[
    {
        "id": 1,
        "task_id": 189,
        "test_case_id": 1,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n10 1 4\n",
        "output": "3 7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 2,
        "task_id": 189,
        "test_case_id": 2,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 1 2 2 3\n",
        "output": "2 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 3,
        "task_id": 189,
        "test_case_id": 3,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "1\n5\n",
        "output": "4 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 4,
        "task_id": 189,
        "test_case_id": 4,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n1 2\n",
        "output": "1 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 5,
        "task_id": 189,
        "test_case_id": 5,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n1 1 1\n",
        "output": "1 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 6,
        "task_id": 189,
        "test_case_id": 6,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n100 100 100 100 100\n",
        "output": "99 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 7,
        "task_id": 189,
        "test_case_id": 7,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "113\n86 67 31 33 72 100 88 63 16 12 79 80 76 45 31 96 44 10 24 33 53 11 56 100 23 57 9 48 28 73 18 48 12 89 73 9 51 11 82 94 90 92 34 99 54 58 33 67 35 87 58 90 94 64 57 80 87 99 84 99 20 1 63 12 16 40 50 95 33 58 7 23 71 89 53 15 95 29 71 16 65 21 66 89 82 30 6 45 6 66 58 32 27 78 28 42 8 61 10 26 7 55 76 65 100 38 79 1 23 81 55 58 38\n",
        "output": "54 2787\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 8,
        "task_id": 189,
        "test_case_id": 8,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n96 93 70\n",
        "output": "92 24\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 9,
        "task_id": 189,
        "test_case_id": 9,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n100 54 93 96\n",
        "output": "94 45\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 10,
        "task_id": 189,
        "test_case_id": 10,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n75 94 58 66 98 95 87 74 65 78\n",
        "output": "76 104\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 11,
        "task_id": 189,
        "test_case_id": 11,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n89 65 98 94 52 71 67 88 70 79\n",
        "output": "72 113\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 12,
        "task_id": 189,
        "test_case_id": 12,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "7\n91 54 87 88 79 62 62\n",
        "output": "78 82\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 13,
        "task_id": 189,
        "test_case_id": 13,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "8\n94 56 100 70 91 79 74 60\n",
        "output": "75 96\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 14,
        "task_id": 189,
        "test_case_id": 14,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "11\n1 1 1 1 1 1 1 1 1 2 3\n",
        "output": "2 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 15,
        "task_id": 189,
        "test_case_id": 15,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n1 3\n",
        "output": "2 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 16,
        "task_id": 189,
        "test_case_id": 16,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n1 10\n",
        "output": "2 7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 17,
        "task_id": 189,
        "test_case_id": 17,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n1 100\n",
        "output": "2 97\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 18,
        "task_id": 189,
        "test_case_id": 18,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 3 9 9\n",
        "output": "4 10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 19,
        "task_id": 189,
        "test_case_id": 19,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n2 4\n",
        "output": "3 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 20,
        "task_id": 189,
        "test_case_id": 20,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n1 1 10\n",
        "output": "2 7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 21,
        "task_id": 189,
        "test_case_id": 21,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n2 2 2 4\n",
        "output": "3 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 22,
        "task_id": 189,
        "test_case_id": 22,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n1 1 1 1 1 1 1 1 1 3\n",
        "output": "2 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 23,
        "task_id": 189,
        "test_case_id": 23,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n1 1 1 1 1 1 1 1 2 3\n",
        "output": "2 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 24,
        "task_id": 189,
        "test_case_id": 24,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 4 5\n",
        "output": "3 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 25,
        "task_id": 189,
        "test_case_id": 25,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "6\n1 1 2 10 11 11\n",
        "output": "3 22\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 26,
        "task_id": 189,
        "test_case_id": 26,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 1 1 100 100\n",
        "output": "2 194\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 27,
        "task_id": 189,
        "test_case_id": 27,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "6\n1 4 10 18 20 25\n",
        "output": "11 42\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 28,
        "task_id": 189,
        "test_case_id": 28,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 4 7\n",
        "output": "3 4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 29,
        "task_id": 189,
        "test_case_id": 29,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n3 5\n",
        "output": "4 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 30,
        "task_id": 189,
        "test_case_id": 30,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "7\n1 1 10 10 10 10 10\n",
        "output": "9 14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 31,
        "task_id": 189,
        "test_case_id": 31,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 70 71\n",
        "output": "3 134\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 32,
        "task_id": 189,
        "test_case_id": 32,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 2 3 3 3\n",
        "output": "2 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 33,
        "task_id": 189,
        "test_case_id": 33,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n2 2 5\n",
        "output": "3 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 34,
        "task_id": 189,
        "test_case_id": 34,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 1 100 100\n",
        "output": "2 194\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 35,
        "task_id": 189,
        "test_case_id": 35,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "1\n1\n",
        "output": "1 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 36,
        "task_id": 189,
        "test_case_id": 36,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 1 5 5\n",
        "output": "2 4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 37,
        "task_id": 189,
        "test_case_id": 37,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 19 20\n",
        "output": "3 32\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 38,
        "task_id": 189,
        "test_case_id": 38,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 29 30\n",
        "output": "3 52\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 39,
        "task_id": 189,
        "test_case_id": 39,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 1 9 9\n",
        "output": "2 12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 40,
        "task_id": 189,
        "test_case_id": 40,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n5 7 7\n",
        "output": "6 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 41,
        "task_id": 189,
        "test_case_id": 41,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 3 3 3\n",
        "output": "2 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 42,
        "task_id": 189,
        "test_case_id": 42,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "6\n1 10 20 30 31 31\n",
        "output": "21 55\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 43,
        "task_id": 189,
        "test_case_id": 43,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n3 3 5\n",
        "output": "4 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 44,
        "task_id": 189,
        "test_case_id": 44,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n1 1 5\n",
        "output": "2 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 45,
        "task_id": 189,
        "test_case_id": 45,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n1 6\n",
        "output": "2 3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 46,
        "task_id": 189,
        "test_case_id": 46,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n1 20\n",
        "output": "2 17\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 47,
        "task_id": 189,
        "test_case_id": 47,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "7\n4 4 4 7 7 7 7\n",
        "output": "6 3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 48,
        "task_id": 189,
        "test_case_id": 48,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 100 100 100 100\n",
        "output": "99 97\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 49,
        "task_id": 189,
        "test_case_id": 49,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 1 1 5\n",
        "output": "2 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 50,
        "task_id": 189,
        "test_case_id": 50,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "7\n1 1 1 1 100 100 100\n",
        "output": "2 291\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 51,
        "task_id": 189,
        "test_case_id": 51,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n1 4 4\n",
        "output": "3 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 52,
        "task_id": 189,
        "test_case_id": 52,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 10 11\n",
        "output": "3 14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 53,
        "task_id": 189,
        "test_case_id": 53,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "11\n2 11 13 14 18 20 20 21 22 23 25\n",
        "output": "19 43\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 54,
        "task_id": 189,
        "test_case_id": 54,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n8 8 8 8 8 8 8 8 9 10\n",
        "output": "9 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 55,
        "task_id": 189,
        "test_case_id": 55,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n1 100 100\n",
        "output": "99 97\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 56,
        "task_id": 189,
        "test_case_id": 56,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n4 4 4 4 6\n",
        "output": "5 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 57,
        "task_id": 189,
        "test_case_id": 57,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n5 5 5 5 5 5 5 5 5 9\n",
        "output": "6 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 58,
        "task_id": 189,
        "test_case_id": 58,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n1 1 1 1 1 1 100 100 100 100\n",
        "output": "2 388\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 59,
        "task_id": 189,
        "test_case_id": 59,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n7 14\n",
        "output": "8 5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 60,
        "task_id": 189,
        "test_case_id": 60,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "6\n1 1 1 1 97 98\n",
        "output": "2 189\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 61,
        "task_id": 189,
        "test_case_id": 61,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100\n",
        "output": "2 4850\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 62,
        "task_id": 189,
        "test_case_id": 62,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n8 8 8 8 8 8 8 8 8 10\n",
        "output": "9 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 63,
        "task_id": 189,
        "test_case_id": 63,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 1 10 10\n",
        "output": "2 14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 64,
        "task_id": 189,
        "test_case_id": 64,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n1 1 1 1 1 1 1 1 1 99\n",
        "output": "2 96\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 65,
        "task_id": 189,
        "test_case_id": 65,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 8 8\n",
        "output": "3 9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 66,
        "task_id": 189,
        "test_case_id": 66,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n1 50 50\n",
        "output": "49 47\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 67,
        "task_id": 189,
        "test_case_id": 67,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 9 10\n",
        "output": "3 12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 68,
        "task_id": 189,
        "test_case_id": 68,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n1 1 3\n",
        "output": "2 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 69,
        "task_id": 189,
        "test_case_id": 69,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "10\n1 1 1 1 1 1 1 1 1 9\n",
        "output": "2 6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 70,
        "task_id": 189,
        "test_case_id": 70,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 5 100\n",
        "output": "3 98\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 71,
        "task_id": 189,
        "test_case_id": 71,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 1 1 97 98\n",
        "output": "2 189\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 72,
        "task_id": 189,
        "test_case_id": 72,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n3 3 5 5 7\n",
        "output": "4 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 73,
        "task_id": 189,
        "test_case_id": 73,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 2 9 9 12\n",
        "output": "8 14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 74,
        "task_id": 189,
        "test_case_id": 74,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 1 1 1 3\n",
        "output": "2 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 75,
        "task_id": 189,
        "test_case_id": 75,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "2\n66 100\n",
        "output": "67 32\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 76,
        "task_id": 189,
        "test_case_id": 76,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "3\n1 1 100\n",
        "output": "2 97\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 77,
        "task_id": 189,
        "test_case_id": 77,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "11\n3 4 9 13 39 53 53 58 63 82 83\n",
        "output": "52 261\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 78,
        "task_id": 189,
        "test_case_id": 78,
        "question": "Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \\ldots, a_n$.\n\nFor every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.\n\nA stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \\le 1$.\n\nSalem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. \n\nAs an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 1000$) — the number of sticks.\n\nThe second line contains $n$ integers $a_i$ ($1 \\le a_i \\le 100$) — the lengths of the sticks.\n\n\n-----Output-----\n\nPrint the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.\n\n\n-----Examples-----\nInput\n3\n10 1 4\n\nOutput\n3 7\n\nInput\n5\n1 1 2 2 3\n\nOutput\n2 0\n\n\n\n-----Note-----\n\nIn the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.\n\nIn the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.",
        "solutions": "[\"n = int(input())\\na = list(map(int,input().split()))\\nt = 0\\nmn = 1000000000\\nfor i in range(1,100):\\n    cur = 0\\n    for j in range(n):\\n        cur += max(0,abs(i-a[j])-1)\\n    if cur < mn:\\n        mn = cur\\n        t = i\\nprint(t,mn)\\n\", \"n=int(input())\\na=[*map(int,input().split())]\\n\\nmcost = 10**8\\nans = 0\\n\\nfor i in range(1,101):\\n    tcost = 0\\n    for j in range(n):\\n        if a[j] > i:\\n            d = abs(a[j] - (i + 1))\\n        elif a[j] < i:\\n            d = abs(a[j] - (i - 1))\\n        else:\\n            d = 0\\n        tcost += d\\n    if tcost < mcost:\\n        mcost, ans = tcost , i\\n\\nprint(ans, mcost)\", \"n = int(input())\\ns = list(map(int,input().split()))\\na,b = -1,188888\\nfor t in range(1,101):\\n    mi = 0\\n    for i in range(n):\\n        mi += min(abs(s[i]-t),abs(s[i]-t-1),abs(s[i]-t+1))\\n    if b>mi:\\n        a,b = t,mi\\nprint(a,b)\", \"import math\\n\\nn = int(input())\\nA = [int(i) for i in input().split()]\\nA.sort()\\n\\nans = 10**18\\nval = 0\\nfor mid in range(1,100):\\n    cost = 0\\n    for i in range(n):\\n        cost += min(abs(A[i] - mid), abs(A[i]-mid+1), abs(A[i]-mid-1))\\n    if cost<ans:\\n        ans = cost\\n        val = mid\\n\\nprint(val, ans)\\n\", \"def read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef compute_min_cost(t, nums):\\n    res = 0\\n    for num in nums:\\n        if abs(t - num) <= 1:\\n            continue\\n        res += abs(num - t) - 1\\n    return res\\n\\n\\ndef main():\\n    _ = read_nums()\\n\\n    costs = []\\n    nums = read_nums()\\n    for t in range(1, 101):\\n        min_cost = compute_min_cost(t, nums)\\n        costs.append((t, min_cost))\\n\\n    t, cost = sorted(costs, key=lambda x: x[1])[0]\\n    print(t, cost)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n    mm = inf\\n    mi = 0\\n    for i in range(1,100):\\n        t = 0\\n        for c in a:\\n            if c < i:\\n                t += i-1-c\\n            elif c > i:\\n                t += c - 1 - i\\n        if mm > t:\\n            mi = i\\n            mm = t\\n\\n    return '{} {}'.format(mi, mm)\\n\\n\\n\\nprint(main())\\n\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmincost=100000\\nans=0\\nfor t in range(1,101):\\n    curcost=0\\n    for i in l:\\n        if i==t:\\n            continue\\n        else:\\n            curcost+=abs(t-i)-1\\n    if curcost<mincost:\\n        mincost=curcost\\n        ans=t\\nprint(ans,mincost)\", \"n = int(input())\\n\\narr = list(map(int, input().split()))\\narr.sort()\\n\\na = []\\nfor t in range(1, 101):\\n    tot = 0\\n    for item in arr:\\n        if (abs(item - t) >= 1):\\n            tot += abs(item - t) - 1\\n    \\n    a.append((tot, t))\\n\\na.sort()\\n\\nprint(a[0][1], a[0][0])\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nt = []\\nfor i in range(101):\\n    s = 0\\n    for j in arr:\\n        s += max(0, abs(j - i) - 1)\\n    t.append(s)\\np = t[1:].index(min(t)) + 1\\nprint(p, min(t))\", \"n=int(input())\\nans=10**18\\nval=-1\\narr=list(map(int,input().split()))\\nfor i in range(1,102):\\n    valx=0\\n    for j in arr:\\n        if(abs(j-i)>1):\\n            valx+=abs(j-i)-1\\n    if(valx<ans):\\n        ans=valx\\n        val=i\\nprint(val,ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 10 ** 8\\nansi = 0\\nfor i in range(1, 101):\\n\\ttmp = sum(min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a)\\n\\tif tmp < ans:\\n\\t\\tans = tmp\\n\\t\\tansi = i\\nprint(ansi, ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\ndef f(a):\\n    return [sum(min(\\n        [abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l), a]\\nres = [float('inf'), float('inf')]\\nfor a in range(1, 101):\\n    res = min(res, f(a))\\nprint(res[1], res[0])\", \"N = int(input())\\nnumber_list = list(map(int, input().split(' ')))\\nret = [0, 9999999]\\nfor n in range(1, 101):\\n    temp = 0\\n    for number in number_list:\\n        temp += max(0, abs(number - n) - 1)\\n    if ret[1] > temp:\\n        ret[0] = n\\n        ret[1] = temp\\n\\nprint(ret[0], ret[1])\\n\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nmincost = 1000 * 100 + 1\\nbest_t = None\\nfor t in range(1, 101):\\n    cost = 0\\n    for x in a:\\n        cost += max(0, abs(x - t) - 1)\\n    if cost < mincost:\\n        mincost = cost\\n        best_t = t\\n\\nprint(best_t, mincost)\", \"n = int(input())\\na = [int(v) for v in input().split()]\\na.sort()\\n\\ndef cost1(v, t):\\n    if v < t - 1:\\n        return t - 1 - v\\n    elif v > t + 1:\\n        return v - (t + 1)\\n    else:\\n        return 0\\n\\nbest_t = None\\nbest_cost = 9999999999999\\n\\nfor t in range(1, 101):\\n    cost = sum(cost1(v, t) for v in a)\\n    if cost < best_cost:\\n        best_cost = cost\\n        best_t = t\\n\\nprint(best_t, best_cost)\\n\", \"n=int(input())\\n\\nl=list(map(int,input().split()))\\n\\nmaxx=10000000000\\ncur=0\\nfor i in range(1,101):\\n\\tnow=0\\n\\tfor j in range(n):\\n\\t\\tif l[j]<i:\\n\\t\\t\\tnow+=i-l[j]-1\\n\\t\\telif l[j]>i:\\n\\t\\t\\tnow+=l[j]-i-1\\n\\n\\tif now<maxx:\\n\\t\\tmaxx=now\\n\\t\\tcur=i\\n\\nprint(cur, maxx)\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n#n,m=map(int,stdin.readline().strip().split())\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nans=10**20\\nt1=-1\\nfor t in range(1,101):\\n    aux1=0\\n    for j in range(n):\\n        aux=102\\n        aux=min(aux,abs(1+t-s[j]))\\n        aux=min(aux,abs(t-1-s[j]))\\n        aux=min(aux,abs(t-s[j]))\\n        aux1+=aux\\n    if aux1<ans:\\n        ans=aux1\\n        t1=t\\nprint(t1,ans)\\n        \\n        \\n\", \"import math\\nn = int(input())\\nar = [*map(int, input().split(' '))]\\nmint,mincost = int(1e9),int(1e9)\\nfor i in range(1,105):\\n\\tcost = sum([min(abs(x-i), abs(x-i-1), abs(x-i+1)) for x in ar])\\n\\tif cost < mincost:\\n\\t\\tmincost = cost\\n\\t\\tmint = i\\nprint(int(mint), int(mincost))\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = [0] * 101\\nfor i in range(1, 101):\\n    for k in range(n):\\n        ans[i] += max(abs(l[k] - i) - 1, 0)\\ncnt = [100000000, 100000000]\\nfor i in range(1, 101):\\n    if cnt[1] > ans[i]:\\n        cnt[0] = i\\n        cnt[1] = ans[i]\\nprint(cnt[0], cnt[1])\", \"n=int(input())\\nar=list(map(int,input().split()))\\ndef f(i):\\n    ans=0\\n    for e in ar:\\n        if(e==i):continue\\n        else:ans+=abs(e-i)-1\\n    return ans\\na=float('inf')\\nb=0\\nfor x in range(1,1001):\\n    if(f(x)<a):\\n        a=f(x)\\n        b=x\\nprint(b,a)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nmi = 10 ** 8\\nx = -1\\nfor i in range(1, 111):\\n    s = 0\\n    for j in range(n):\\n        if not i - 1 <= a[j] <= i + 1:\\n            if a[j] < i - 1:\\n                z = i - 1 - a[j]\\n            else:\\n                z = a[j] - i - 1\\n            s += z\\n    if s < mi:\\n        mi = s\\n        x = i\\nprint(x, mi)\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 1 1 10\n",
        "output": "2 7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1105/A"
    },
    {
        "id": 79,
        "task_id": 199,
        "test_case_id": 1,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 3\n4 3 5\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 80,
        "task_id": 199,
        "test_case_id": 2,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 4\n5 3 4\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 81,
        "task_id": 199,
        "test_case_id": 3,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 7\n1 2 3\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 82,
        "task_id": 199,
        "test_case_id": 4,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 1\n1\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 83,
        "task_id": 199,
        "test_case_id": 5,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 2\n1\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 84,
        "task_id": 199,
        "test_case_id": 6,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 10\n10 10 10 10 10\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 85,
        "task_id": 199,
        "test_case_id": 7,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 1000000000\n1000000000\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 86,
        "task_id": 199,
        "test_case_id": 8,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 1000000000000\n42\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 87,
        "task_id": 199,
        "test_case_id": 9,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 2\n1 1 5\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 88,
        "task_id": 199,
        "test_case_id": 10,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n1 100\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 89,
        "task_id": 199,
        "test_case_id": 11,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 1\n5 10 15\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 90,
        "task_id": 199,
        "test_case_id": 12,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n1 1000\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 91,
        "task_id": 199,
        "test_case_id": 13,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 3\n2 4 4\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 92,
        "task_id": 199,
        "test_case_id": 14,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "10 1\n1 2 3 4 5 6 7 8 9 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 93,
        "task_id": 199,
        "test_case_id": 15,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 6\n1 99 99\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 94,
        "task_id": 199,
        "test_case_id": 16,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4 1\n100 1 100 100\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 95,
        "task_id": 199,
        "test_case_id": 17,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 2\n4 6 8 10 14\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 96,
        "task_id": 199,
        "test_case_id": 18,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4 6\n1 2 3 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 97,
        "task_id": 199,
        "test_case_id": 19,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 2\n4 6 8 10 19\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 98,
        "task_id": 199,
        "test_case_id": 20,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4 1\n5 3 1 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 99,
        "task_id": 199,
        "test_case_id": 21,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4 2\n2 3 4 5\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 100,
        "task_id": 199,
        "test_case_id": 22,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 10\n1 9 9\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 101,
        "task_id": 199,
        "test_case_id": 23,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 7\n1 5 12\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 102,
        "task_id": 199,
        "test_case_id": 24,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n1 1000000000\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 103,
        "task_id": 199,
        "test_case_id": 25,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 1\n100 100 100 100 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 104,
        "task_id": 199,
        "test_case_id": 26,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n100 10000\n",
        "output": "100\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 105,
        "task_id": 199,
        "test_case_id": 27,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 1\n5 5 5 5 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 106,
        "task_id": 199,
        "test_case_id": 28,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 500\n1 1000\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 107,
        "task_id": 199,
        "test_case_id": 29,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n1 10000000\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 108,
        "task_id": 199,
        "test_case_id": 30,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 50\n1 100\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 109,
        "task_id": 199,
        "test_case_id": 31,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n100 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 110,
        "task_id": 199,
        "test_case_id": 32,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 1\n1 1 1 1 1000\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 111,
        "task_id": 199,
        "test_case_id": 33,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 3\n4 4 92\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 112,
        "task_id": 199,
        "test_case_id": 34,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 30\n1 100\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 113,
        "task_id": 199,
        "test_case_id": 35,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 94\n1 99\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 114,
        "task_id": 199,
        "test_case_id": 36,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "6 1\n2 2 3 6 6 6\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 115,
        "task_id": 199,
        "test_case_id": 37,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 3\n1 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 116,
        "task_id": 199,
        "test_case_id": 38,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 3\n100 4 4\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 117,
        "task_id": 199,
        "test_case_id": 39,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 10\n100 100 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 118,
        "task_id": 199,
        "test_case_id": 40,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n1000000000 999999999\n",
        "output": "999999999\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 119,
        "task_id": 199,
        "test_case_id": 41,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 3\n1 3 5\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 120,
        "task_id": 199,
        "test_case_id": 42,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 5\n1 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 121,
        "task_id": 199,
        "test_case_id": 43,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "15 56\n38 47 84 28 67 40 15 24 64 37 68 30 74 41 62\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 122,
        "task_id": 199,
        "test_case_id": 44,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 5\n1 100 100 100 100\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 123,
        "task_id": 199,
        "test_case_id": 45,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n1 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 124,
        "task_id": 199,
        "test_case_id": 46,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 4\n1 2 2\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 125,
        "task_id": 199,
        "test_case_id": 47,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 2\n900000000 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 126,
        "task_id": 199,
        "test_case_id": 48,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4 1\n1 5 5 5\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 127,
        "task_id": 199,
        "test_case_id": 49,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 7\n1 5 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 128,
        "task_id": 199,
        "test_case_id": 50,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4 2\n5 7 8 9\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 129,
        "task_id": 199,
        "test_case_id": 51,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 3\n1 2 3 4 5\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 130,
        "task_id": 199,
        "test_case_id": 52,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 3\n100 2 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 131,
        "task_id": 199,
        "test_case_id": 53,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 5\n1 100\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 132,
        "task_id": 199,
        "test_case_id": 54,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 5000\n1 1000000000\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 133,
        "task_id": 199,
        "test_case_id": 55,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 1000000000000\n1000000000\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 134,
        "task_id": 199,
        "test_case_id": 56,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n2 4\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 135,
        "task_id": 199,
        "test_case_id": 57,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 3\n1 2 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 136,
        "task_id": 199,
        "test_case_id": 58,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 2\n5 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 137,
        "task_id": 199,
        "test_case_id": 59,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 5000\n1 100000000\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 138,
        "task_id": 199,
        "test_case_id": 60,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 1\n1 4 5\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 139,
        "task_id": 199,
        "test_case_id": 61,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 50\n1 500\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 140,
        "task_id": 199,
        "test_case_id": 62,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 5\n1 8\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 141,
        "task_id": 199,
        "test_case_id": 63,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 100\n1 100 100\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 142,
        "task_id": 199,
        "test_case_id": 64,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 3\n4 6 7\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 143,
        "task_id": 199,
        "test_case_id": 65,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n2 5\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 144,
        "task_id": 199,
        "test_case_id": 66,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 4\n8 1000\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 145,
        "task_id": 199,
        "test_case_id": 67,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1000000000\n99999999 1000000000\n",
        "output": "49999999\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 146,
        "task_id": 199,
        "test_case_id": 68,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 3\n23 123 123\n",
        "output": "23\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 147,
        "task_id": 199,
        "test_case_id": 69,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 1\n5 6 3\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 148,
        "task_id": 199,
        "test_case_id": 70,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 1\n1 10 10 10 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 149,
        "task_id": 199,
        "test_case_id": 71,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 5\n1 1 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 150,
        "task_id": 199,
        "test_case_id": 72,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 1\n1 1 5\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 151,
        "task_id": 199,
        "test_case_id": 73,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 5\n1 2 3\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 152,
        "task_id": 199,
        "test_case_id": 74,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4 4\n1000000000 1000000000 1000000000 1000000000\n",
        "output": "999999999\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 153,
        "task_id": 199,
        "test_case_id": 75,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 100\n1 55 55\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 154,
        "task_id": 199,
        "test_case_id": 76,
        "question": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.\n\nHelp him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $s$ liters of kvass.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $s$ ($1 \\le n \\le 10^3$, $1 \\le s \\le 10^{12}$) — the number of kegs and glass volume.\n\nThe second line contains $n$ integers $v_1, v_2, \\ldots, v_n$ ($1 \\le v_i \\le 10^9$) — the volume of $i$-th keg.\n\n\n-----Output-----\n\nIf the Fair Nut cannot pour his glass by $s$ liters of kvass, print $-1$. Otherwise, print a single integer — how much kvass in the least keg can be.\n\n\n-----Examples-----\nInput\n3 3\n4 3 5\n\nOutput\n3\n\nInput\n3 4\n5 3 4\n\nOutput\n2\n\nInput\n3 7\n1 2 3\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the answer is $3$, the Fair Nut can take $1$ liter from the first keg and $2$ liters from the third keg. There are $3$ liters of kvass in each keg.\n\nIn the second example, the answer is $2$, the Fair Nut can take $3$ liters from the first keg and $1$ liter from the second keg.\n\nIn the third example, the Fair Nut can't pour his cup by $7$ liters, so the answer is $-1$.",
        "solutions": "[\"def doit():\\n    xx = input().split()\\n    n = int(xx[0])\\n    s = int(xx[1])\\n    v = [int(k) for k in input().split()]\\n\\n    S = sum(v)\\n    newS = S - s\\n    if newS < 0:\\n        return -1\\n    return min(newS//n, min(v))\\n        \\nprint(doit())\\n\", \"n, s = list(map(int, input().split()))\\n\\nv = list(map(int, input().split()))\\n\\nif sum(v) < s:\\n    print(-1)\\n    return\\n\\nmv = min(v)\\n\\nfor i in range(n):\\n    s -= v[i] - mv\\n\\nif s < 1:\\n    print(mv)\\n    return\\n\\nans = mv - s // n\\nif s % n != 0:\\n    ans -= 1\\n\\nprint(ans)\\n\\n\\n\\n\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\n\\nn, s = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\n\\nl, r = -1, min(values) + 1\\nwhile r - l > 1:\\n    m = (l + r) >> 1\\n    \\n    cnt = 0\\n    for v in values:\\n        cnt += v - m\\n    \\n    if cnt >= s:\\n        l = m\\n    else:\\n        r = m\\n\\nif l == -1:\\n    stdout.write('-1\\\\n')\\nelse:\\n    stdout.write(str(l) + '\\\\n')\", \"n, s = list(map(int, input().split()))\\n\\nallCups = list(map(int, input().split()))\\nsumK = sum(allCups)\\nminK = min(allCups)\\nif sumK < s:\\n    print(-1)\\n\\nelse:\\n    if sumK - (minK * n) >= s:\\n        print(minK)\\n    else:\\n        s = s - (sumK - (minK * n))\\n        #print(s)\\n        if s % n == 0:\\n            print(minK - (s // n))\\n        else:\\n            print(minK - (s // n) - 1)\\n\", \"n, s = list(map(int, input().split()))\\na = list(map(int, input().split()))\\na.sort()\\nd = sum(a)\\nif d >= s:\\n    r = d - s\\n    ans = min(r // n, a[0])\\nelse:\\n    ans = -1\\n\\nprint(ans)\\n\", \"n, s = map(int, input().split())\\nnum = list(map(int, input().split()))\\nx = sum(num)\\nif x < s:\\n    print(-1)\\nelse:\\n    k = min(num)\\n    for i in range(n):\\n        s -= abs(num[i] - k)\\n        num[i] = k\\n    if s <= 0:\\n        print(k)\\n    else:\\n        q = s // n\\n        k -= q\\n        if s % n == 0:\\n            print(k)\\n        else:\\n            print(k - 1)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\nA = list(map(int, input().split()))\\nif sum(A) < s:\\n    print(-1)\\nelse:\\n    x = min(A)\\n    y = 0\\n    for k in range(n):\\n        y += (A[k] - x)\\n    if y >= s:\\n        print(x)\\n    else:\\n        a = s - y\\n        print(x - ceil(a / n))\", \"n,s=map(int,input().split())\\na=list(map(int,input().split()))\\ny=min(a)*n\\nx=sum(a)\\nif x<s:\\n    print(-1)\\nelse:\\n    if s<=x-y:\\n        print(y//n)\\n    else:\\n       s=s-(x-y)\\n       print((y-s)//n)\", \"import math\\nn,s=map(int,input().split())\\nv=list(map(int,input().split()))\\nx=sum(v)\\nif s>x:\\n    print(-1)\\nelse:\\n    a=min(v)\\n    if s<x-n*a:\\n        print(a)\\n    else:\\n        b=x-n*a\\n        c=s-b\\n        print(a-math.ceil(c/n))\", \"n, s = list(map(int, input().split()))\\nv = list(map(int, input().split()))\\nsm = sum(v)\\nsm -= s\\nif sm < 0:\\n    print(-1)\\nelse:\\n    mn = min(v)\\n    r = min(mn, sm // n)\\n    print(r)\\n\", \"import math, sys, itertools\\n\\ndef mp():\\n    return list(map(int, input().split()))\\n\\ndef main():\\n    n, s = mp()\\n    a = mp()\\n    sm = sum(a)\\n    if sm < s:\\n        print(-1)\\n        return\\n    ans = (sum(a) - s) // n\\n    print(min(ans, min(a)))\\n        \\n\\ndeb = 0\\nif deb:\\n    file = open('input.txt', 'r')\\n    input = file.readline\\nelse:\\n    input = sys.stdin.readline\\n    \\nmain()\", \"n, s = list(map(int, input().split()))\\nv = [int(k) for k in input().split()]\\nv.sort(reverse=True)\\nfor i in range(n):\\n    s -= v[i] - v[-1]\\n    v[i] = v[-1]\\nif s <= 0:\\n    print(v[-1])\\nelse:\\n    if s > n * v[0]:\\n        print(-1)\\n    else:\\n        print(v[0] - (s + n - 1) // n)  \\n\", \"import math\\nn,s = list(map(int,input().split()))\\nv = input().split()\\nmini = math.inf\\nfor i in range(n):\\n    mini = min(int(v[i]),mini)\\ns += mini*n\\nfor i in range(n):\\n    s -= int(v[i])\\nif s < 0:\\n    print(mini)\\nelif s > mini*n:\\n    print(-1)\\nelif s%n == 0:\\n    print(mini-s//n)\\nelse:\\n    print(mini-s//n-1)\\n\", \"n, s = list(map(int, input().split()))\\nv = [int(x) for x in input().split()]\\nt = sum(v)\\nif sum(v) < s:\\n\\tprint(-1)\\n\\treturn\\nb = min(v)\\nkol = t - b * n\\ns -= kol\\nif s <= 0:\\n\\tprint(b)\\n\\treturn\\ntmp = (s + n - 1) // n\\nprint(b - tmp)\\n\", \"n, s = map(int, input().split())\\nl = [*map(int, input().split())]\\nsm = sum(l)\\nif sm < s:\\n    print(-1)\\n    return\\nm = min(l)\\ns -= sm - m * n\\nif s <= 0:\\n    print(m)\\nelse:\\n    print(m - (s + n - 1)//n)\", \"n, s = map(int, input().split())\\nk = list(map(int, input().split()))\\nsumk = sum(k)\\nmink = min(k)\\nif sumk < s:\\n    print(-1)\\n    return\\nif sumk-n*mink >= s:\\n    print(mink)\\nelse:\\n    s -= sumk-n*mink\\n    if s%n == 0:\\n        print(mink-s//n)\\n    else:\\n        print(mink-s//n-1)\", \"import math\\nn,q=list(map(int,input().split()))\\nh=list(map(int,input().split()))\\nt=0\\nfor i in range (n):\\n    t+=h[i]\\nif t<q:\\n    print(-1)\\n    return\\nlow=min(h)\\nfor i in range (n):\\n    q-=(h[i]-low)\\nif q<=0:\\n    print(low)\\n    return\\nlow-=math.ceil(q/n)\\nprint(low)\\n\", \"n,s = map(int,input().split())\\nl = list(map(int, input().split()))\\n\\nif sum(l) < s:\\n\\tprint(-1)\\n\\treturn\\nq = sum(l) - min(l) * n\\nif q>=s:\\n\\tprint(min(l))\\n\\treturn\\nprint(min(l)-(s-q+n-1)//n)\", \"n, S = [int(x) for x in input().split()]\\n\\nA = [int(x) for x in input().split()]\\n\\ndef ans():\\n  nonlocal S\\n  to_min = sum(A) - n*min(A)\\n  S -= to_min\\n  if S <= 0:\\n    return min(A)\\n  if n*min(A) < S: return -1\\n  return (n*min(A) - S) // n\\n\\nprint(ans())\\n\", \"n, s = list(map(int, input().split()))\\nu = list(map(int, input().split()))\\nmu = min(u)\\nsu = sum(u)\\nif su < s:\\n    print(-1)\\nelse:\\n    s -= (su - mu * n)\\n    if s <= 0:\\n        print(mu)\\n    else:\\n        k = s // n\\n        if s % n != 0:\\n            k += 1\\n        print(mu - k)\\n\", \"n, k = list(map(int, input().split(' ')))\\n\\na = list(map(int, input().split(' ')))\\n\\nminV = min(a)\\n\\ns = sum(a)\\n\\nif(k > s):\\n  print(-1)\\nelse:\\n  rest = s - minV * n\\n  if(rest >= k):\\n    print(minV)\\n  else:\\n    k -= rest\\n    \\n    sol = k // n\\n    if(k % n):\\n      sol += 1\\n\\n    print(minV - sol)\", \"def ifPoss(arr,v,h):\\n    tot = 0\\n    for i in arr:\\n        tot += (i-h)\\n    return tot>=v\\ndef prog():\\n    n,v = map(int,input().split())\\n    arr = [int(x) for x in input().split()]\\n    minLev = -1\\n    l,h = 0,min(arr)\\n    while(l<=h):\\n        m = int((l+h)/2)\\n        if(ifPoss(arr,v,m)):\\n            minLev = max(minLev,m)\\n            l = m+1\\n        else:\\n            h = m-1\\n    return minLev\\nprint(prog())\", \"#!/usr/bin/env python\\n# coding: utf-8\\n\\n# In[15]:\\n\\n\\nimport math\\nns=list(map(int, input().rstrip().split()))\\nn=ns[0]\\ns=ns[1]\\n\\ndata=list(map(int, input().rstrip().split()))\\n\\n\\n# In[16]:\\n\\n\\ndata.sort()\\n\\n\\n# In[17]:\\n\\n\\nextras=[i-data[0] for i in data]\\n\\n\\n# In[18]:\\n\\n\\ntotal=sum(data)\\nextratotal=sum(extras)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\\n\\n# In[19]:\\n\\n\\nif s>total:\\n    print(-1)\\nelif extratotal>=s:\\n    print(data[0])    \\nelse:\\n    sub=math.ceil((s-extratotal)/n)\\n    print(data[0]-sub)\\n    \\n\\n\\n# In[ ]:\\n\\n\", \"import sys\\nfrom math import ceil\\n\\n\\ndef main():\\n    n, s = map(int, sys.stdin.readline().split())\\n    arr = list(map(int, sys.stdin.readline().split()))\\n    if s > sum(arr):\\n        print(-1, sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n    else:\\n        count = 0\\n        arr.sort(reverse=True)\\n        for i in range(n-1):\\n            if count == s:\\n                break\\n            if count+(arr[i]-arr[-1]) <= s:\\n                count += arr[i]-arr[-1]\\n                arr[i] = arr[-1]\\n            elif count+(arr[i]-arr[-1]) > s:\\n                count = s\\n                arr[i] -= (s-count)\\n        if count == s:\\n            print(arr[-1])\\n        else:\\n            factor = (s-count)/n\\n\\n            print(arr[-1]-ceil(factor), sep=' ', end='\\\\n', file=sys.stdout, flush=False)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 1\n1 7\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1084/B"
    },
    {
        "id": 155,
        "task_id": 226,
        "test_case_id": 1,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "3\n141 592 653\n",
        "output": "653 733\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 156,
        "task_id": 226,
        "test_case_id": 2,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "5\n10 21 10 21 10\n",
        "output": "31 41\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 157,
        "task_id": 226,
        "test_case_id": 4,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "50\n100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000\n",
        "output": "2500000 2500000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 158,
        "task_id": 226,
        "test_case_id": 5,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "2\n1 100000\n",
        "output": "1 100000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 159,
        "task_id": 226,
        "test_case_id": 6,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "17\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536\n",
        "output": "65535 65536\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 160,
        "task_id": 226,
        "test_case_id": 7,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "15\n3026 3027 4599 4854 7086 29504 38709 40467 40663 58674 61008 70794 77517 85547 87320\n",
        "output": "306375 306420\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 161,
        "task_id": 226,
        "test_case_id": 8,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "30\n2351 14876 66138 87327 29940 73204 19925 50198 13441 54751 1383 92120 90236 13525 3920 16669 80637 94428 54890 71321 77670 57080 82145 39778 69967 38722 46902 82127 1142 21792\n",
        "output": "724302 724303\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 162,
        "task_id": 226,
        "test_case_id": 10,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "2\n9859 48096\n",
        "output": "9859 48096\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 163,
        "task_id": 226,
        "test_case_id": 11,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "3\n25987 64237 88891\n",
        "output": "88891 90224\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 164,
        "task_id": 226,
        "test_case_id": 12,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "4\n9411 13081 2149 19907\n",
        "output": "19907 24641\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 165,
        "task_id": 226,
        "test_case_id": 13,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "5\n25539 29221 6895 82089 18673\n",
        "output": "80328 82089\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 166,
        "task_id": 226,
        "test_case_id": 14,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "6\n76259 10770 87448 3054 67926 81667\n",
        "output": "158428 168696\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 167,
        "task_id": 226,
        "test_case_id": 15,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "7\n92387 35422 24898 32532 92988 84636 99872\n",
        "output": "192724 270011\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 168,
        "task_id": 226,
        "test_case_id": 16,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "8\n8515 51563 5451 94713 9537 30709 63343 41819\n",
        "output": "138409 167241\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 169,
        "task_id": 226,
        "test_case_id": 17,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "9\n91939 407 10197 24191 58791 9486 68030 25807 11\n",
        "output": "102429 186430\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 170,
        "task_id": 226,
        "test_case_id": 18,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "10\n30518 96518 74071 59971 50121 4862 43967 73607 19138 90754\n",
        "output": "252317 291210\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 171,
        "task_id": 226,
        "test_case_id": 19,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "11\n46646 21171 78816 89449 99375 50934 15950 90299 18702 62232 12657\n",
        "output": "288850 297381\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 172,
        "task_id": 226,
        "test_case_id": 20,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "12\n30070 37311 92074 18927 91732 29711 12126 41583 52857 99118 73097 33928\n",
        "output": "296580 315954\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 173,
        "task_id": 226,
        "test_case_id": 21,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "13\n13494 86155 96820 72596 40986 99976 16813 25571 87013 3301 832 26376 83769\n",
        "output": "325890 327812\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 174,
        "task_id": 226,
        "test_case_id": 22,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "14\n96918 67704 10077 34778 90239 11457 80284 42263 53872 74779 93976 53416 83860 74518\n",
        "output": "414474 453667\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 175,
        "task_id": 226,
        "test_case_id": 23,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "15\n13046 83844 14823 64255 15301 90234 84972 93547 88028 11665 54415 13159 83950 951 42336\n",
        "output": "362168 392358\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 176,
        "task_id": 226,
        "test_case_id": 24,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "16\n29174 32688 95377 26437 64554 60498 56955 10239 22183 15847 47559 40199 92552 70488 4147 73082\n",
        "output": "370791 371188\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 177,
        "task_id": 226,
        "test_case_id": 25,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "17\n79894 24637 8634 80107 81104 39275 53130 94227 56339 87326 7999 75751 92642 96921 74470 20999 69688\n",
        "output": "492038 551105\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 178,
        "task_id": 226,
        "test_case_id": 26,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "18\n96022 73481 13380 42288 6166 85348 25113 78215 23198 24212 44246 35494 92733 66459 44793 68916 82818 3967\n",
        "output": "436157 470692\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 179,
        "task_id": 226,
        "test_case_id": 27,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "19\n79446 55030 93934 39062 88123 88317 21289 62203 57354 28394 37390 95238 92823 92892 39308 16833 54733 51525 58759\n",
        "output": "538648 614005\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 180,
        "task_id": 226,
        "test_case_id": 28,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "20\n5440 88704 61481 72140 15810 58854 43034 5150 80684 61360 50516 54301 78790 43678 46138 79893 89899 60260 2881 66499\n",
        "output": "506639 558873\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 181,
        "task_id": 226,
        "test_case_id": 29,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "21\n21569 37548 74739 25809 65063 37631 71913 89138 47543 65542 10956 14045 78880 70111 73357 27810 70326 40523 899 6547 87440\n",
        "output": "506467 510922\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 182,
        "task_id": 226,
        "test_case_id": 30,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "22\n72289 86393 79484 55287 14317 83704 11192 73126 81699 2429 4100 41085 87482 72352 10976 75727 42240 79569 31621 3492 51189 25936\n",
        "output": "513496 572193\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 183,
        "task_id": 226,
        "test_case_id": 31,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "23\n88417 11045 92742 84765 6675 86673 40072 57114 15854 6611 40347 76636 87572 66082 38195 56348 89962 59831 29640 43541 14937 73713 52755\n",
        "output": "602650 616877\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 184,
        "task_id": 226,
        "test_case_id": 32,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "24\n71841 27185 73295 46946 55928 65450 12055 73806 82714 78089 787 36380 87663 68323 75814 4265 94581 31581 51850 40486 11390 21491 27560 22678\n",
        "output": "560664 601494\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 185,
        "task_id": 226,
        "test_case_id": 33,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "25\n87969 76030 78041 616 13694 11522 84038 25090 16869 14975 61226 96124 20457 62052 70329 76374 42303 11844 15276 37430 99330 77781 35069 64358 45168\n",
        "output": "586407 637558\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 186,
        "task_id": 226,
        "test_case_id": 34,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "26\n71393 24874 91299 30093 62947 14491 80214 41782 51025 19158 21666 23163 20547 64293 40653 24291 46922 92106 13294 77479 63079 25559 42579 62933 24433 39507\n",
        "output": "569885 599895\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 187,
        "task_id": 226,
        "test_case_id": 35,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "27\n54817 73719 96044 92275 12201 60564 84901 25770 17884 90636 14810 82907 20637 58023 10976 72208 94644 63856 11312 74424 26828 40632 58600 37316 38290 82420 48297\n",
        "output": "716531 728460\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 188,
        "task_id": 226,
        "test_case_id": 36,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "28\n70945 22563 76598 21753 4558 39341 48372 77054 52039 27522 75249 18459 96536 60264 5491 20125 42367 44118 42034 38665 47472 88410 66109 78995 52147 68436 9814 71112\n",
        "output": "669482 697066\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 189,
        "task_id": 226,
        "test_case_id": 37,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "29\n54369 14511 14048 83934 53812 75014 20356 17938 86195 31704 68393 78202 96626 86697 75814 746 46985 15868 40052 11417 11221 44700 40915 53378 98708 78644 4035 20164 37165\n",
        "output": "678299 683312\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 190,
        "task_id": 226,
        "test_case_id": 38,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "30\n4555 13594 57403 75796 14203 12847 66292 60885 9525 40478 57327 69970 15297 37483 39540 31102 14855 412 84174 57684 65591 19837 80431 18385 3107 87740 15433 24854 73472 88205\n",
        "output": "620095 620382\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 191,
        "task_id": 226,
        "test_case_id": 39,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "31\n20683 29734 37957 37978 63456 58920 70980 44873 76385 44661 17767 97009 15387 63916 77159 79019 86770 4866 14897 63141 86236 67614 87940 60064 16964 97948 9654 49714 30888 88075 63792\n",
        "output": "825663 838784\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 192,
        "task_id": 226,
        "test_case_id": 40,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "32\n71403 78578 75406 67455 12710 37697 67155 28861 10540 48843 10911 56753 15477 33453 4378 26936 34492 19720 12915 27382 49984 91200 95449 34448 63525 83964 3875 98767 77905 63753 83018 58084\n",
        "output": "770578 774459\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 193,
        "task_id": 226,
        "test_case_id": 41,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "33\n87531 27423 55960 53829 37771 40665 39138 12849 77399 53025 71350 83793 48271 59887 41997 74854 14919 24175 43637 24327 13733 38978 2959 319 10086 26876 65393 56332 68025 63623 93732 68354 83938\n",
        "output": "741185 823963\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 194,
        "task_id": 226,
        "test_case_id": 42,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "34\n70955 19371 60706 50603 54321 86738 11122 29541 11555 57207 31790 19344 24170 29424 36512 22771 86833 4437 41655 64376 34378 19459 86276 74702 23943 69789 59614 48489 49634 63494 12958 11328 69333 1736\n",
        "output": "693927 744637\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 195,
        "task_id": 226,
        "test_case_id": 43,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "35\n54379 920 41259 12784 3574 98219 40001 80825 45710 61390 24933 79088 24260 23153 6835 94880 67260 76187 39673 28616 98126 10341 26489 49085 37800 55805 86539 97542 39754 30660 32184 64703 11625 77872 63584\n",
        "output": "823487 862568\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 196,
        "task_id": 226,
        "test_case_id": 44,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "36\n37803 17060 78709 42262 28636 68484 79280 97517 12570 98276 52669 6128 57054 58098 68646 75501 39174 56449 3099 1369 94579 58119 1295 90764 51657 66013 48056 55107 54066 30530 75602 74973 21212 21304 22589 4895\n",
        "output": "872694 876851\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 197,
        "task_id": 226,
        "test_case_id": 45,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "37\n53932 65904 91967 4443 77890 47261 8160 81505 46725 69754 21621 65871 24440 51828 71673 23418 86896 4008 1117 65610 82519 5897 8804 65148 98218 76221 42277 79968 68379 30401 62125 61052 96207 64737 24698 99495 70720\n",
        "output": "989044 1011845\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 198,
        "task_id": 226,
        "test_case_id": 46,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "38\n70060 14749 72520 58113 2951 26037 80143 32789 80881 73936 82060 92911 24531 78261 9292 71335 91515 8462 31839 62555 46268 29482 92121 31019 12075 94942 36498 96317 58499 30271 81351 71322 81602 8169 26807 69903 38154 20539\n",
        "output": "977736 1012543\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 199,
        "task_id": 226,
        "test_case_id": 47,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "39\n20780 30889 9970 87591 19501 96302 76318 49481 47740 10823 42500 61167 57325 47798 36511 19252 39237 23316 29857 2603 10016 9964 99630 5402 82828 5150 98015 53882 72811 97437 57473 57400 91189 84305 85811 64503 40179 50614 52044\n",
        "output": "954593 973021\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 200,
        "task_id": 226,
        "test_case_id": 48,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "40\n3670 5779 20621 87964 12595 34136 98063 92429 38366 43789 88330 52934 19100 22776 43342 82312 74404 64756 73980 14278 21283 85101 63339 70409 63034 14245 33606 58571 84927 14931 25355 15452 46072 4671 5838 69121 18243 87783 29748 84047\n",
        "output": "909877 959523\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 201,
        "task_id": 226,
        "test_case_id": 49,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "41\n87094 21920 58071 41634 29145 45616 94239 76417 5226 47971 48770 79974 19190 25017 37857 30229 11726 12314 71998 54327 85032 8687 46656 12088 9595 24454 27827 7624 66535 14801 44581 25723 55659 48103 75242 39529 52973 17858 16985 41454 44182\n",
        "output": "799467 864856\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 202,
        "task_id": 226,
        "test_case_id": 50,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "42\n70518 70764 38625 3816 78399 48585 66222 60405 72085 52153 85018 39717 51984 51451 8180 78146 59448 16768 2720 51272 48780 56464 21461 86471 23452 10470 22048 65189 56655 90480 31103 11801 73758 91536 10055 34129 20407 47933 4223 98861 84475 52291\n",
        "output": "1012190 1036128\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 203,
        "task_id": 226,
        "test_case_id": 51,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "43\n86646 19609 43370 33293 3460 94658 95101 44393 6241 56335 78161 66757 52074 53692 2695 58767 31363 64326 738 15513 69425 4242 28971 60855 37309 53382 16269 57346 70968 90350 74522 22072 83345 67672 69060 4537 55137 78008 91461 32075 33280 70405 71607\n",
        "output": "1039942 1109548\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 204,
        "task_id": 226,
        "test_case_id": 52,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "44\n70070 68453 23924 95475 52714 73435 34380 61085 40396 60518 38601 26501 52165 47421 73018 6684 79085 68781 31460 88265 33173 52020 44992 2534 8062 96295 77786 39103 85280 24812 93748 75446 92932 11105 71169 66433 89866 75379 11402 22186 73572 31624 70092 10734\n",
        "output": "1141992 1210184\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 205,
        "task_id": 226,
        "test_case_id": 53,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "45\n53494 93105 37182 24953 1967 43700 39068 12369 7256 64700 31744 62052 84959 49662 34829 78793 51000 16339 29478 52506 96922 75606 52501 1109 21919 6503 72007 63964 75400 24682 45678 18420 67928 87241 73278 69545 24596 29646 65936 55401 89673 49738 35873 45189 3622\n",
        "output": "1052557 1068976\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 206,
        "task_id": 226,
        "test_case_id": 54,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "46\n36918 9246 74631 78622 94325 22476 35243 96357 41411 68882 92184 21796 28153 43392 37856 26710 64130 20793 60200 16747 84862 23383 60010 42788 68480 92519 66229 56121 57009 24553 89096 4499 53323 30673 75386 31442 92030 59721 53173 45511 29966 67853 77462 12347 61811 81517\n",
        "output": "1199490 1212346\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 207,
        "task_id": 226,
        "test_case_id": 55,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "47\n53046 58090 55185 8100 43578 1253 7226 13049 75567 73065 19920 48836 28243 45633 75475 74628 11853 68351 90922 89500 81315 71161 34816 49875 82337 2727 27746 37878 79833 24423 75618 82065 95614 82618 34391 1850 94056 57092 73115 70214 46067 29071 75947 46802 95807 42600 11211\n",
        "output": "1214201 1233568\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 208,
        "task_id": 226,
        "test_case_id": 56,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "48\n69174 6934 59931 70281 68640 47326 3402 64333 42426 77247 13063 8579 61038 39362 2694 22545 83767 15909 88940 86445 45063 27451 18133 91555 28898 45640 21967 62738 61441 24293 19036 68144 5201 26050 69204 29154 85681 19871 60352 36133 86359 47186 74432 5448 53996 27876 58022 80559\n",
        "output": "1096672 1115247\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 209,
        "task_id": 226,
        "test_case_id": 57,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "49\n19894 55779 73188 99759 17893 50295 8089 81025 76582 81429 73503 35619 61128 41603 40313 3166 31490 87660 19662 59197 8812 75229 25642 65938 42755 31656 16188 87599 51562 91460 38262 11118 90596 69482 71313 66858 87707 17242 14886 93539 35164 32596 83317 72606 12185 21664 80642 72099 7525\n",
        "output": "1233007 1259909\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 210,
        "task_id": 226,
        "test_case_id": 58,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "50\n70081 97965 40736 24325 2476 20832 54026 23972 91400 47099 95141 27386 79799 49285 4039 818 23552 72203 55273 38168 52783 50365 89351 30945 47154 8047 27586 49184 20573 8953 38849 36466 45479 89848 82827 71475 74283 87115 92590 28903 97800 74550 74140 82514 10849 6786 67881 63456 53022 25051\n",
        "output": "1251581 1255820\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 211,
        "task_id": 226,
        "test_case_id": 59,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "4\n10 3 2 1\n",
        "output": "4 12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 212,
        "task_id": 226,
        "test_case_id": 60,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "6\n5245 1414 21632 12159 31783 7412\n",
        "output": "38442 41203\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 213,
        "task_id": 226,
        "test_case_id": 61,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "46\n1666 17339 9205 20040 30266 12751 11329 7951 9000 14465 11771 7600 19480 15993 19453 7470 1361 7922 27747 17347 4727 11280 403 16338 6064 11124 25723 18717 26118 271 9242 16952 26381 31795 28226 3646 27589 31472 30108 28354 25281 22429 30956 32264 14729 21685\n",
        "output": "379808 392222\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 214,
        "task_id": 226,
        "test_case_id": 62,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "3\n100 90 80\n",
        "output": "90 180\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 215,
        "task_id": 226,
        "test_case_id": 63,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "5\n10 9 8 7 6\n",
        "output": "16 24\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 216,
        "task_id": 226,
        "test_case_id": 64,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "4\n100 40 50 10\n",
        "output": "50 150\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 217,
        "task_id": 226,
        "test_case_id": 65,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "6\n5 4 3 2 1 1\n",
        "output": "7 9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 218,
        "task_id": 226,
        "test_case_id": 66,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "33\n30274 12228 26670 31244 5457 2643 27275 4380 30954 23407 8387 6669 25229 31591 27518 30261 25670 20962 31316 8992 8324 26216 10812 28467 15401 23077 10311 24975 14046 12010 11406 22841 7593\n",
        "output": "299163 327443\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 219,
        "task_id": 226,
        "test_case_id": 67,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "3\n4 2 1\n",
        "output": "2 5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 220,
        "task_id": 226,
        "test_case_id": 68,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "3\n10 5 5\n",
        "output": "5 15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 221,
        "task_id": 226,
        "test_case_id": 69,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "6\n6 5 4 3 2 1\n",
        "output": "9 12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 222,
        "task_id": 226,
        "test_case_id": 70,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "4\n5 2 7 3\n",
        "output": "7 10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 223,
        "task_id": 329,
        "test_case_id": 11,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "ihimeitimrmhriemsjhrtjtijtesmhemnmmrsetmjttthtjhnnmirtimne\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 224,
        "task_id": 329,
        "test_case_id": 15,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "hsntijjetmehejtsitnthietssmeenjrhhetsnjrsethisjrtrhrierjtmimeenjnhnijeesjttrmn\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 225,
        "task_id": 329,
        "test_case_id": 17,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "neithjhhhtmejjnmieishethmtetthrienrhjmjenrmtejerernmthmsnrthhtrimmtmshm\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 226,
        "task_id": 329,
        "test_case_id": 22,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "tmnersmrtsehhntsietttrehrhneiireijnijjejmjhei\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 227,
        "task_id": 329,
        "test_case_id": 31,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "msjeshtthsieshejsjhsnhejsihisijsertenrshhrthjhiirijjneinjrtrmrs\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 228,
        "task_id": 329,
        "test_case_id": 33,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "mmmsermimjmrhrhejhrrejermsneheihhjemnehrhihesnjsehthjsmmjeiejmmnhinsemjrntrhrhsmjtttsrhjjmejj\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 229,
        "task_id": 329,
        "test_case_id": 53,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiiiiitttttttttttttttttttt\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 230,
        "task_id": 434,
        "test_case_id": 14,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "3\n999999999 -1 1000000000\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 231,
        "task_id": 438,
        "test_case_id": 2,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "9\n",
        "output": "3\n1 2 6 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 232,
        "task_id": 438,
        "test_case_id": 6,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "1000\n",
        "output": "44\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 54 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 233,
        "task_id": 438,
        "test_case_id": 7,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "4\n",
        "output": "2\n1 3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 234,
        "task_id": 438,
        "test_case_id": 8,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "6\n",
        "output": "3\n1 2 3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 235,
        "task_id": 438,
        "test_case_id": 10,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "8\n",
        "output": "3\n1 2 5 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 236,
        "task_id": 438,
        "test_case_id": 11,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "10\n",
        "output": "4\n1 2 3 4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 237,
        "task_id": 438,
        "test_case_id": 13,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "12\n",
        "output": "4\n1 2 3 6 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 238,
        "task_id": 438,
        "test_case_id": 15,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "14\n",
        "output": "4\n1 2 3 8 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 239,
        "task_id": 438,
        "test_case_id": 16,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "15\n",
        "output": "5\n1 2 3 4 5 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 240,
        "task_id": 438,
        "test_case_id": 17,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "16\n",
        "output": "5\n1 2 3 4 6 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 241,
        "task_id": 438,
        "test_case_id": 18,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "20\n",
        "output": "5\n1 2 3 4 10 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 242,
        "task_id": 438,
        "test_case_id": 19,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "21\n",
        "output": "6\n1 2 3 4 5 6 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 243,
        "task_id": 438,
        "test_case_id": 20,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "22\n",
        "output": "6\n1 2 3 4 5 7 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 244,
        "task_id": 438,
        "test_case_id": 21,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "27\n",
        "output": "6\n1 2 3 4 5 12 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 245,
        "task_id": 438,
        "test_case_id": 22,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "28\n",
        "output": "7\n1 2 3 4 5 6 7 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 246,
        "task_id": 438,
        "test_case_id": 24,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "35\n",
        "output": "7\n1 2 3 4 5 6 14 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 247,
        "task_id": 438,
        "test_case_id": 25,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "36\n",
        "output": "8\n1 2 3 4 5 6 7 8 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 248,
        "task_id": 438,
        "test_case_id": 27,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "44\n",
        "output": "8\n1 2 3 4 5 6 7 16 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 249,
        "task_id": 438,
        "test_case_id": 28,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "45\n",
        "output": "9\n1 2 3 4 5 6 7 8 9 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 250,
        "task_id": 438,
        "test_case_id": 29,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "46\n",
        "output": "9\n1 2 3 4 5 6 7 8 10 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 251,
        "task_id": 438,
        "test_case_id": 30,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "230\n",
        "output": "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 40 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 252,
        "task_id": 438,
        "test_case_id": 31,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "231\n",
        "output": "21\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 253,
        "task_id": 438,
        "test_case_id": 32,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "232\n",
        "output": "21\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 254,
        "task_id": 438,
        "test_case_id": 34,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "629\n",
        "output": "34\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 68 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 255,
        "task_id": 438,
        "test_case_id": 35,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "630\n",
        "output": "35\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 256,
        "task_id": 438,
        "test_case_id": 37,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "945\n",
        "output": "42\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 84 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 257,
        "task_id": 438,
        "test_case_id": 38,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "946\n",
        "output": "43\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 258,
        "task_id": 438,
        "test_case_id": 40,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "989\n",
        "output": "43\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 86 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 259,
        "task_id": 438,
        "test_case_id": 41,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "990\n",
        "output": "44\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 260,
        "task_id": 438,
        "test_case_id": 43,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "956\n",
        "output": "43\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 53 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 261,
        "task_id": 438,
        "test_case_id": 44,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "981\n",
        "output": "43\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 78 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 262,
        "task_id": 438,
        "test_case_id": 45,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "867\n",
        "output": "41\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 47 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 263,
        "task_id": 438,
        "test_case_id": 46,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "906\n",
        "output": "42\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 45 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 264,
        "task_id": 438,
        "test_case_id": 47,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "999\n",
        "output": "44\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 53 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 265,
        "task_id": 438,
        "test_case_id": 48,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "100\n",
        "output": "13\n1 2 3 4 5 6 7 8 9 10 11 12 22 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 266,
        "task_id": 438,
        "test_case_id": 49,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "126\n",
        "output": "15\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 21 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 267,
        "task_id": 471,
        "test_case_id": 2,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "2 0\n11 -10\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 268,
        "task_id": 471,
        "test_case_id": 11,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "18 8\n19 18 20 11 16 12 20 17 15 11 16 13 20 13 14 16 10 12\n",
        "output": "12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 269,
        "task_id": 471,
        "test_case_id": 12,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "26 3\n20 15 19 20 17 10 15 20 16 14 19 12 18 15 14 16 13 13 20 12 12 13 12 18 15 11\n",
        "output": "17\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 270,
        "task_id": 471,
        "test_case_id": 13,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "40 4\n10 13 15 17 13 12 16 20 14 17 11 11 18 12 18 19 19 16 13 13 12 15 14 12 10 15 16 11 13 12 12 15 10 17 13 10 12 19 14 15\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 271,
        "task_id": 471,
        "test_case_id": 14,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "44 4\n11 15 10 19 14 13 14 11 11 13 13 14 15 17 18 19 11 13 14 17 12 16 19 19 13 20 14 12 13 14 12 13 14 14 10 20 17 16 12 11 14 19 11 12\n",
        "output": "16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 272,
        "task_id": 471,
        "test_case_id": 15,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "51 5\n20 20 10 17 11 15 12 11 12 19 17 12 16 11 18 11 14 16 11 19 13 13 20 14 18 13 20 18 13 15 12 12 10 11 13 19 12 11 14 17 14 19 18 18 14 13 10 12 16 18 20\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 273,
        "task_id": 471,
        "test_case_id": 18,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "87 1\n16 10 11 15 11 16 16 16 16 14 14 12 14 10 18 10 18 13 18 11 11 19 13 11 19 17 14 20 10 12 16 15 18 16 19 13 10 19 10 15 11 17 13 16 13 15 13 10 12 13 20 10 18 19 11 20 14 14 12 14 17 10 15 11 17 13 16 19 12 10 14 15 20 10 17 14 19 11 20 10 17 15 20 12 10 14 14\n",
        "output": "19\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 274,
        "task_id": 471,
        "test_case_id": 19,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "91 25\n19 15 20 12 18 11 18 12 20 11 16 18 13 11 11 13 13 14 15 16 13 11 13 19 15 13 10 15 10 12 13 11 18 11 14 10 11 11 20 14 11 11 14 10 14 19 13 16 19 12 18 18 14 15 10 14 16 11 11 14 12 14 14 20 16 15 17 17 12 15 12 15 20 16 10 18 15 15 19 18 19 18 12 10 11 15 20 20 15 16 15\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 275,
        "task_id": 471,
        "test_case_id": 21,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "28 -20\n-11 -16 -16 -18 -15 -12 -18 -13 -19 -20 -19 -20 -18 -15 -18 -15 -11 -10 -20 -17 -15 -14 -16 -13 -10 -16 -20 -17\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 276,
        "task_id": 471,
        "test_case_id": 22,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "38 -29\n-13 -13 -10 -12 -13 -13 -13 -18 -18 -20 -19 -14 -17 -16 -19 -13 -10 -14 -19 -12 -16 -17 -11 -12 -12 -13 -18 -12 -11 -18 -15 -20 -20 -14 -13 -17 -12 -12\n",
        "output": "19\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 277,
        "task_id": 471,
        "test_case_id": 23,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "45 -21\n-19 -13 -10 -16 -15 -18 -18 -18 -13 -19 -19 -15 -17 -17 -16 -16 -11 -19 -20 -12 -17 -12 -16 -18 -10 -17 -12 -18 -15 -20 -10 -16 -20 -17 -11 -18 -20 -10 -19 -11 -16 -18 -15 -16 -18\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 278,
        "task_id": 471,
        "test_case_id": 24,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "59 -3\n-12 -15 -17 -12 -14 -13 -20 -15 -18 -19 -12 -16 -20 -17 -10 -15 -18 -12 -20 -20 -14 -15 -11 -13 -20 -19 -14 -16 -19 -15 -16 -12 -20 -12 -15 -16 -12 -19 -13 -16 -13 -17 -15 -13 -10 -13 -17 -17 -13 -13 -14 -12 -13 -18 -17 -18 -15 -14 -15\n",
        "output": "17\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 279,
        "task_id": 471,
        "test_case_id": 25,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "61 -27\n-14 -15 -11 -20 -13 -15 -14 -19 -17 -18 -16 -11 -16 -18 -11 -17 -13 -17 -13 -19 -15 -14 -14 -12 -19 -16 -13 -15 -13 -20 -18 -15 -17 -14 -13 -10 -20 -17 -10 -13 -16 -12 -11 -19 -15 -10 -13 -13 -15 -20 -13 -15 -18 -11 -13 -19 -13 -17 -11 -16 -12\n",
        "output": "17\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 280,
        "task_id": 471,
        "test_case_id": 26,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "76 -20\n-20 -12 -19 -13 -14 -19 -19 -19 -12 -17 -12 -16 -19 -19 -19 -16 -10 -18 -16 -19 -16 -10 -16 -11 -18 -13 -11 -10 -13 -11 -13 -10 -18 -20 -13 -15 -13 -19 -15 -18 -20 -10 -11 -20 -10 -11 -16 -17 -13 -12 -11 -14 -13 -16 -19 -13 -10 -11 -17 -19 -10 -10 -14 -13 -12 -15 -10 -10 -20 -20 -15 -14 -19 -18 -11 -17\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 281,
        "task_id": 471,
        "test_case_id": 27,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "89 -6\n-11 -12 -12 -20 -13 -14 -13 -13 -14 -12 -20 -20 -15 -20 -20 -19 -10 -19 -13 -15 -17 -20 -14 -19 -17 -18 -16 -19 -10 -13 -19 -10 -18 -12 -18 -13 -17 -17 -19 -18 -13 -20 -19 -10 -15 -15 -12 -20 -14 -20 -14 -17 -18 -13 -15 -14 -10 -14 -20 -13 -16 -10 -20 -18 -15 -15 -15 -16 -19 -13 -15 -18 -18 -11 -13 -19 -18 -20 -12 -13 -11 -14 -10 -10 -14 -15 -15 -12 -13\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 282,
        "task_id": 766,
        "test_case_id": 1,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ababa\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 283,
        "task_id": 766,
        "test_case_id": 2,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "zzcxx\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 284,
        "task_id": 766,
        "test_case_id": 3,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "yeee\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 285,
        "task_id": 766,
        "test_case_id": 4,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "a\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 286,
        "task_id": 766,
        "test_case_id": 5,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bbab\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 287,
        "task_id": 766,
        "test_case_id": 6,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abcd\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 288,
        "task_id": 766,
        "test_case_id": 7,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abc\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 289,
        "task_id": 766,
        "test_case_id": 8,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abcdaaaa\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 290,
        "task_id": 766,
        "test_case_id": 9,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aaaaaaaaaaaaaaa\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 291,
        "task_id": 766,
        "test_case_id": 10,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "adb\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 292,
        "task_id": 766,
        "test_case_id": 11,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "dcccbad\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 293,
        "task_id": 766,
        "test_case_id": 12,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bcbccccccca\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 294,
        "task_id": 766,
        "test_case_id": 13,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abcdefgh\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 295,
        "task_id": 766,
        "test_case_id": 14,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aabcdef\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 296,
        "task_id": 766,
        "test_case_id": 15,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aabc\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 297,
        "task_id": 766,
        "test_case_id": 16,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ssab\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 298,
        "task_id": 766,
        "test_case_id": 17,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ccdd\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 299,
        "task_id": 766,
        "test_case_id": 18,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abcc\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 300,
        "task_id": 766,
        "test_case_id": 19,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ab\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 301,
        "task_id": 766,
        "test_case_id": 20,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abcde\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 302,
        "task_id": 766,
        "test_case_id": 21,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aa\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 303,
        "task_id": 766,
        "test_case_id": 22,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aaabbb\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 304,
        "task_id": 766,
        "test_case_id": 23,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bbbba\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 305,
        "task_id": 766,
        "test_case_id": 24,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abbbc\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 306,
        "task_id": 766,
        "test_case_id": 25,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "baabaa\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 307,
        "task_id": 766,
        "test_case_id": 26,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abacabadde\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 308,
        "task_id": 766,
        "test_case_id": 27,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aabbcc\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 309,
        "task_id": 766,
        "test_case_id": 28,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abbc\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 310,
        "task_id": 766,
        "test_case_id": 29,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aaaaaaabbbbbbcder\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 311,
        "task_id": 766,
        "test_case_id": 30,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aabb\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 312,
        "task_id": 766,
        "test_case_id": 31,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aabbccddee\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 313,
        "task_id": 766,
        "test_case_id": 32,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "abca\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 314,
        "task_id": 766,
        "test_case_id": 33,
        "question": "Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.\n\nYou're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.\n\n\n-----Input-----\n\nThe only line contains s (1 ≤ |s| ≤ 10^5) consisting of lowercase latin letters.\n\n\n-----Output-----\n\nPrint «Yes» if the string can be split according to the criteria above or «No» otherwise.\n\nEach letter can be printed in arbitrary case.\n\n\n-----Examples-----\nInput\nababa\n\nOutput\nYes\n\nInput\nzzcxx\n\nOutput\nYes\n\nInput\nyeee\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.\n\nThere's no suitable partition in sample case three.",
        "solutions": "[\"s = input()\\nss = set(s)\\n\\nif len(s) >= 4:\\n    if len(ss) in (3, 4):\\n        print('Yes')\\n    elif len(ss) == 2:\\n        for c in ss:\\n            if s.count(c) == 1:\\n                print('No')\\n                break\\n        else:\\n            print('Yes')\\n    else:\\n        print('No')\\nelse:\\n    print('No')\", \"import getpass\\nimport sys\\nimport math\\nfrom decimal import Decimal\\nimport decimal\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nmp = {}\\nst = input()\\nfor i in st:\\n    mp[i] = 0\\nfor i in st:\\n    mp[i] += 1\\n\\nif len(mp) == 4:\\n    print('Yes')\\n    return\\n\\nif len(mp) == 1:\\n    print('No')\\n    return\\n\\nif len(mp) == 2:\\n    if min(mp.values()) >= 2:\\n        print('Yes')\\n        return\\n\\nif len(mp) == 3:\\n    if max(mp.values()) >= 2:\\n        print('Yes')\\n        return\\nprint('No')\\n\\n\", \"d = {}\\ns = input()\\nfor l in s:\\n    if l not in d:\\n        d[l] = 0\\n    d[l]+=1\\nif len(d) > 4:\\n    print('No')\\nelif len(d) == 3:\\n    if len(s) > 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(d) == 2:\\n    for k in d:\\n        if d[k] < 2:\\n            print('No')\\n            return\\n    print('Yes')\\nelif len(d)==4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"s = input()\\nl = list(set(s))\\nans = 1\\nif (len(l)>4) or (len(l)<=1):\\n    ans = 0\\nelse:\\n    if len(l)==2:\\n        c1=0\\n        c0=0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            else:\\n                c1+=1\\n        if (c1<2) or (c0<2):\\n            ans = 0\\n    if (len(l)==3):\\n        c1 = 0\\n        c2 = 0\\n        c0 = 0\\n        for i in range(len(s)):\\n            if s[i]==l[0]:\\n                c0+=1\\n            if s[i]==l[1]:\\n                c1+=1\\n            if s[i]==l[2]:\\n                c2+=1\\n        if (c1+c2+c0)<4:\\n            ans = 0\\nif (ans==0):\\n    print('No')\\nelse:\\n    print('Yes')\\n        \\n            \\n        \\n        \\n    \\n\\n    \\n\", \"s = input()\\nkol = 0\\nfor i in range(26):\\n    if chr(i + 97) in s:\\n        kol += 1\\ntmp = list(set(s))\\nif kol == 4:\\n    print('Yes')\\nelif kol == 3 and len(s) != 3:\\n    print('Yes')\\nelif kol == 2 and s.count(tmp[0]) != 1 and s.count(tmp[1]) != 1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"a=[0]*27\\nx=input()\\nfor i in x:\\n    a[ord(i)-96]+=1\\ns=0\\nq=0\\nfor i in a:\\n    if i!=0: s+=1\\n    if i>1: q+=1\\nif s>4:\\n    print('No')\\nelif s<=1:\\n    print('No')\\nelif s==4:\\n    print('Yes')\\nelif s==2:\\n    if q>=2:\\n        print('Yes')\\n    else: print('No')\\nelse:\\n    if q>=1:\\n        print('Yes')\\n    else: print('No')\", \"from collections import Counter\\n\\ncnt = Counter(input().strip())\\nvals = sorted(cnt.values())\\n\\nif len(vals) == 1 or len(vals) > 4:\\n    print(\\\"No\\\")\\nelif len(vals) == 2:\\n    a, b = vals\\n    if a == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 3:\\n    a, b, c = vals\\n    if c == 1:\\n        print(\\\"No\\\")\\n    else:\\n        print(\\\"Yes\\\")\\nelif len(vals) == 4:\\n    print(\\\"Yes\\\")\\nelse:\\n    raise RuntimeError(\\\"Should never happen\\\")\\n\", \"s = sorted(input())\\nt = 1\\nlets = []\\nfor i in range(1,len(s)):\\n    if s[i] == s[i-1]:\\n        t += 1\\n    else: \\n        lets.append(t)\\n        t = 1\\nlets.append(t)\\nsuc = False\\nif len(lets) == 2 and lets[0] > 1 and lets[1] > 1: suc = True\\nif len(lets) == 3 and max(lets) > 1: suc = True\\nif len(lets) == 4: suc = True\\nif suc: print('Yes')\\nelse: print('No')\\n\", \"s = input()\\nf=[0]*26\\na='a'\\nfor ele in s:\\n    f[ord(ele)-ord(a)]+=1 \\n\\nse = set(s)\\n\\nif len(se) == 1 or len(se)>4: \\n    print(\\\"No\\\")\\n    return\\nif len(se)==2:\\n    s = list(se)\\n    if f[ord(s[0])-ord(a)]>1 and f[ord(s[1])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif len(se)==3:\\n    if f[ord(s[0])-ord(a)]>1 or f[ord(s[1])-ord(a)]>1 or f[ord(s[2])-ord(a)]>1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nif(len(se))==4:\\n    print(\\\"Yes\\\")\", \"from collections import Counter\\n\\ns = input()\\nln = len(set(s))\\nC = Counter(s)\\n\\nif ln == 1 or ln > 4:\\n    print('No')\\n\\nelif ln == 2:\\n    print(('No', 'Yes')[min(C.values()) >= 2])\\n\\nelif ln == 3:\\n    print(('No', 'Yes')[max(C.values()) >= 2])\\n\\nelif ln == 4:\\n    print('Yes')\\n\\nelse:\\n    exit(100500)\\n\", \"from collections import defaultdict as dd, deque\\n\\nH = dd(int)\\n\\ns = input()\\n\\nfor c in s:\\n    H[c] += 1\\n\\nif len(H)==4 or (len(H)==3 and max(H.values())>1) or (len(H)==2 and min(H.values())>1):\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s = input()\\nd, m, l = dict(), set(), list()\\nfor i in s:\\n    try:\\n        d[i] += 1\\n    except:\\n        d[i] = 1\\n    m.add(i)\\nfor i in m:\\n    l.append(d[i])\\nif len(l) == 2:\\n    if min(l) >= 2:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 3:\\n    if l.count(1) != 3:\\n        print('Yes')\\n    else:\\n        print('No')\\nelif len(l) == 4:\\n    print('Yes')\\nelse:\\n    print('No')\", \"from collections import defaultdict\\ns = input()\\nm = defaultdict(int)\\nfor c in s:\\n    m[c] += 1\\n\\ncnts = [j for i,j in list(m.items())]\\n\\nif len(s) < 4 or len(cnts) > 4 or len(cnts) == 1 or (len(cnts) == 2 and min(cnts) == 1):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n\", \"s = input()\\na = [0]*26\\nfor i in s:\\n    a[ord(i)-97]+=1\\no = []\\nfor i in a:\\n    if i > 0:o.append(i)\\nif len(o)==0:\\n    print('No')\\nelif len(o)>= 5:print('No')\\nelif len(o)==1:print('No')\\nelif len(o) == 4:print('Yes')\\nelse:\\n    t = len(o)\\n    for i in o:\\n        if i > 1:t += 1\\n    if t >= 4:\\n        print('Yes')\\n    else:print('No')\\n\", \"s = dict()\\nfor symb in list(input()):\\n\\ts[symb] = s.get(symb, 0) + 1\\ncnt = 0\\nc = []\\nfor i in s.values():\\n\\tc.append(i)\\n\\tcnt += 1\\nif cnt == 4:\\n\\tprint('Yes')\\nelif cnt == 3:\\n\\tif c[0] > 1 or c[1] > 1 or c[2] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelif cnt == 2:\\n\\tif c[0] > 1 and c[1] > 1:\\n\\t\\tprint('Yes')\\n\\telse:\\n\\t\\tprint('No')\\nelse:\\n\\tprint('No')\", \"R=lambda:list(map(int,input().split()))\\n\\ns = str(input())\\n\\ndyn = [0] * 26\\napp = [False] * 26\\n\\nfor i in range(len(s)):\\n    dyn[ord(s[i]) - ord('a')] += 1\\n    app[ord(s[i]) - ord('a')] = True\\n    \\nt = sum(app)\\n\\nif t == 1 or t > 4: print('No')\\n\\nif t == 2:\\n    if 1 not in dyn: print('Yes')\\n    else: print('No')\\n    \\nif t == 3:\\n    if max(dyn) > 1: print('Yes')\\n    else: print('No')\\n    \\nif t == 4: print('Yes')\\n\", \"s = input()\\na = set()\\nfor i in s:\\n    a.add(i)\\na = list(a)\\nif len(a) == 4:\\n    print(\\\"Yes\\\")\\nelif len(a) == 2:\\n    if s.count(a[0]) > 1 and s.count(a[1]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelif len(a) == 3:\\n    if s.count(a[0]) > 1 or s.count(a[1]) > 1 or s.count(a[2]) > 1:\\n        print(\\\"Yes\\\")\\n    else:\\n        print(\\\"No\\\")\\nelse:\\n    print(\\\"No\\\")\", \"s = input()\\nletters = [0] * 26\\nif len(s) < 4:\\n    print('No')\\nelse:\\n    for i in range(len(s)):\\n        letters[ord(s[i]) - 97] += 1\\n    kolvo = 0\\n    for i in range(26):\\n        if letters[i] > 0:\\n            kolvo += 1\\n    if kolvo > 4:\\n        print('No')\\n    elif kolvo == 3:\\n        print('Yes')\\n    elif kolvo == 1:\\n        print('No')\\n    elif kolvo == 2:\\n        a = 0\\n        b = 0\\n        for i in range(len(letters)):\\n            if letters[i] != 0 and a == 0:\\n                a += letters[i]\\n            elif letters[i] != 0 and a != 0:\\n                b += letters[i]\\n        if a != 1 and b != 1:\\n            print('Yes')\\n        else:\\n            print('No')\\n    elif kolvo == 4:\\n        print('Yes')\", \"#codeforces_955B_live\\nsi = [ e for e in input()]\\ntest = len(set(si)) \\nif test > 4 or test == 1:\\n\\tprint(\\\"No\\\")\\nelif test == 2:\\n\\tsi.sort()\\n\\tif si.count(si[0]) == 1 or si.count(si[-1]) == 1 :\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelif test == 3:\\n\\tsi.sort()\\n\\tif len(si) == 3:\\n\\t\\tprint(\\\"No\\\")\\n\\telse:\\n\\t\\tprint(\\\"Yes\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\", \"s = list(input())\\ns.sort()\\nif len(s) < 4:\\n    print(\\\"No\\\")\\nelse:\\n    st = set(s)\\n    if len(st) > 4:\\n        print(\\\"No\\\")\\n    elif len(st) < 2:\\n        print(\\\"No\\\")\\n    elif len(st) == 2:\\n        c1 = s.count(s[0])\\n        c2 = s.count(s[-1])\\n        if c1 < 2 or c2 < 2:\\n            print(\\\"No\\\")\\n        else:\\n            print(\\\"Yes\\\")\\n    else:\\n        print(\\\"Yes\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aaabbbccc\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/955/B"
    },
    {
        "id": 315,
        "task_id": 1237,
        "test_case_id": 7,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "100 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 316,
        "task_id": 1512,
        "test_case_id": 2,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "5\n5 1 2 3 4\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 317,
        "task_id": 1512,
        "test_case_id": 4,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "9\n9 5 8 6 3 2 4 1 7\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 318,
        "task_id": 1512,
        "test_case_id": 6,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "7\n1 6 7 4 2 5 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 319,
        "task_id": 1512,
        "test_case_id": 7,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "48\n38 6 31 19 45 28 27 43 11 35 36 20 9 16 42 48 14 22 39 18 12 10 34 25 13 26 40 29 17 8 33 46 24 30 37 44 1 15 2 21 3 5 4 47 32 23 41 7\n",
        "output": "38\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 320,
        "task_id": 1512,
        "test_case_id": 8,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "26\n23 14 15 19 9 22 20 12 5 4 21 1 16 8 6 11 3 17 2 10 24 26 13 18 25 7\n",
        "output": "23\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 321,
        "task_id": 1512,
        "test_case_id": 9,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "46\n32 25 11 1 3 10 8 12 18 42 28 16 35 30 41 38 43 4 13 23 6 17 36 34 39 22 26 14 45 20 33 44 21 7 15 5 40 46 2 29 37 9 31 19 27 24\n",
        "output": "42\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 322,
        "task_id": 1512,
        "test_case_id": 11,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "57\n40 11 43 39 13 29 18 57 54 48 17 4 22 5 38 15 36 53 33 3 51 41 30 9 26 10 55 27 35 56 23 20 1 8 12 46 21 28 6 19 34 2 45 31 49 42 50 16 44 7 25 52 14 32 47 37 24\n",
        "output": "57\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 323,
        "task_id": 1512,
        "test_case_id": 12,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "85\n82 72 24 38 81 18 49 62 37 28 41 57 10 55 83 67 56 2 73 44 26 85 78 14 27 40 51 61 54 29 16 25 5 31 71 42 21 30 3 74 6 63 76 33 39 68 66 23 53 20 22 43 45 52 80 60 1 59 50 58 12 77 65 36 15 19 46 17 79 9 47 8 70 75 34 7 69 32 4 84 64 35 11 13 48\n",
        "output": "82\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 324,
        "task_id": 1512,
        "test_case_id": 14,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "87\n66 53 79 35 24 61 22 70 29 43 6 21 75 4 85 2 37 18 65 49 40 82 58 73 33 87 71 19 34 83 84 25 56 48 9 63 38 20 67 32 74 42 51 39 11 1 78 86 44 64 81 17 62 72 47 54 52 23 7 5 41 46 3 28 77 57 13 15 59 68 14 36 50 27 80 31 26 10 55 60 69 76 16 12 8 45 30\n",
        "output": "79\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 325,
        "task_id": 1940,
        "test_case_id": 1,
        "question": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each pocket at the same time. There are n different pebble types in the park, and there are w_{i} pebbles of the i-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.\n\nHelp her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.\n\nThe second line contains n integers w_1, w_2, ..., w_{n} (1 ≤ w_{i} ≤ 10^4) — number of pebbles of each type. \n\n\n-----Output-----\n\nThe only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.\n\n\n-----Examples-----\nInput\n3 2\n2 3 4\n\nOutput\n3\n\nInput\n5 4\n3 1 8 9 7\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.\n\nOptimal sequence of actions in the second sample case:   In the first day Anastasia collects 8 pebbles of the third type.  In the second day she collects 8 pebbles of the fourth type.  In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.  In the fourth day she collects 7 pebbles of the fifth type.  In the fifth day she collects 1 pebble of the second type.",
        "solutions": "[\"n, k = [int(i) for i in input().split()]\\n\\nw = [int(i) for i in input().split()]\\n\\ntot = 0\\nfor wi in w:\\n    tot += (wi+k-1)//k\\n\\nans = (tot+1)//2\\nprint(ans)\\n\", \"n,k=[int(i) for i in input().split()]\\na=[int(i) for i in input().split()]\\nx=0\\nfor i in range(n):\\n    x+=(a[i]+k-1)//k\\nprint((x+1)//2)\", \"N, K = list(map(int, input().split()))\\nW = [int(x) for x in input().split()]\\nans = 0\\nfor w in W:\\n    if w % K == 0:\\n        ans += w // K\\n    else:\\n        ans += w // K + 1\\nif ans % 2 == 0:\\n    print(ans // 2)\\nelse:\\n    print(ans // 2 + 1)\\n\", \"from sys import stdin\\nimport math\\n\\nN, K = list(map(int, stdin.readline().split()))\\npebbles = list(map(int, stdin.readline().split()))\\n\\nprint(math.ceil(sum(math.ceil(p / K) for p in pebbles) / 2))\\n\", \"n, k = map(int, input().split())\\narray = list(map(int, input().split()))\\nans = 0\\nfor i in range (n):\\n    ans += (array[i] + k - 1) // k\\nprint((ans + 1) // 2)\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\nres = 0\\nfor i in a:\\n    res += (i+k-1) // k\\n\\nprint((res+1)//2)\", \"from sys import stdin, stdout\\n\\n\\nn, k = list(map(int, stdin.readline().rstrip().split()))\\n\\npebbleList = [int(a) for a in stdin.readline().rstrip().split()]\\n\\nnTrips=[]\\nfor i in range(n):\\n    nTrips.append(pebbleList[i]//k)\\n    if pebbleList[i]%k!=0:\\n        nTrips[i]+=1\\n\\ntotal = sum(nTrips)//2 + sum(nTrips)%2\\nprint(total)\\n\", \"\\n\\nn, k = list(map(int, input().split()))\\n\\nws = list(int(x) for x in input().split())\\n\\nresult = 0\\nfree_pocket = False\\n\\n\\nfor w in ws:\\n    needed_pockets = (w + k - 1) // k\\n    if needed_pockets % 2 == 0:\\n        result += needed_pockets // 2\\n    else:\\n        if free_pocket:\\n            result += (needed_pockets - 1) // 2\\n        else:\\n            result += (needed_pockets + 1) // 2\\n        free_pocket = not free_pocket\\n\\nprint(result)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nans = 0\\nfor i in range(n):\\n    ans += (a[i] - 1) // k + 1\\n    \\nprint((ans - 1) // 2 + 1)\", \"import sys\\nn,k = list(map(int, input().split()))\\nw = list(map(int, input().split()))\\nrem = 0\\nans = 0\\nfor i in range(n):\\n    \\n    if w[i] % k != 0:\\n        rem +=1\\n    ans += w[i] // k;\\nres = 0\\nres += ans// 2\\nif ans % 2 != 0:\\n    rem += 1\\nres += rem // 2\\nif rem % 2 != 0:\\n    res += 1\\nprint(res)\\n\", \"n,k=map(int,input().split())\\nip=list(map(int,input().split()))\\ncount=0\\nfor i in ip:\\n    if i%k==0:\\n        count+=i//k\\n    else:\\n        count+=(i//k)+1\\nif count %2==0:\\n    print(count//2)\\nelse:\\n    print(count//2 + 1)\", \"import math\\nn,k=list(map(int,input().split()))\\nw=[int(i) for i in input().split()]\\nres=[]\\nfor i in range(n):\\n    res.append(w[i]//k)\\n    res.append(bool(w[i]%k))\\nprint(math.ceil(sum(res)/2))\\n\", \"n, k = map(int, input().split())\\ndays = 0\\nw = list(map(int, input().split()))\\nfor wi in w:\\n    days += (wi - 1) // k + 1\\nprint((days - 1) // 2 + 1)\", \"n,k=map(int,input().split())\\nl=sorted(map(int,input().split()))\\nans=0\\nfor i in range(n):\\n    ans+=-(-l[i]//k)\\nprint(-(-ans//2))\", \"n,k=map(int,input().split())\\nl=[int(i) for i in input().split()]\\nans=[]\\nfor i in l:\\n    ans.append((i+k-1)//k)\\nprint((sum(ans)+1)//2)\", \"#!/usr/bin/env python3\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\nn, k = ri()\\n\\nw = list(ri())\\n\\nans = 0\\nfor ww in w:\\n    if ww % k == 0:\\n        ans += ww//k\\n    else:\\n        ans += ww//k + 1\\n\\nif ans%2:\\n    print(ans//2+1)\\nelse:\\n    print(ans//2)\\n\\nprint()\\n\\n\", \"n,k=map(int,input().split())\\nd=0\\nt = sum(((i-1)//k + 1) for i in map(int,input().split()))\\nprint((t-1)//2 + 1)\", \"from math import *\\nn,k = list(map(int,input().split()))\\n*m,=list(map(int,input().split()))\\nd=0.0\\nfor i in m:\\n    d+=ceil(i/k)\\nprint(ceil(d/2))\\n\", \"n, k = [int(i) for i in input().split()]\\nw = [int(i) for i in input().split()]\\nw.sort()\\nm = 0\\nfor i in w:\\n    m += (i + k - 1) // k\\n\\nprint((m + 1) // 2)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\n\\npeb = list(map(int, input().split()))\\n\\nd = 0\\n\\nfor p in peb:\\n    d += ceil(p / s)\\n\\nprint(ceil(d/2))\\n\", \"def R():\\n    return [int(x) for x in input().split()]\\n\\ndef __starting_point():\\n    n, k = R()\\n    w = R()\\n    result = 0\\n    for _w in w:\\n        if _w < k:\\n            result += 1\\n        elif _w % k == 0:\\n            result += _w // k\\n        else:\\n            result += _w // k + 1\\n\\n    if result % 2 == 0:\\n        print(result // 2)\\n    else: \\n        print(result // 2 + 1)\\n\\n__starting_point()\", \"from collections import deque\\nfrom sys import stdin\\nfrom math import ceil\\nlines = deque(line.strip() for line in stdin.readlines())\\n\\ndef nextline():\\n    return lines.popleft()\\n\\ndef types(cast):\\n    return tuple(int(x) for x in nextline().split())\\n\\ndef ints():\\n    return types(int)\\n\\ndef strs():\\n    return nextline().split()\\n\\ndef main():\\n    # lines will now contain all of the input's lines in a list\\n    n, k = ints()\\n    ws = ints()\\n    count = ceil(sum(ceil(x/k) for x in ws)/2)\\n    print(count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport math\\n\\nfin = sys.stdin\\nfout = sys.stdout\\nn, k = list(map(int, fin.readline().split()))\\na = list(map(int, fin.readline().split()))\\nans = 0\\ni = 0\\nwhile i < n:\\n    ans += math.ceil(a[i] / k)\\n    i += 1\\nfout.write(str(math.ceil(ans / 2)))\\n\", \"import math\\nn,k=list(map(int,input().split()))\\nline=list(map(int,input().split()))\\ncnt=0\\nfor x in line:\\n\\tcnt+=math.ceil(x/k)\\nprint(math.ceil(cnt/2))\\n\", \"n, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ncounterS = 0\\ncounterL = 0\\n\\nfor i in arr:\\n    if i <= k:\\n        counterS += 1\\n    else:\\n        if i <= 2 * k:\\n            counterL += 1\\n        else:\\n            counterL += (i // (2 * k))\\n            y = i - (i // (2 * k))*(2*k)\\n            if y <= k:\\n                if y != 0:\\n                    counterS += 1\\n            else:\\n                counterL += 1\\nlastCounter = (counterS // 2) + (counterS % 2) + counterL\\nprint(lastCounter)\\n\"]",
        "difficulty": "interview",
        "input": "3 2\n2 3 4\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/789/A"
    },
    {
        "id": 326,
        "task_id": 1940,
        "test_case_id": 2,
        "question": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each pocket at the same time. There are n different pebble types in the park, and there are w_{i} pebbles of the i-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.\n\nHelp her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.\n\nThe second line contains n integers w_1, w_2, ..., w_{n} (1 ≤ w_{i} ≤ 10^4) — number of pebbles of each type. \n\n\n-----Output-----\n\nThe only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.\n\n\n-----Examples-----\nInput\n3 2\n2 3 4\n\nOutput\n3\n\nInput\n5 4\n3 1 8 9 7\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.\n\nOptimal sequence of actions in the second sample case:   In the first day Anastasia collects 8 pebbles of the third type.  In the second day she collects 8 pebbles of the fourth type.  In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.  In the fourth day she collects 7 pebbles of the fifth type.  In the fifth day she collects 1 pebble of the second type.",
        "solutions": "[\"n, k = [int(i) for i in input().split()]\\n\\nw = [int(i) for i in input().split()]\\n\\ntot = 0\\nfor wi in w:\\n    tot += (wi+k-1)//k\\n\\nans = (tot+1)//2\\nprint(ans)\\n\", \"n,k=[int(i) for i in input().split()]\\na=[int(i) for i in input().split()]\\nx=0\\nfor i in range(n):\\n    x+=(a[i]+k-1)//k\\nprint((x+1)//2)\", \"N, K = list(map(int, input().split()))\\nW = [int(x) for x in input().split()]\\nans = 0\\nfor w in W:\\n    if w % K == 0:\\n        ans += w // K\\n    else:\\n        ans += w // K + 1\\nif ans % 2 == 0:\\n    print(ans // 2)\\nelse:\\n    print(ans // 2 + 1)\\n\", \"from sys import stdin\\nimport math\\n\\nN, K = list(map(int, stdin.readline().split()))\\npebbles = list(map(int, stdin.readline().split()))\\n\\nprint(math.ceil(sum(math.ceil(p / K) for p in pebbles) / 2))\\n\", \"n, k = map(int, input().split())\\narray = list(map(int, input().split()))\\nans = 0\\nfor i in range (n):\\n    ans += (array[i] + k - 1) // k\\nprint((ans + 1) // 2)\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\nres = 0\\nfor i in a:\\n    res += (i+k-1) // k\\n\\nprint((res+1)//2)\", \"from sys import stdin, stdout\\n\\n\\nn, k = list(map(int, stdin.readline().rstrip().split()))\\n\\npebbleList = [int(a) for a in stdin.readline().rstrip().split()]\\n\\nnTrips=[]\\nfor i in range(n):\\n    nTrips.append(pebbleList[i]//k)\\n    if pebbleList[i]%k!=0:\\n        nTrips[i]+=1\\n\\ntotal = sum(nTrips)//2 + sum(nTrips)%2\\nprint(total)\\n\", \"\\n\\nn, k = list(map(int, input().split()))\\n\\nws = list(int(x) for x in input().split())\\n\\nresult = 0\\nfree_pocket = False\\n\\n\\nfor w in ws:\\n    needed_pockets = (w + k - 1) // k\\n    if needed_pockets % 2 == 0:\\n        result += needed_pockets // 2\\n    else:\\n        if free_pocket:\\n            result += (needed_pockets - 1) // 2\\n        else:\\n            result += (needed_pockets + 1) // 2\\n        free_pocket = not free_pocket\\n\\nprint(result)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nans = 0\\nfor i in range(n):\\n    ans += (a[i] - 1) // k + 1\\n    \\nprint((ans - 1) // 2 + 1)\", \"import sys\\nn,k = list(map(int, input().split()))\\nw = list(map(int, input().split()))\\nrem = 0\\nans = 0\\nfor i in range(n):\\n    \\n    if w[i] % k != 0:\\n        rem +=1\\n    ans += w[i] // k;\\nres = 0\\nres += ans// 2\\nif ans % 2 != 0:\\n    rem += 1\\nres += rem // 2\\nif rem % 2 != 0:\\n    res += 1\\nprint(res)\\n\", \"n,k=map(int,input().split())\\nip=list(map(int,input().split()))\\ncount=0\\nfor i in ip:\\n    if i%k==0:\\n        count+=i//k\\n    else:\\n        count+=(i//k)+1\\nif count %2==0:\\n    print(count//2)\\nelse:\\n    print(count//2 + 1)\", \"import math\\nn,k=list(map(int,input().split()))\\nw=[int(i) for i in input().split()]\\nres=[]\\nfor i in range(n):\\n    res.append(w[i]//k)\\n    res.append(bool(w[i]%k))\\nprint(math.ceil(sum(res)/2))\\n\", \"n, k = map(int, input().split())\\ndays = 0\\nw = list(map(int, input().split()))\\nfor wi in w:\\n    days += (wi - 1) // k + 1\\nprint((days - 1) // 2 + 1)\", \"n,k=map(int,input().split())\\nl=sorted(map(int,input().split()))\\nans=0\\nfor i in range(n):\\n    ans+=-(-l[i]//k)\\nprint(-(-ans//2))\", \"n,k=map(int,input().split())\\nl=[int(i) for i in input().split()]\\nans=[]\\nfor i in l:\\n    ans.append((i+k-1)//k)\\nprint((sum(ans)+1)//2)\", \"#!/usr/bin/env python3\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\nn, k = ri()\\n\\nw = list(ri())\\n\\nans = 0\\nfor ww in w:\\n    if ww % k == 0:\\n        ans += ww//k\\n    else:\\n        ans += ww//k + 1\\n\\nif ans%2:\\n    print(ans//2+1)\\nelse:\\n    print(ans//2)\\n\\nprint()\\n\\n\", \"n,k=map(int,input().split())\\nd=0\\nt = sum(((i-1)//k + 1) for i in map(int,input().split()))\\nprint((t-1)//2 + 1)\", \"from math import *\\nn,k = list(map(int,input().split()))\\n*m,=list(map(int,input().split()))\\nd=0.0\\nfor i in m:\\n    d+=ceil(i/k)\\nprint(ceil(d/2))\\n\", \"n, k = [int(i) for i in input().split()]\\nw = [int(i) for i in input().split()]\\nw.sort()\\nm = 0\\nfor i in w:\\n    m += (i + k - 1) // k\\n\\nprint((m + 1) // 2)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\n\\npeb = list(map(int, input().split()))\\n\\nd = 0\\n\\nfor p in peb:\\n    d += ceil(p / s)\\n\\nprint(ceil(d/2))\\n\", \"def R():\\n    return [int(x) for x in input().split()]\\n\\ndef __starting_point():\\n    n, k = R()\\n    w = R()\\n    result = 0\\n    for _w in w:\\n        if _w < k:\\n            result += 1\\n        elif _w % k == 0:\\n            result += _w // k\\n        else:\\n            result += _w // k + 1\\n\\n    if result % 2 == 0:\\n        print(result // 2)\\n    else: \\n        print(result // 2 + 1)\\n\\n__starting_point()\", \"from collections import deque\\nfrom sys import stdin\\nfrom math import ceil\\nlines = deque(line.strip() for line in stdin.readlines())\\n\\ndef nextline():\\n    return lines.popleft()\\n\\ndef types(cast):\\n    return tuple(int(x) for x in nextline().split())\\n\\ndef ints():\\n    return types(int)\\n\\ndef strs():\\n    return nextline().split()\\n\\ndef main():\\n    # lines will now contain all of the input's lines in a list\\n    n, k = ints()\\n    ws = ints()\\n    count = ceil(sum(ceil(x/k) for x in ws)/2)\\n    print(count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport math\\n\\nfin = sys.stdin\\nfout = sys.stdout\\nn, k = list(map(int, fin.readline().split()))\\na = list(map(int, fin.readline().split()))\\nans = 0\\ni = 0\\nwhile i < n:\\n    ans += math.ceil(a[i] / k)\\n    i += 1\\nfout.write(str(math.ceil(ans / 2)))\\n\", \"import math\\nn,k=list(map(int,input().split()))\\nline=list(map(int,input().split()))\\ncnt=0\\nfor x in line:\\n\\tcnt+=math.ceil(x/k)\\nprint(math.ceil(cnt/2))\\n\", \"n, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ncounterS = 0\\ncounterL = 0\\n\\nfor i in arr:\\n    if i <= k:\\n        counterS += 1\\n    else:\\n        if i <= 2 * k:\\n            counterL += 1\\n        else:\\n            counterL += (i // (2 * k))\\n            y = i - (i // (2 * k))*(2*k)\\n            if y <= k:\\n                if y != 0:\\n                    counterS += 1\\n            else:\\n                counterL += 1\\nlastCounter = (counterS // 2) + (counterS % 2) + counterL\\nprint(lastCounter)\\n\"]",
        "difficulty": "interview",
        "input": "5 4\n3 1 8 9 7\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/789/A"
    },
    {
        "id": 327,
        "task_id": 1940,
        "test_case_id": 4,
        "question": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each pocket at the same time. There are n different pebble types in the park, and there are w_{i} pebbles of the i-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.\n\nHelp her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.\n\nThe second line contains n integers w_1, w_2, ..., w_{n} (1 ≤ w_{i} ≤ 10^4) — number of pebbles of each type. \n\n\n-----Output-----\n\nThe only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.\n\n\n-----Examples-----\nInput\n3 2\n2 3 4\n\nOutput\n3\n\nInput\n5 4\n3 1 8 9 7\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.\n\nOptimal sequence of actions in the second sample case:   In the first day Anastasia collects 8 pebbles of the third type.  In the second day she collects 8 pebbles of the fourth type.  In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.  In the fourth day she collects 7 pebbles of the fifth type.  In the fifth day she collects 1 pebble of the second type.",
        "solutions": "[\"n, k = [int(i) for i in input().split()]\\n\\nw = [int(i) for i in input().split()]\\n\\ntot = 0\\nfor wi in w:\\n    tot += (wi+k-1)//k\\n\\nans = (tot+1)//2\\nprint(ans)\\n\", \"n,k=[int(i) for i in input().split()]\\na=[int(i) for i in input().split()]\\nx=0\\nfor i in range(n):\\n    x+=(a[i]+k-1)//k\\nprint((x+1)//2)\", \"N, K = list(map(int, input().split()))\\nW = [int(x) for x in input().split()]\\nans = 0\\nfor w in W:\\n    if w % K == 0:\\n        ans += w // K\\n    else:\\n        ans += w // K + 1\\nif ans % 2 == 0:\\n    print(ans // 2)\\nelse:\\n    print(ans // 2 + 1)\\n\", \"from sys import stdin\\nimport math\\n\\nN, K = list(map(int, stdin.readline().split()))\\npebbles = list(map(int, stdin.readline().split()))\\n\\nprint(math.ceil(sum(math.ceil(p / K) for p in pebbles) / 2))\\n\", \"n, k = map(int, input().split())\\narray = list(map(int, input().split()))\\nans = 0\\nfor i in range (n):\\n    ans += (array[i] + k - 1) // k\\nprint((ans + 1) // 2)\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\nres = 0\\nfor i in a:\\n    res += (i+k-1) // k\\n\\nprint((res+1)//2)\", \"from sys import stdin, stdout\\n\\n\\nn, k = list(map(int, stdin.readline().rstrip().split()))\\n\\npebbleList = [int(a) for a in stdin.readline().rstrip().split()]\\n\\nnTrips=[]\\nfor i in range(n):\\n    nTrips.append(pebbleList[i]//k)\\n    if pebbleList[i]%k!=0:\\n        nTrips[i]+=1\\n\\ntotal = sum(nTrips)//2 + sum(nTrips)%2\\nprint(total)\\n\", \"\\n\\nn, k = list(map(int, input().split()))\\n\\nws = list(int(x) for x in input().split())\\n\\nresult = 0\\nfree_pocket = False\\n\\n\\nfor w in ws:\\n    needed_pockets = (w + k - 1) // k\\n    if needed_pockets % 2 == 0:\\n        result += needed_pockets // 2\\n    else:\\n        if free_pocket:\\n            result += (needed_pockets - 1) // 2\\n        else:\\n            result += (needed_pockets + 1) // 2\\n        free_pocket = not free_pocket\\n\\nprint(result)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nans = 0\\nfor i in range(n):\\n    ans += (a[i] - 1) // k + 1\\n    \\nprint((ans - 1) // 2 + 1)\", \"import sys\\nn,k = list(map(int, input().split()))\\nw = list(map(int, input().split()))\\nrem = 0\\nans = 0\\nfor i in range(n):\\n    \\n    if w[i] % k != 0:\\n        rem +=1\\n    ans += w[i] // k;\\nres = 0\\nres += ans// 2\\nif ans % 2 != 0:\\n    rem += 1\\nres += rem // 2\\nif rem % 2 != 0:\\n    res += 1\\nprint(res)\\n\", \"n,k=map(int,input().split())\\nip=list(map(int,input().split()))\\ncount=0\\nfor i in ip:\\n    if i%k==0:\\n        count+=i//k\\n    else:\\n        count+=(i//k)+1\\nif count %2==0:\\n    print(count//2)\\nelse:\\n    print(count//2 + 1)\", \"import math\\nn,k=list(map(int,input().split()))\\nw=[int(i) for i in input().split()]\\nres=[]\\nfor i in range(n):\\n    res.append(w[i]//k)\\n    res.append(bool(w[i]%k))\\nprint(math.ceil(sum(res)/2))\\n\", \"n, k = map(int, input().split())\\ndays = 0\\nw = list(map(int, input().split()))\\nfor wi in w:\\n    days += (wi - 1) // k + 1\\nprint((days - 1) // 2 + 1)\", \"n,k=map(int,input().split())\\nl=sorted(map(int,input().split()))\\nans=0\\nfor i in range(n):\\n    ans+=-(-l[i]//k)\\nprint(-(-ans//2))\", \"n,k=map(int,input().split())\\nl=[int(i) for i in input().split()]\\nans=[]\\nfor i in l:\\n    ans.append((i+k-1)//k)\\nprint((sum(ans)+1)//2)\", \"#!/usr/bin/env python3\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\nn, k = ri()\\n\\nw = list(ri())\\n\\nans = 0\\nfor ww in w:\\n    if ww % k == 0:\\n        ans += ww//k\\n    else:\\n        ans += ww//k + 1\\n\\nif ans%2:\\n    print(ans//2+1)\\nelse:\\n    print(ans//2)\\n\\nprint()\\n\\n\", \"n,k=map(int,input().split())\\nd=0\\nt = sum(((i-1)//k + 1) for i in map(int,input().split()))\\nprint((t-1)//2 + 1)\", \"from math import *\\nn,k = list(map(int,input().split()))\\n*m,=list(map(int,input().split()))\\nd=0.0\\nfor i in m:\\n    d+=ceil(i/k)\\nprint(ceil(d/2))\\n\", \"n, k = [int(i) for i in input().split()]\\nw = [int(i) for i in input().split()]\\nw.sort()\\nm = 0\\nfor i in w:\\n    m += (i + k - 1) // k\\n\\nprint((m + 1) // 2)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\n\\npeb = list(map(int, input().split()))\\n\\nd = 0\\n\\nfor p in peb:\\n    d += ceil(p / s)\\n\\nprint(ceil(d/2))\\n\", \"def R():\\n    return [int(x) for x in input().split()]\\n\\ndef __starting_point():\\n    n, k = R()\\n    w = R()\\n    result = 0\\n    for _w in w:\\n        if _w < k:\\n            result += 1\\n        elif _w % k == 0:\\n            result += _w // k\\n        else:\\n            result += _w // k + 1\\n\\n    if result % 2 == 0:\\n        print(result // 2)\\n    else: \\n        print(result // 2 + 1)\\n\\n__starting_point()\", \"from collections import deque\\nfrom sys import stdin\\nfrom math import ceil\\nlines = deque(line.strip() for line in stdin.readlines())\\n\\ndef nextline():\\n    return lines.popleft()\\n\\ndef types(cast):\\n    return tuple(int(x) for x in nextline().split())\\n\\ndef ints():\\n    return types(int)\\n\\ndef strs():\\n    return nextline().split()\\n\\ndef main():\\n    # lines will now contain all of the input's lines in a list\\n    n, k = ints()\\n    ws = ints()\\n    count = ceil(sum(ceil(x/k) for x in ws)/2)\\n    print(count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport math\\n\\nfin = sys.stdin\\nfout = sys.stdout\\nn, k = list(map(int, fin.readline().split()))\\na = list(map(int, fin.readline().split()))\\nans = 0\\ni = 0\\nwhile i < n:\\n    ans += math.ceil(a[i] / k)\\n    i += 1\\nfout.write(str(math.ceil(ans / 2)))\\n\", \"import math\\nn,k=list(map(int,input().split()))\\nline=list(map(int,input().split()))\\ncnt=0\\nfor x in line:\\n\\tcnt+=math.ceil(x/k)\\nprint(math.ceil(cnt/2))\\n\", \"n, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ncounterS = 0\\ncounterL = 0\\n\\nfor i in arr:\\n    if i <= k:\\n        counterS += 1\\n    else:\\n        if i <= 2 * k:\\n            counterL += 1\\n        else:\\n            counterL += (i // (2 * k))\\n            y = i - (i // (2 * k))*(2*k)\\n            if y <= k:\\n                if y != 0:\\n                    counterS += 1\\n            else:\\n                counterL += 1\\nlastCounter = (counterS // 2) + (counterS % 2) + counterL\\nprint(lastCounter)\\n\"]",
        "difficulty": "interview",
        "input": "3 57\n78 165 54\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/789/A"
    },
    {
        "id": 328,
        "task_id": 1940,
        "test_case_id": 5,
        "question": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each pocket at the same time. There are n different pebble types in the park, and there are w_{i} pebbles of the i-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.\n\nHelp her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.\n\nThe second line contains n integers w_1, w_2, ..., w_{n} (1 ≤ w_{i} ≤ 10^4) — number of pebbles of each type. \n\n\n-----Output-----\n\nThe only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.\n\n\n-----Examples-----\nInput\n3 2\n2 3 4\n\nOutput\n3\n\nInput\n5 4\n3 1 8 9 7\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.\n\nOptimal sequence of actions in the second sample case:   In the first day Anastasia collects 8 pebbles of the third type.  In the second day she collects 8 pebbles of the fourth type.  In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.  In the fourth day she collects 7 pebbles of the fifth type.  In the fifth day she collects 1 pebble of the second type.",
        "solutions": "[\"n, k = [int(i) for i in input().split()]\\n\\nw = [int(i) for i in input().split()]\\n\\ntot = 0\\nfor wi in w:\\n    tot += (wi+k-1)//k\\n\\nans = (tot+1)//2\\nprint(ans)\\n\", \"n,k=[int(i) for i in input().split()]\\na=[int(i) for i in input().split()]\\nx=0\\nfor i in range(n):\\n    x+=(a[i]+k-1)//k\\nprint((x+1)//2)\", \"N, K = list(map(int, input().split()))\\nW = [int(x) for x in input().split()]\\nans = 0\\nfor w in W:\\n    if w % K == 0:\\n        ans += w // K\\n    else:\\n        ans += w // K + 1\\nif ans % 2 == 0:\\n    print(ans // 2)\\nelse:\\n    print(ans // 2 + 1)\\n\", \"from sys import stdin\\nimport math\\n\\nN, K = list(map(int, stdin.readline().split()))\\npebbles = list(map(int, stdin.readline().split()))\\n\\nprint(math.ceil(sum(math.ceil(p / K) for p in pebbles) / 2))\\n\", \"n, k = map(int, input().split())\\narray = list(map(int, input().split()))\\nans = 0\\nfor i in range (n):\\n    ans += (array[i] + k - 1) // k\\nprint((ans + 1) // 2)\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\nres = 0\\nfor i in a:\\n    res += (i+k-1) // k\\n\\nprint((res+1)//2)\", \"from sys import stdin, stdout\\n\\n\\nn, k = list(map(int, stdin.readline().rstrip().split()))\\n\\npebbleList = [int(a) for a in stdin.readline().rstrip().split()]\\n\\nnTrips=[]\\nfor i in range(n):\\n    nTrips.append(pebbleList[i]//k)\\n    if pebbleList[i]%k!=0:\\n        nTrips[i]+=1\\n\\ntotal = sum(nTrips)//2 + sum(nTrips)%2\\nprint(total)\\n\", \"\\n\\nn, k = list(map(int, input().split()))\\n\\nws = list(int(x) for x in input().split())\\n\\nresult = 0\\nfree_pocket = False\\n\\n\\nfor w in ws:\\n    needed_pockets = (w + k - 1) // k\\n    if needed_pockets % 2 == 0:\\n        result += needed_pockets // 2\\n    else:\\n        if free_pocket:\\n            result += (needed_pockets - 1) // 2\\n        else:\\n            result += (needed_pockets + 1) // 2\\n        free_pocket = not free_pocket\\n\\nprint(result)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nans = 0\\nfor i in range(n):\\n    ans += (a[i] - 1) // k + 1\\n    \\nprint((ans - 1) // 2 + 1)\", \"import sys\\nn,k = list(map(int, input().split()))\\nw = list(map(int, input().split()))\\nrem = 0\\nans = 0\\nfor i in range(n):\\n    \\n    if w[i] % k != 0:\\n        rem +=1\\n    ans += w[i] // k;\\nres = 0\\nres += ans// 2\\nif ans % 2 != 0:\\n    rem += 1\\nres += rem // 2\\nif rem % 2 != 0:\\n    res += 1\\nprint(res)\\n\", \"n,k=map(int,input().split())\\nip=list(map(int,input().split()))\\ncount=0\\nfor i in ip:\\n    if i%k==0:\\n        count+=i//k\\n    else:\\n        count+=(i//k)+1\\nif count %2==0:\\n    print(count//2)\\nelse:\\n    print(count//2 + 1)\", \"import math\\nn,k=list(map(int,input().split()))\\nw=[int(i) for i in input().split()]\\nres=[]\\nfor i in range(n):\\n    res.append(w[i]//k)\\n    res.append(bool(w[i]%k))\\nprint(math.ceil(sum(res)/2))\\n\", \"n, k = map(int, input().split())\\ndays = 0\\nw = list(map(int, input().split()))\\nfor wi in w:\\n    days += (wi - 1) // k + 1\\nprint((days - 1) // 2 + 1)\", \"n,k=map(int,input().split())\\nl=sorted(map(int,input().split()))\\nans=0\\nfor i in range(n):\\n    ans+=-(-l[i]//k)\\nprint(-(-ans//2))\", \"n,k=map(int,input().split())\\nl=[int(i) for i in input().split()]\\nans=[]\\nfor i in l:\\n    ans.append((i+k-1)//k)\\nprint((sum(ans)+1)//2)\", \"#!/usr/bin/env python3\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\nn, k = ri()\\n\\nw = list(ri())\\n\\nans = 0\\nfor ww in w:\\n    if ww % k == 0:\\n        ans += ww//k\\n    else:\\n        ans += ww//k + 1\\n\\nif ans%2:\\n    print(ans//2+1)\\nelse:\\n    print(ans//2)\\n\\nprint()\\n\\n\", \"n,k=map(int,input().split())\\nd=0\\nt = sum(((i-1)//k + 1) for i in map(int,input().split()))\\nprint((t-1)//2 + 1)\", \"from math import *\\nn,k = list(map(int,input().split()))\\n*m,=list(map(int,input().split()))\\nd=0.0\\nfor i in m:\\n    d+=ceil(i/k)\\nprint(ceil(d/2))\\n\", \"n, k = [int(i) for i in input().split()]\\nw = [int(i) for i in input().split()]\\nw.sort()\\nm = 0\\nfor i in w:\\n    m += (i + k - 1) // k\\n\\nprint((m + 1) // 2)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\n\\npeb = list(map(int, input().split()))\\n\\nd = 0\\n\\nfor p in peb:\\n    d += ceil(p / s)\\n\\nprint(ceil(d/2))\\n\", \"def R():\\n    return [int(x) for x in input().split()]\\n\\ndef __starting_point():\\n    n, k = R()\\n    w = R()\\n    result = 0\\n    for _w in w:\\n        if _w < k:\\n            result += 1\\n        elif _w % k == 0:\\n            result += _w // k\\n        else:\\n            result += _w // k + 1\\n\\n    if result % 2 == 0:\\n        print(result // 2)\\n    else: \\n        print(result // 2 + 1)\\n\\n__starting_point()\", \"from collections import deque\\nfrom sys import stdin\\nfrom math import ceil\\nlines = deque(line.strip() for line in stdin.readlines())\\n\\ndef nextline():\\n    return lines.popleft()\\n\\ndef types(cast):\\n    return tuple(int(x) for x in nextline().split())\\n\\ndef ints():\\n    return types(int)\\n\\ndef strs():\\n    return nextline().split()\\n\\ndef main():\\n    # lines will now contain all of the input's lines in a list\\n    n, k = ints()\\n    ws = ints()\\n    count = ceil(sum(ceil(x/k) for x in ws)/2)\\n    print(count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport math\\n\\nfin = sys.stdin\\nfout = sys.stdout\\nn, k = list(map(int, fin.readline().split()))\\na = list(map(int, fin.readline().split()))\\nans = 0\\ni = 0\\nwhile i < n:\\n    ans += math.ceil(a[i] / k)\\n    i += 1\\nfout.write(str(math.ceil(ans / 2)))\\n\", \"import math\\nn,k=list(map(int,input().split()))\\nline=list(map(int,input().split()))\\ncnt=0\\nfor x in line:\\n\\tcnt+=math.ceil(x/k)\\nprint(math.ceil(cnt/2))\\n\", \"n, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ncounterS = 0\\ncounterL = 0\\n\\nfor i in arr:\\n    if i <= k:\\n        counterS += 1\\n    else:\\n        if i <= 2 * k:\\n            counterL += 1\\n        else:\\n            counterL += (i // (2 * k))\\n            y = i - (i // (2 * k))*(2*k)\\n            if y <= k:\\n                if y != 0:\\n                    counterS += 1\\n            else:\\n                counterL += 1\\nlastCounter = (counterS // 2) + (counterS % 2) + counterL\\nprint(lastCounter)\\n\"]",
        "difficulty": "interview",
        "input": "5 72\n74 10 146 189 184\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/789/A"
    },
    {
        "id": 329,
        "task_id": 1940,
        "test_case_id": 6,
        "question": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each pocket at the same time. There are n different pebble types in the park, and there are w_{i} pebbles of the i-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.\n\nHelp her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.\n\nThe second line contains n integers w_1, w_2, ..., w_{n} (1 ≤ w_{i} ≤ 10^4) — number of pebbles of each type. \n\n\n-----Output-----\n\nThe only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.\n\n\n-----Examples-----\nInput\n3 2\n2 3 4\n\nOutput\n3\n\nInput\n5 4\n3 1 8 9 7\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.\n\nOptimal sequence of actions in the second sample case:   In the first day Anastasia collects 8 pebbles of the third type.  In the second day she collects 8 pebbles of the fourth type.  In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.  In the fourth day she collects 7 pebbles of the fifth type.  In the fifth day she collects 1 pebble of the second type.",
        "solutions": "[\"n, k = [int(i) for i in input().split()]\\n\\nw = [int(i) for i in input().split()]\\n\\ntot = 0\\nfor wi in w:\\n    tot += (wi+k-1)//k\\n\\nans = (tot+1)//2\\nprint(ans)\\n\", \"n,k=[int(i) for i in input().split()]\\na=[int(i) for i in input().split()]\\nx=0\\nfor i in range(n):\\n    x+=(a[i]+k-1)//k\\nprint((x+1)//2)\", \"N, K = list(map(int, input().split()))\\nW = [int(x) for x in input().split()]\\nans = 0\\nfor w in W:\\n    if w % K == 0:\\n        ans += w // K\\n    else:\\n        ans += w // K + 1\\nif ans % 2 == 0:\\n    print(ans // 2)\\nelse:\\n    print(ans // 2 + 1)\\n\", \"from sys import stdin\\nimport math\\n\\nN, K = list(map(int, stdin.readline().split()))\\npebbles = list(map(int, stdin.readline().split()))\\n\\nprint(math.ceil(sum(math.ceil(p / K) for p in pebbles) / 2))\\n\", \"n, k = map(int, input().split())\\narray = list(map(int, input().split()))\\nans = 0\\nfor i in range (n):\\n    ans += (array[i] + k - 1) // k\\nprint((ans + 1) // 2)\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\nres = 0\\nfor i in a:\\n    res += (i+k-1) // k\\n\\nprint((res+1)//2)\", \"from sys import stdin, stdout\\n\\n\\nn, k = list(map(int, stdin.readline().rstrip().split()))\\n\\npebbleList = [int(a) for a in stdin.readline().rstrip().split()]\\n\\nnTrips=[]\\nfor i in range(n):\\n    nTrips.append(pebbleList[i]//k)\\n    if pebbleList[i]%k!=0:\\n        nTrips[i]+=1\\n\\ntotal = sum(nTrips)//2 + sum(nTrips)%2\\nprint(total)\\n\", \"\\n\\nn, k = list(map(int, input().split()))\\n\\nws = list(int(x) for x in input().split())\\n\\nresult = 0\\nfree_pocket = False\\n\\n\\nfor w in ws:\\n    needed_pockets = (w + k - 1) // k\\n    if needed_pockets % 2 == 0:\\n        result += needed_pockets // 2\\n    else:\\n        if free_pocket:\\n            result += (needed_pockets - 1) // 2\\n        else:\\n            result += (needed_pockets + 1) // 2\\n        free_pocket = not free_pocket\\n\\nprint(result)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nans = 0\\nfor i in range(n):\\n    ans += (a[i] - 1) // k + 1\\n    \\nprint((ans - 1) // 2 + 1)\", \"import sys\\nn,k = list(map(int, input().split()))\\nw = list(map(int, input().split()))\\nrem = 0\\nans = 0\\nfor i in range(n):\\n    \\n    if w[i] % k != 0:\\n        rem +=1\\n    ans += w[i] // k;\\nres = 0\\nres += ans// 2\\nif ans % 2 != 0:\\n    rem += 1\\nres += rem // 2\\nif rem % 2 != 0:\\n    res += 1\\nprint(res)\\n\", \"n,k=map(int,input().split())\\nip=list(map(int,input().split()))\\ncount=0\\nfor i in ip:\\n    if i%k==0:\\n        count+=i//k\\n    else:\\n        count+=(i//k)+1\\nif count %2==0:\\n    print(count//2)\\nelse:\\n    print(count//2 + 1)\", \"import math\\nn,k=list(map(int,input().split()))\\nw=[int(i) for i in input().split()]\\nres=[]\\nfor i in range(n):\\n    res.append(w[i]//k)\\n    res.append(bool(w[i]%k))\\nprint(math.ceil(sum(res)/2))\\n\", \"n, k = map(int, input().split())\\ndays = 0\\nw = list(map(int, input().split()))\\nfor wi in w:\\n    days += (wi - 1) // k + 1\\nprint((days - 1) // 2 + 1)\", \"n,k=map(int,input().split())\\nl=sorted(map(int,input().split()))\\nans=0\\nfor i in range(n):\\n    ans+=-(-l[i]//k)\\nprint(-(-ans//2))\", \"n,k=map(int,input().split())\\nl=[int(i) for i in input().split()]\\nans=[]\\nfor i in l:\\n    ans.append((i+k-1)//k)\\nprint((sum(ans)+1)//2)\", \"#!/usr/bin/env python3\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\nn, k = ri()\\n\\nw = list(ri())\\n\\nans = 0\\nfor ww in w:\\n    if ww % k == 0:\\n        ans += ww//k\\n    else:\\n        ans += ww//k + 1\\n\\nif ans%2:\\n    print(ans//2+1)\\nelse:\\n    print(ans//2)\\n\\nprint()\\n\\n\", \"n,k=map(int,input().split())\\nd=0\\nt = sum(((i-1)//k + 1) for i in map(int,input().split()))\\nprint((t-1)//2 + 1)\", \"from math import *\\nn,k = list(map(int,input().split()))\\n*m,=list(map(int,input().split()))\\nd=0.0\\nfor i in m:\\n    d+=ceil(i/k)\\nprint(ceil(d/2))\\n\", \"n, k = [int(i) for i in input().split()]\\nw = [int(i) for i in input().split()]\\nw.sort()\\nm = 0\\nfor i in w:\\n    m += (i + k - 1) // k\\n\\nprint((m + 1) // 2)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\n\\npeb = list(map(int, input().split()))\\n\\nd = 0\\n\\nfor p in peb:\\n    d += ceil(p / s)\\n\\nprint(ceil(d/2))\\n\", \"def R():\\n    return [int(x) for x in input().split()]\\n\\ndef __starting_point():\\n    n, k = R()\\n    w = R()\\n    result = 0\\n    for _w in w:\\n        if _w < k:\\n            result += 1\\n        elif _w % k == 0:\\n            result += _w // k\\n        else:\\n            result += _w // k + 1\\n\\n    if result % 2 == 0:\\n        print(result // 2)\\n    else: \\n        print(result // 2 + 1)\\n\\n__starting_point()\", \"from collections import deque\\nfrom sys import stdin\\nfrom math import ceil\\nlines = deque(line.strip() for line in stdin.readlines())\\n\\ndef nextline():\\n    return lines.popleft()\\n\\ndef types(cast):\\n    return tuple(int(x) for x in nextline().split())\\n\\ndef ints():\\n    return types(int)\\n\\ndef strs():\\n    return nextline().split()\\n\\ndef main():\\n    # lines will now contain all of the input's lines in a list\\n    n, k = ints()\\n    ws = ints()\\n    count = ceil(sum(ceil(x/k) for x in ws)/2)\\n    print(count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport math\\n\\nfin = sys.stdin\\nfout = sys.stdout\\nn, k = list(map(int, fin.readline().split()))\\na = list(map(int, fin.readline().split()))\\nans = 0\\ni = 0\\nwhile i < n:\\n    ans += math.ceil(a[i] / k)\\n    i += 1\\nfout.write(str(math.ceil(ans / 2)))\\n\", \"import math\\nn,k=list(map(int,input().split()))\\nline=list(map(int,input().split()))\\ncnt=0\\nfor x in line:\\n\\tcnt+=math.ceil(x/k)\\nprint(math.ceil(cnt/2))\\n\", \"n, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ncounterS = 0\\ncounterL = 0\\n\\nfor i in arr:\\n    if i <= k:\\n        counterS += 1\\n    else:\\n        if i <= 2 * k:\\n            counterL += 1\\n        else:\\n            counterL += (i // (2 * k))\\n            y = i - (i // (2 * k))*(2*k)\\n            if y <= k:\\n                if y != 0:\\n                    counterS += 1\\n            else:\\n                counterL += 1\\nlastCounter = (counterS // 2) + (counterS % 2) + counterL\\nprint(lastCounter)\\n\"]",
        "difficulty": "interview",
        "input": "9 13\n132 87 200 62 168 51 185 192 118\n",
        "output": "48\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/789/A"
    },
    {
        "id": 330,
        "task_id": 1940,
        "test_case_id": 8,
        "question": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each pocket at the same time. There are n different pebble types in the park, and there are w_{i} pebbles of the i-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.\n\nHelp her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.\n\nThe second line contains n integers w_1, w_2, ..., w_{n} (1 ≤ w_{i} ≤ 10^4) — number of pebbles of each type. \n\n\n-----Output-----\n\nThe only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.\n\n\n-----Examples-----\nInput\n3 2\n2 3 4\n\nOutput\n3\n\nInput\n5 4\n3 1 8 9 7\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.\n\nOptimal sequence of actions in the second sample case:   In the first day Anastasia collects 8 pebbles of the third type.  In the second day she collects 8 pebbles of the fourth type.  In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.  In the fourth day she collects 7 pebbles of the fifth type.  In the fifth day she collects 1 pebble of the second type.",
        "solutions": "[\"n, k = [int(i) for i in input().split()]\\n\\nw = [int(i) for i in input().split()]\\n\\ntot = 0\\nfor wi in w:\\n    tot += (wi+k-1)//k\\n\\nans = (tot+1)//2\\nprint(ans)\\n\", \"n,k=[int(i) for i in input().split()]\\na=[int(i) for i in input().split()]\\nx=0\\nfor i in range(n):\\n    x+=(a[i]+k-1)//k\\nprint((x+1)//2)\", \"N, K = list(map(int, input().split()))\\nW = [int(x) for x in input().split()]\\nans = 0\\nfor w in W:\\n    if w % K == 0:\\n        ans += w // K\\n    else:\\n        ans += w // K + 1\\nif ans % 2 == 0:\\n    print(ans // 2)\\nelse:\\n    print(ans // 2 + 1)\\n\", \"from sys import stdin\\nimport math\\n\\nN, K = list(map(int, stdin.readline().split()))\\npebbles = list(map(int, stdin.readline().split()))\\n\\nprint(math.ceil(sum(math.ceil(p / K) for p in pebbles) / 2))\\n\", \"n, k = map(int, input().split())\\narray = list(map(int, input().split()))\\nans = 0\\nfor i in range (n):\\n    ans += (array[i] + k - 1) // k\\nprint((ans + 1) // 2)\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\nres = 0\\nfor i in a:\\n    res += (i+k-1) // k\\n\\nprint((res+1)//2)\", \"from sys import stdin, stdout\\n\\n\\nn, k = list(map(int, stdin.readline().rstrip().split()))\\n\\npebbleList = [int(a) for a in stdin.readline().rstrip().split()]\\n\\nnTrips=[]\\nfor i in range(n):\\n    nTrips.append(pebbleList[i]//k)\\n    if pebbleList[i]%k!=0:\\n        nTrips[i]+=1\\n\\ntotal = sum(nTrips)//2 + sum(nTrips)%2\\nprint(total)\\n\", \"\\n\\nn, k = list(map(int, input().split()))\\n\\nws = list(int(x) for x in input().split())\\n\\nresult = 0\\nfree_pocket = False\\n\\n\\nfor w in ws:\\n    needed_pockets = (w + k - 1) // k\\n    if needed_pockets % 2 == 0:\\n        result += needed_pockets // 2\\n    else:\\n        if free_pocket:\\n            result += (needed_pockets - 1) // 2\\n        else:\\n            result += (needed_pockets + 1) // 2\\n        free_pocket = not free_pocket\\n\\nprint(result)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nans = 0\\nfor i in range(n):\\n    ans += (a[i] - 1) // k + 1\\n    \\nprint((ans - 1) // 2 + 1)\", \"import sys\\nn,k = list(map(int, input().split()))\\nw = list(map(int, input().split()))\\nrem = 0\\nans = 0\\nfor i in range(n):\\n    \\n    if w[i] % k != 0:\\n        rem +=1\\n    ans += w[i] // k;\\nres = 0\\nres += ans// 2\\nif ans % 2 != 0:\\n    rem += 1\\nres += rem // 2\\nif rem % 2 != 0:\\n    res += 1\\nprint(res)\\n\", \"n,k=map(int,input().split())\\nip=list(map(int,input().split()))\\ncount=0\\nfor i in ip:\\n    if i%k==0:\\n        count+=i//k\\n    else:\\n        count+=(i//k)+1\\nif count %2==0:\\n    print(count//2)\\nelse:\\n    print(count//2 + 1)\", \"import math\\nn,k=list(map(int,input().split()))\\nw=[int(i) for i in input().split()]\\nres=[]\\nfor i in range(n):\\n    res.append(w[i]//k)\\n    res.append(bool(w[i]%k))\\nprint(math.ceil(sum(res)/2))\\n\", \"n, k = map(int, input().split())\\ndays = 0\\nw = list(map(int, input().split()))\\nfor wi in w:\\n    days += (wi - 1) // k + 1\\nprint((days - 1) // 2 + 1)\", \"n,k=map(int,input().split())\\nl=sorted(map(int,input().split()))\\nans=0\\nfor i in range(n):\\n    ans+=-(-l[i]//k)\\nprint(-(-ans//2))\", \"n,k=map(int,input().split())\\nl=[int(i) for i in input().split()]\\nans=[]\\nfor i in l:\\n    ans.append((i+k-1)//k)\\nprint((sum(ans)+1)//2)\", \"#!/usr/bin/env python3\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\nn, k = ri()\\n\\nw = list(ri())\\n\\nans = 0\\nfor ww in w:\\n    if ww % k == 0:\\n        ans += ww//k\\n    else:\\n        ans += ww//k + 1\\n\\nif ans%2:\\n    print(ans//2+1)\\nelse:\\n    print(ans//2)\\n\\nprint()\\n\\n\", \"n,k=map(int,input().split())\\nd=0\\nt = sum(((i-1)//k + 1) for i in map(int,input().split()))\\nprint((t-1)//2 + 1)\", \"from math import *\\nn,k = list(map(int,input().split()))\\n*m,=list(map(int,input().split()))\\nd=0.0\\nfor i in m:\\n    d+=ceil(i/k)\\nprint(ceil(d/2))\\n\", \"n, k = [int(i) for i in input().split()]\\nw = [int(i) for i in input().split()]\\nw.sort()\\nm = 0\\nfor i in w:\\n    m += (i + k - 1) // k\\n\\nprint((m + 1) // 2)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\n\\npeb = list(map(int, input().split()))\\n\\nd = 0\\n\\nfor p in peb:\\n    d += ceil(p / s)\\n\\nprint(ceil(d/2))\\n\", \"def R():\\n    return [int(x) for x in input().split()]\\n\\ndef __starting_point():\\n    n, k = R()\\n    w = R()\\n    result = 0\\n    for _w in w:\\n        if _w < k:\\n            result += 1\\n        elif _w % k == 0:\\n            result += _w // k\\n        else:\\n            result += _w // k + 1\\n\\n    if result % 2 == 0:\\n        print(result // 2)\\n    else: \\n        print(result // 2 + 1)\\n\\n__starting_point()\", \"from collections import deque\\nfrom sys import stdin\\nfrom math import ceil\\nlines = deque(line.strip() for line in stdin.readlines())\\n\\ndef nextline():\\n    return lines.popleft()\\n\\ndef types(cast):\\n    return tuple(int(x) for x in nextline().split())\\n\\ndef ints():\\n    return types(int)\\n\\ndef strs():\\n    return nextline().split()\\n\\ndef main():\\n    # lines will now contain all of the input's lines in a list\\n    n, k = ints()\\n    ws = ints()\\n    count = ceil(sum(ceil(x/k) for x in ws)/2)\\n    print(count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport math\\n\\nfin = sys.stdin\\nfout = sys.stdout\\nn, k = list(map(int, fin.readline().split()))\\na = list(map(int, fin.readline().split()))\\nans = 0\\ni = 0\\nwhile i < n:\\n    ans += math.ceil(a[i] / k)\\n    i += 1\\nfout.write(str(math.ceil(ans / 2)))\\n\", \"import math\\nn,k=list(map(int,input().split()))\\nline=list(map(int,input().split()))\\ncnt=0\\nfor x in line:\\n\\tcnt+=math.ceil(x/k)\\nprint(math.ceil(cnt/2))\\n\", \"n, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ncounterS = 0\\ncounterL = 0\\n\\nfor i in arr:\\n    if i <= k:\\n        counterS += 1\\n    else:\\n        if i <= 2 * k:\\n            counterL += 1\\n        else:\\n            counterL += (i // (2 * k))\\n            y = i - (i // (2 * k))*(2*k)\\n            if y <= k:\\n                if y != 0:\\n                    counterS += 1\\n            else:\\n                counterL += 1\\nlastCounter = (counterS // 2) + (counterS % 2) + counterL\\nprint(lastCounter)\\n\"]",
        "difficulty": "interview",
        "input": "10 1\n1 1 1 1 1 1 1 1 1 1\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/789/A"
    },
    {
        "id": 331,
        "task_id": 1940,
        "test_case_id": 9,
        "question": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each pocket at the same time. There are n different pebble types in the park, and there are w_{i} pebbles of the i-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.\n\nHelp her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.\n\nThe second line contains n integers w_1, w_2, ..., w_{n} (1 ≤ w_{i} ≤ 10^4) — number of pebbles of each type. \n\n\n-----Output-----\n\nThe only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.\n\n\n-----Examples-----\nInput\n3 2\n2 3 4\n\nOutput\n3\n\nInput\n5 4\n3 1 8 9 7\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.\n\nOptimal sequence of actions in the second sample case:   In the first day Anastasia collects 8 pebbles of the third type.  In the second day she collects 8 pebbles of the fourth type.  In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.  In the fourth day she collects 7 pebbles of the fifth type.  In the fifth day she collects 1 pebble of the second type.",
        "solutions": "[\"n, k = [int(i) for i in input().split()]\\n\\nw = [int(i) for i in input().split()]\\n\\ntot = 0\\nfor wi in w:\\n    tot += (wi+k-1)//k\\n\\nans = (tot+1)//2\\nprint(ans)\\n\", \"n,k=[int(i) for i in input().split()]\\na=[int(i) for i in input().split()]\\nx=0\\nfor i in range(n):\\n    x+=(a[i]+k-1)//k\\nprint((x+1)//2)\", \"N, K = list(map(int, input().split()))\\nW = [int(x) for x in input().split()]\\nans = 0\\nfor w in W:\\n    if w % K == 0:\\n        ans += w // K\\n    else:\\n        ans += w // K + 1\\nif ans % 2 == 0:\\n    print(ans // 2)\\nelse:\\n    print(ans // 2 + 1)\\n\", \"from sys import stdin\\nimport math\\n\\nN, K = list(map(int, stdin.readline().split()))\\npebbles = list(map(int, stdin.readline().split()))\\n\\nprint(math.ceil(sum(math.ceil(p / K) for p in pebbles) / 2))\\n\", \"n, k = map(int, input().split())\\narray = list(map(int, input().split()))\\nans = 0\\nfor i in range (n):\\n    ans += (array[i] + k - 1) // k\\nprint((ans + 1) // 2)\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\nres = 0\\nfor i in a:\\n    res += (i+k-1) // k\\n\\nprint((res+1)//2)\", \"from sys import stdin, stdout\\n\\n\\nn, k = list(map(int, stdin.readline().rstrip().split()))\\n\\npebbleList = [int(a) for a in stdin.readline().rstrip().split()]\\n\\nnTrips=[]\\nfor i in range(n):\\n    nTrips.append(pebbleList[i]//k)\\n    if pebbleList[i]%k!=0:\\n        nTrips[i]+=1\\n\\ntotal = sum(nTrips)//2 + sum(nTrips)%2\\nprint(total)\\n\", \"\\n\\nn, k = list(map(int, input().split()))\\n\\nws = list(int(x) for x in input().split())\\n\\nresult = 0\\nfree_pocket = False\\n\\n\\nfor w in ws:\\n    needed_pockets = (w + k - 1) // k\\n    if needed_pockets % 2 == 0:\\n        result += needed_pockets // 2\\n    else:\\n        if free_pocket:\\n            result += (needed_pockets - 1) // 2\\n        else:\\n            result += (needed_pockets + 1) // 2\\n        free_pocket = not free_pocket\\n\\nprint(result)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nans = 0\\nfor i in range(n):\\n    ans += (a[i] - 1) // k + 1\\n    \\nprint((ans - 1) // 2 + 1)\", \"import sys\\nn,k = list(map(int, input().split()))\\nw = list(map(int, input().split()))\\nrem = 0\\nans = 0\\nfor i in range(n):\\n    \\n    if w[i] % k != 0:\\n        rem +=1\\n    ans += w[i] // k;\\nres = 0\\nres += ans// 2\\nif ans % 2 != 0:\\n    rem += 1\\nres += rem // 2\\nif rem % 2 != 0:\\n    res += 1\\nprint(res)\\n\", \"n,k=map(int,input().split())\\nip=list(map(int,input().split()))\\ncount=0\\nfor i in ip:\\n    if i%k==0:\\n        count+=i//k\\n    else:\\n        count+=(i//k)+1\\nif count %2==0:\\n    print(count//2)\\nelse:\\n    print(count//2 + 1)\", \"import math\\nn,k=list(map(int,input().split()))\\nw=[int(i) for i in input().split()]\\nres=[]\\nfor i in range(n):\\n    res.append(w[i]//k)\\n    res.append(bool(w[i]%k))\\nprint(math.ceil(sum(res)/2))\\n\", \"n, k = map(int, input().split())\\ndays = 0\\nw = list(map(int, input().split()))\\nfor wi in w:\\n    days += (wi - 1) // k + 1\\nprint((days - 1) // 2 + 1)\", \"n,k=map(int,input().split())\\nl=sorted(map(int,input().split()))\\nans=0\\nfor i in range(n):\\n    ans+=-(-l[i]//k)\\nprint(-(-ans//2))\", \"n,k=map(int,input().split())\\nl=[int(i) for i in input().split()]\\nans=[]\\nfor i in l:\\n    ans.append((i+k-1)//k)\\nprint((sum(ans)+1)//2)\", \"#!/usr/bin/env python3\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\nn, k = ri()\\n\\nw = list(ri())\\n\\nans = 0\\nfor ww in w:\\n    if ww % k == 0:\\n        ans += ww//k\\n    else:\\n        ans += ww//k + 1\\n\\nif ans%2:\\n    print(ans//2+1)\\nelse:\\n    print(ans//2)\\n\\nprint()\\n\\n\", \"n,k=map(int,input().split())\\nd=0\\nt = sum(((i-1)//k + 1) for i in map(int,input().split()))\\nprint((t-1)//2 + 1)\", \"from math import *\\nn,k = list(map(int,input().split()))\\n*m,=list(map(int,input().split()))\\nd=0.0\\nfor i in m:\\n    d+=ceil(i/k)\\nprint(ceil(d/2))\\n\", \"n, k = [int(i) for i in input().split()]\\nw = [int(i) for i in input().split()]\\nw.sort()\\nm = 0\\nfor i in w:\\n    m += (i + k - 1) // k\\n\\nprint((m + 1) // 2)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\n\\npeb = list(map(int, input().split()))\\n\\nd = 0\\n\\nfor p in peb:\\n    d += ceil(p / s)\\n\\nprint(ceil(d/2))\\n\", \"def R():\\n    return [int(x) for x in input().split()]\\n\\ndef __starting_point():\\n    n, k = R()\\n    w = R()\\n    result = 0\\n    for _w in w:\\n        if _w < k:\\n            result += 1\\n        elif _w % k == 0:\\n            result += _w // k\\n        else:\\n            result += _w // k + 1\\n\\n    if result % 2 == 0:\\n        print(result // 2)\\n    else: \\n        print(result // 2 + 1)\\n\\n__starting_point()\", \"from collections import deque\\nfrom sys import stdin\\nfrom math import ceil\\nlines = deque(line.strip() for line in stdin.readlines())\\n\\ndef nextline():\\n    return lines.popleft()\\n\\ndef types(cast):\\n    return tuple(int(x) for x in nextline().split())\\n\\ndef ints():\\n    return types(int)\\n\\ndef strs():\\n    return nextline().split()\\n\\ndef main():\\n    # lines will now contain all of the input's lines in a list\\n    n, k = ints()\\n    ws = ints()\\n    count = ceil(sum(ceil(x/k) for x in ws)/2)\\n    print(count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport math\\n\\nfin = sys.stdin\\nfout = sys.stdout\\nn, k = list(map(int, fin.readline().split()))\\na = list(map(int, fin.readline().split()))\\nans = 0\\ni = 0\\nwhile i < n:\\n    ans += math.ceil(a[i] / k)\\n    i += 1\\nfout.write(str(math.ceil(ans / 2)))\\n\", \"import math\\nn,k=list(map(int,input().split()))\\nline=list(map(int,input().split()))\\ncnt=0\\nfor x in line:\\n\\tcnt+=math.ceil(x/k)\\nprint(math.ceil(cnt/2))\\n\", \"n, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ncounterS = 0\\ncounterL = 0\\n\\nfor i in arr:\\n    if i <= k:\\n        counterS += 1\\n    else:\\n        if i <= 2 * k:\\n            counterL += 1\\n        else:\\n            counterL += (i // (2 * k))\\n            y = i - (i // (2 * k))*(2*k)\\n            if y <= k:\\n                if y != 0:\\n                    counterS += 1\\n            else:\\n                counterL += 1\\nlastCounter = (counterS // 2) + (counterS % 2) + counterL\\nprint(lastCounter)\\n\"]",
        "difficulty": "interview",
        "input": "2 2\n2 2\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/789/A"
    },
    {
        "id": 332,
        "task_id": 2230,
        "test_case_id": 1,
        "question": "Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly one bag with k candies. \n\nHelp him give n bags of candies to each brother so that all brothers got the same number of candies.\n\n\n-----Input-----\n\nThe single line contains a single integer n (n is even, 2 ≤ n ≤ 100) — the number of Gerald's brothers.\n\n\n-----Output-----\n\nLet's assume that Gerald indexes his brothers with numbers from 1 to n. You need to print n lines, on the i-th line print n integers — the numbers of candies in the bags for the i-th brother. Naturally, all these numbers should be distinct and be within limits from 1 to n^2. You can print the numbers in the lines in any order. \n\nIt is guaranteed that the solution exists at the given limits.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1 4\n2 3\n\n\n\n-----Note-----\n\nThe sample shows Gerald's actions if he has two brothers. In this case, his bags contain 1, 2, 3 and 4 candies. He can give the bags with 1 and 4 candies to one brother and the bags with 2 and 3 to the other brother.",
        "solutions": "[\"n = int(input())\\nl = 0\\nr = n * n - 1\\n\\nfor i in range(n):\\n    for k in range(n // 2):\\n        print(l + 1, end = ' ')\\n        print(r + 1, end = ' ')\\n        l += 1\\n        r -= 1\\n    print()\\n\", \"n = int(input())\\na = 1\\nb = n * n\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(a, b, end = ' ')\\n        a += 1\\n        b -= 1\\n    print()\", \"def __starting_point():\\n    N = int(input())\\n    st = 1\\n    en = N*N\\n    for i in range(N):\\n        for j in range(N//2):\\n            print (st,end=\\\" \\\")\\n            st+=1\\n            print (en,end=\\\" \\\")\\n            en-=1\\n        print()\\n\\n__starting_point()\", \"def get_candies(n):\\n    result = []\\n    bags = list(range(1, n**2 +1))\\n\\n    for i in range(n):\\n        each = []\\n        for times in range(int(n / 2)):\\n            each.append(bags[0])\\n            each.append(bags[-1])\\n            bags = bags[1:len(bags)-1]\\n        each.sort()\\n        result.append(each)\\n\\n    return result\\n\\n\\ndef main():\\n    n = int(input())\\n    \\n\\n\\n    result = get_candies(n)\\n    \\n    for i in range(len(result)):\\n        string = \\\"\\\"\\n        for value in result[i]:\\n            string += str(value)\\n            string += \\\" \\\"\\n        print(string)\\n        \\n        \\n    \\n\\n#import doctest\\n#doctest.testmod()\\nmain()   \\n\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(1, n+1):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(n):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\ncnt1 = 1\\ncnt2 = n ** 2\\narr = []\\nfor i in range(n * n // 2):\\n    arr.append([cnt1, cnt2])\\n    cnt1 += 1\\n    cnt2 -= 1\\nfor i in range(0, len(arr), n // 2):\\n    for j in range(n // 2):\\n        print(arr[i + j][0], arr[i + j][1], sep=' ', end=' ')\\n    print('')\", \"n = input()\\nn = int(n)\\nbags = []\\nfor i in range(n**2):\\n\\tbags.append(i + 1)\\n\\nstart = 0\\nend = -1\\nstep = int(n / 2)\\n\\nfor i in range(n):\\n\\tfor j in range(start, start + step):\\n\\t\\tprint(bags[j], end=' ')\\n\\tstart += step\\n\\tfor j in range(end, end - step, -1):\\n\\t\\tprint(bags[j], end=' ')\\n\\tend -= step\\n\\tprint('')\\t\\n\", \"n = int(input())\\nt1, t2 = 1, n ** 2\\nfor i in range(0, n):\\n    for j in range(0, n, 2):\\n        print(t1, t2, sep = ' ', end = ' ')\\n        t1 += 1\\n        t2 -= 1\\n    print('')\", \"n = int(input())\\np = 0\\nfor i in range(n):\\n    for j in range(int(n/2)):\\n        p += 1\\n        print(p,n*n-p+1,end=\\\" \\\")\\n    print()\\n\", \"n = int(input()) \\nvec = [x + 1 for x in range(n * n)]\\nm = n // 2;\\nfor i in range(n):\\n    for j in range(m):\\n        print(vec[i * m + j], end = \\\" \\\")\\n        print(vec[-(i * m + j + 1)], end = \\\" \\\");\\n    print();\\n\", \"n = int(input())\\nleft = 1\\nright = n ** 2\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(left, right, end=' ')\\n        left, right = left + 1, right - 1\\n    print()\", \"def solve(n):\\n  start = 1\\n  end = n*n\\n  halfN = n // 2\\n  while(n):\\n    line = \\\"\\\"\\n    i=0\\n    while(i<halfN):\\n      line += str(start) + \\\" \\\"\\n      start += 1\\n      i += 1\\n    i=0\\n    while(i<halfN):\\n      line += str(end) + \\\" \\\"\\n      end -= 1\\n      i += 1\\n    n -= 1\\n    print(line)\\n\\nn = int(input())\\n\\nsolve(n)\"]",
        "difficulty": "interview",
        "input": "2\n",
        "output": "1 4\n2 3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/334/A"
    },
    {
        "id": 333,
        "task_id": 2230,
        "test_case_id": 2,
        "question": "Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly one bag with k candies. \n\nHelp him give n bags of candies to each brother so that all brothers got the same number of candies.\n\n\n-----Input-----\n\nThe single line contains a single integer n (n is even, 2 ≤ n ≤ 100) — the number of Gerald's brothers.\n\n\n-----Output-----\n\nLet's assume that Gerald indexes his brothers with numbers from 1 to n. You need to print n lines, on the i-th line print n integers — the numbers of candies in the bags for the i-th brother. Naturally, all these numbers should be distinct and be within limits from 1 to n^2. You can print the numbers in the lines in any order. \n\nIt is guaranteed that the solution exists at the given limits.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1 4\n2 3\n\n\n\n-----Note-----\n\nThe sample shows Gerald's actions if he has two brothers. In this case, his bags contain 1, 2, 3 and 4 candies. He can give the bags with 1 and 4 candies to one brother and the bags with 2 and 3 to the other brother.",
        "solutions": "[\"n = int(input())\\nl = 0\\nr = n * n - 1\\n\\nfor i in range(n):\\n    for k in range(n // 2):\\n        print(l + 1, end = ' ')\\n        print(r + 1, end = ' ')\\n        l += 1\\n        r -= 1\\n    print()\\n\", \"n = int(input())\\na = 1\\nb = n * n\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(a, b, end = ' ')\\n        a += 1\\n        b -= 1\\n    print()\", \"def __starting_point():\\n    N = int(input())\\n    st = 1\\n    en = N*N\\n    for i in range(N):\\n        for j in range(N//2):\\n            print (st,end=\\\" \\\")\\n            st+=1\\n            print (en,end=\\\" \\\")\\n            en-=1\\n        print()\\n\\n__starting_point()\", \"def get_candies(n):\\n    result = []\\n    bags = list(range(1, n**2 +1))\\n\\n    for i in range(n):\\n        each = []\\n        for times in range(int(n / 2)):\\n            each.append(bags[0])\\n            each.append(bags[-1])\\n            bags = bags[1:len(bags)-1]\\n        each.sort()\\n        result.append(each)\\n\\n    return result\\n\\n\\ndef main():\\n    n = int(input())\\n    \\n\\n\\n    result = get_candies(n)\\n    \\n    for i in range(len(result)):\\n        string = \\\"\\\"\\n        for value in result[i]:\\n            string += str(value)\\n            string += \\\" \\\"\\n        print(string)\\n        \\n        \\n    \\n\\n#import doctest\\n#doctest.testmod()\\nmain()   \\n\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(1, n+1):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(n):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\ncnt1 = 1\\ncnt2 = n ** 2\\narr = []\\nfor i in range(n * n // 2):\\n    arr.append([cnt1, cnt2])\\n    cnt1 += 1\\n    cnt2 -= 1\\nfor i in range(0, len(arr), n // 2):\\n    for j in range(n // 2):\\n        print(arr[i + j][0], arr[i + j][1], sep=' ', end=' ')\\n    print('')\", \"n = input()\\nn = int(n)\\nbags = []\\nfor i in range(n**2):\\n\\tbags.append(i + 1)\\n\\nstart = 0\\nend = -1\\nstep = int(n / 2)\\n\\nfor i in range(n):\\n\\tfor j in range(start, start + step):\\n\\t\\tprint(bags[j], end=' ')\\n\\tstart += step\\n\\tfor j in range(end, end - step, -1):\\n\\t\\tprint(bags[j], end=' ')\\n\\tend -= step\\n\\tprint('')\\t\\n\", \"n = int(input())\\nt1, t2 = 1, n ** 2\\nfor i in range(0, n):\\n    for j in range(0, n, 2):\\n        print(t1, t2, sep = ' ', end = ' ')\\n        t1 += 1\\n        t2 -= 1\\n    print('')\", \"n = int(input())\\np = 0\\nfor i in range(n):\\n    for j in range(int(n/2)):\\n        p += 1\\n        print(p,n*n-p+1,end=\\\" \\\")\\n    print()\\n\", \"n = int(input()) \\nvec = [x + 1 for x in range(n * n)]\\nm = n // 2;\\nfor i in range(n):\\n    for j in range(m):\\n        print(vec[i * m + j], end = \\\" \\\")\\n        print(vec[-(i * m + j + 1)], end = \\\" \\\");\\n    print();\\n\", \"n = int(input())\\nleft = 1\\nright = n ** 2\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(left, right, end=' ')\\n        left, right = left + 1, right - 1\\n    print()\", \"def solve(n):\\n  start = 1\\n  end = n*n\\n  halfN = n // 2\\n  while(n):\\n    line = \\\"\\\"\\n    i=0\\n    while(i<halfN):\\n      line += str(start) + \\\" \\\"\\n      start += 1\\n      i += 1\\n    i=0\\n    while(i<halfN):\\n      line += str(end) + \\\" \\\"\\n      end -= 1\\n      i += 1\\n    n -= 1\\n    print(line)\\n\\nn = int(input())\\n\\nsolve(n)\"]",
        "difficulty": "interview",
        "input": "4\n",
        "output": "1 16 2 15\n3 14 4 13\n5 12 6 11\n7 10 8 9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/334/A"
    },
    {
        "id": 334,
        "task_id": 2230,
        "test_case_id": 3,
        "question": "Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly one bag with k candies. \n\nHelp him give n bags of candies to each brother so that all brothers got the same number of candies.\n\n\n-----Input-----\n\nThe single line contains a single integer n (n is even, 2 ≤ n ≤ 100) — the number of Gerald's brothers.\n\n\n-----Output-----\n\nLet's assume that Gerald indexes his brothers with numbers from 1 to n. You need to print n lines, on the i-th line print n integers — the numbers of candies in the bags for the i-th brother. Naturally, all these numbers should be distinct and be within limits from 1 to n^2. You can print the numbers in the lines in any order. \n\nIt is guaranteed that the solution exists at the given limits.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1 4\n2 3\n\n\n\n-----Note-----\n\nThe sample shows Gerald's actions if he has two brothers. In this case, his bags contain 1, 2, 3 and 4 candies. He can give the bags with 1 and 4 candies to one brother and the bags with 2 and 3 to the other brother.",
        "solutions": "[\"n = int(input())\\nl = 0\\nr = n * n - 1\\n\\nfor i in range(n):\\n    for k in range(n // 2):\\n        print(l + 1, end = ' ')\\n        print(r + 1, end = ' ')\\n        l += 1\\n        r -= 1\\n    print()\\n\", \"n = int(input())\\na = 1\\nb = n * n\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(a, b, end = ' ')\\n        a += 1\\n        b -= 1\\n    print()\", \"def __starting_point():\\n    N = int(input())\\n    st = 1\\n    en = N*N\\n    for i in range(N):\\n        for j in range(N//2):\\n            print (st,end=\\\" \\\")\\n            st+=1\\n            print (en,end=\\\" \\\")\\n            en-=1\\n        print()\\n\\n__starting_point()\", \"def get_candies(n):\\n    result = []\\n    bags = list(range(1, n**2 +1))\\n\\n    for i in range(n):\\n        each = []\\n        for times in range(int(n / 2)):\\n            each.append(bags[0])\\n            each.append(bags[-1])\\n            bags = bags[1:len(bags)-1]\\n        each.sort()\\n        result.append(each)\\n\\n    return result\\n\\n\\ndef main():\\n    n = int(input())\\n    \\n\\n\\n    result = get_candies(n)\\n    \\n    for i in range(len(result)):\\n        string = \\\"\\\"\\n        for value in result[i]:\\n            string += str(value)\\n            string += \\\" \\\"\\n        print(string)\\n        \\n        \\n    \\n\\n#import doctest\\n#doctest.testmod()\\nmain()   \\n\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(1, n+1):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(n):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\ncnt1 = 1\\ncnt2 = n ** 2\\narr = []\\nfor i in range(n * n // 2):\\n    arr.append([cnt1, cnt2])\\n    cnt1 += 1\\n    cnt2 -= 1\\nfor i in range(0, len(arr), n // 2):\\n    for j in range(n // 2):\\n        print(arr[i + j][0], arr[i + j][1], sep=' ', end=' ')\\n    print('')\", \"n = input()\\nn = int(n)\\nbags = []\\nfor i in range(n**2):\\n\\tbags.append(i + 1)\\n\\nstart = 0\\nend = -1\\nstep = int(n / 2)\\n\\nfor i in range(n):\\n\\tfor j in range(start, start + step):\\n\\t\\tprint(bags[j], end=' ')\\n\\tstart += step\\n\\tfor j in range(end, end - step, -1):\\n\\t\\tprint(bags[j], end=' ')\\n\\tend -= step\\n\\tprint('')\\t\\n\", \"n = int(input())\\nt1, t2 = 1, n ** 2\\nfor i in range(0, n):\\n    for j in range(0, n, 2):\\n        print(t1, t2, sep = ' ', end = ' ')\\n        t1 += 1\\n        t2 -= 1\\n    print('')\", \"n = int(input())\\np = 0\\nfor i in range(n):\\n    for j in range(int(n/2)):\\n        p += 1\\n        print(p,n*n-p+1,end=\\\" \\\")\\n    print()\\n\", \"n = int(input()) \\nvec = [x + 1 for x in range(n * n)]\\nm = n // 2;\\nfor i in range(n):\\n    for j in range(m):\\n        print(vec[i * m + j], end = \\\" \\\")\\n        print(vec[-(i * m + j + 1)], end = \\\" \\\");\\n    print();\\n\", \"n = int(input())\\nleft = 1\\nright = n ** 2\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(left, right, end=' ')\\n        left, right = left + 1, right - 1\\n    print()\", \"def solve(n):\\n  start = 1\\n  end = n*n\\n  halfN = n // 2\\n  while(n):\\n    line = \\\"\\\"\\n    i=0\\n    while(i<halfN):\\n      line += str(start) + \\\" \\\"\\n      start += 1\\n      i += 1\\n    i=0\\n    while(i<halfN):\\n      line += str(end) + \\\" \\\"\\n      end -= 1\\n      i += 1\\n    n -= 1\\n    print(line)\\n\\nn = int(input())\\n\\nsolve(n)\"]",
        "difficulty": "interview",
        "input": "6\n",
        "output": "1 36 2 35 3 34\n4 33 5 32 6 31\n7 30 8 29 9 28\n10 27 11 26 12 25\n13 24 14 23 15 22\n16 21 17 20 18 19\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/334/A"
    },
    {
        "id": 335,
        "task_id": 2230,
        "test_case_id": 4,
        "question": "Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly one bag with k candies. \n\nHelp him give n bags of candies to each brother so that all brothers got the same number of candies.\n\n\n-----Input-----\n\nThe single line contains a single integer n (n is even, 2 ≤ n ≤ 100) — the number of Gerald's brothers.\n\n\n-----Output-----\n\nLet's assume that Gerald indexes his brothers with numbers from 1 to n. You need to print n lines, on the i-th line print n integers — the numbers of candies in the bags for the i-th brother. Naturally, all these numbers should be distinct and be within limits from 1 to n^2. You can print the numbers in the lines in any order. \n\nIt is guaranteed that the solution exists at the given limits.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1 4\n2 3\n\n\n\n-----Note-----\n\nThe sample shows Gerald's actions if he has two brothers. In this case, his bags contain 1, 2, 3 and 4 candies. He can give the bags with 1 and 4 candies to one brother and the bags with 2 and 3 to the other brother.",
        "solutions": "[\"n = int(input())\\nl = 0\\nr = n * n - 1\\n\\nfor i in range(n):\\n    for k in range(n // 2):\\n        print(l + 1, end = ' ')\\n        print(r + 1, end = ' ')\\n        l += 1\\n        r -= 1\\n    print()\\n\", \"n = int(input())\\na = 1\\nb = n * n\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(a, b, end = ' ')\\n        a += 1\\n        b -= 1\\n    print()\", \"def __starting_point():\\n    N = int(input())\\n    st = 1\\n    en = N*N\\n    for i in range(N):\\n        for j in range(N//2):\\n            print (st,end=\\\" \\\")\\n            st+=1\\n            print (en,end=\\\" \\\")\\n            en-=1\\n        print()\\n\\n__starting_point()\", \"def get_candies(n):\\n    result = []\\n    bags = list(range(1, n**2 +1))\\n\\n    for i in range(n):\\n        each = []\\n        for times in range(int(n / 2)):\\n            each.append(bags[0])\\n            each.append(bags[-1])\\n            bags = bags[1:len(bags)-1]\\n        each.sort()\\n        result.append(each)\\n\\n    return result\\n\\n\\ndef main():\\n    n = int(input())\\n    \\n\\n\\n    result = get_candies(n)\\n    \\n    for i in range(len(result)):\\n        string = \\\"\\\"\\n        for value in result[i]:\\n            string += str(value)\\n            string += \\\" \\\"\\n        print(string)\\n        \\n        \\n    \\n\\n#import doctest\\n#doctest.testmod()\\nmain()   \\n\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(1, n+1):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(n):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\ncnt1 = 1\\ncnt2 = n ** 2\\narr = []\\nfor i in range(n * n // 2):\\n    arr.append([cnt1, cnt2])\\n    cnt1 += 1\\n    cnt2 -= 1\\nfor i in range(0, len(arr), n // 2):\\n    for j in range(n // 2):\\n        print(arr[i + j][0], arr[i + j][1], sep=' ', end=' ')\\n    print('')\", \"n = input()\\nn = int(n)\\nbags = []\\nfor i in range(n**2):\\n\\tbags.append(i + 1)\\n\\nstart = 0\\nend = -1\\nstep = int(n / 2)\\n\\nfor i in range(n):\\n\\tfor j in range(start, start + step):\\n\\t\\tprint(bags[j], end=' ')\\n\\tstart += step\\n\\tfor j in range(end, end - step, -1):\\n\\t\\tprint(bags[j], end=' ')\\n\\tend -= step\\n\\tprint('')\\t\\n\", \"n = int(input())\\nt1, t2 = 1, n ** 2\\nfor i in range(0, n):\\n    for j in range(0, n, 2):\\n        print(t1, t2, sep = ' ', end = ' ')\\n        t1 += 1\\n        t2 -= 1\\n    print('')\", \"n = int(input())\\np = 0\\nfor i in range(n):\\n    for j in range(int(n/2)):\\n        p += 1\\n        print(p,n*n-p+1,end=\\\" \\\")\\n    print()\\n\", \"n = int(input()) \\nvec = [x + 1 for x in range(n * n)]\\nm = n // 2;\\nfor i in range(n):\\n    for j in range(m):\\n        print(vec[i * m + j], end = \\\" \\\")\\n        print(vec[-(i * m + j + 1)], end = \\\" \\\");\\n    print();\\n\", \"n = int(input())\\nleft = 1\\nright = n ** 2\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(left, right, end=' ')\\n        left, right = left + 1, right - 1\\n    print()\", \"def solve(n):\\n  start = 1\\n  end = n*n\\n  halfN = n // 2\\n  while(n):\\n    line = \\\"\\\"\\n    i=0\\n    while(i<halfN):\\n      line += str(start) + \\\" \\\"\\n      start += 1\\n      i += 1\\n    i=0\\n    while(i<halfN):\\n      line += str(end) + \\\" \\\"\\n      end -= 1\\n      i += 1\\n    n -= 1\\n    print(line)\\n\\nn = int(input())\\n\\nsolve(n)\"]",
        "difficulty": "interview",
        "input": "8\n",
        "output": "1 64 2 63 3 62 4 61\n5 60 6 59 7 58 8 57\n9 56 10 55 11 54 12 53\n13 52 14 51 15 50 16 49\n17 48 18 47 19 46 20 45\n21 44 22 43 23 42 24 41\n25 40 26 39 27 38 28 37\n29 36 30 35 31 34 32 33\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/334/A"
    },
    {
        "id": 336,
        "task_id": 2230,
        "test_case_id": 5,
        "question": "Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly one bag with k candies. \n\nHelp him give n bags of candies to each brother so that all brothers got the same number of candies.\n\n\n-----Input-----\n\nThe single line contains a single integer n (n is even, 2 ≤ n ≤ 100) — the number of Gerald's brothers.\n\n\n-----Output-----\n\nLet's assume that Gerald indexes his brothers with numbers from 1 to n. You need to print n lines, on the i-th line print n integers — the numbers of candies in the bags for the i-th brother. Naturally, all these numbers should be distinct and be within limits from 1 to n^2. You can print the numbers in the lines in any order. \n\nIt is guaranteed that the solution exists at the given limits.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1 4\n2 3\n\n\n\n-----Note-----\n\nThe sample shows Gerald's actions if he has two brothers. In this case, his bags contain 1, 2, 3 and 4 candies. He can give the bags with 1 and 4 candies to one brother and the bags with 2 and 3 to the other brother.",
        "solutions": "[\"n = int(input())\\nl = 0\\nr = n * n - 1\\n\\nfor i in range(n):\\n    for k in range(n // 2):\\n        print(l + 1, end = ' ')\\n        print(r + 1, end = ' ')\\n        l += 1\\n        r -= 1\\n    print()\\n\", \"n = int(input())\\na = 1\\nb = n * n\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(a, b, end = ' ')\\n        a += 1\\n        b -= 1\\n    print()\", \"def __starting_point():\\n    N = int(input())\\n    st = 1\\n    en = N*N\\n    for i in range(N):\\n        for j in range(N//2):\\n            print (st,end=\\\" \\\")\\n            st+=1\\n            print (en,end=\\\" \\\")\\n            en-=1\\n        print()\\n\\n__starting_point()\", \"def get_candies(n):\\n    result = []\\n    bags = list(range(1, n**2 +1))\\n\\n    for i in range(n):\\n        each = []\\n        for times in range(int(n / 2)):\\n            each.append(bags[0])\\n            each.append(bags[-1])\\n            bags = bags[1:len(bags)-1]\\n        each.sort()\\n        result.append(each)\\n\\n    return result\\n\\n\\ndef main():\\n    n = int(input())\\n    \\n\\n\\n    result = get_candies(n)\\n    \\n    for i in range(len(result)):\\n        string = \\\"\\\"\\n        for value in result[i]:\\n            string += str(value)\\n            string += \\\" \\\"\\n        print(string)\\n        \\n        \\n    \\n\\n#import doctest\\n#doctest.testmod()\\nmain()   \\n\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(1, n+1):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(n):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\ncnt1 = 1\\ncnt2 = n ** 2\\narr = []\\nfor i in range(n * n // 2):\\n    arr.append([cnt1, cnt2])\\n    cnt1 += 1\\n    cnt2 -= 1\\nfor i in range(0, len(arr), n // 2):\\n    for j in range(n // 2):\\n        print(arr[i + j][0], arr[i + j][1], sep=' ', end=' ')\\n    print('')\", \"n = input()\\nn = int(n)\\nbags = []\\nfor i in range(n**2):\\n\\tbags.append(i + 1)\\n\\nstart = 0\\nend = -1\\nstep = int(n / 2)\\n\\nfor i in range(n):\\n\\tfor j in range(start, start + step):\\n\\t\\tprint(bags[j], end=' ')\\n\\tstart += step\\n\\tfor j in range(end, end - step, -1):\\n\\t\\tprint(bags[j], end=' ')\\n\\tend -= step\\n\\tprint('')\\t\\n\", \"n = int(input())\\nt1, t2 = 1, n ** 2\\nfor i in range(0, n):\\n    for j in range(0, n, 2):\\n        print(t1, t2, sep = ' ', end = ' ')\\n        t1 += 1\\n        t2 -= 1\\n    print('')\", \"n = int(input())\\np = 0\\nfor i in range(n):\\n    for j in range(int(n/2)):\\n        p += 1\\n        print(p,n*n-p+1,end=\\\" \\\")\\n    print()\\n\", \"n = int(input()) \\nvec = [x + 1 for x in range(n * n)]\\nm = n // 2;\\nfor i in range(n):\\n    for j in range(m):\\n        print(vec[i * m + j], end = \\\" \\\")\\n        print(vec[-(i * m + j + 1)], end = \\\" \\\");\\n    print();\\n\", \"n = int(input())\\nleft = 1\\nright = n ** 2\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(left, right, end=' ')\\n        left, right = left + 1, right - 1\\n    print()\", \"def solve(n):\\n  start = 1\\n  end = n*n\\n  halfN = n // 2\\n  while(n):\\n    line = \\\"\\\"\\n    i=0\\n    while(i<halfN):\\n      line += str(start) + \\\" \\\"\\n      start += 1\\n      i += 1\\n    i=0\\n    while(i<halfN):\\n      line += str(end) + \\\" \\\"\\n      end -= 1\\n      i += 1\\n    n -= 1\\n    print(line)\\n\\nn = int(input())\\n\\nsolve(n)\"]",
        "difficulty": "interview",
        "input": "10\n",
        "output": "1 100 2 99 3 98 4 97 5 96\n6 95 7 94 8 93 9 92 10 91\n11 90 12 89 13 88 14 87 15 86\n16 85 17 84 18 83 19 82 20 81\n21 80 22 79 23 78 24 77 25 76\n26 75 27 74 28 73 29 72 30 71\n31 70 32 69 33 68 34 67 35 66\n36 65 37 64 38 63 39 62 40 61\n41 60 42 59 43 58 44 57 45 56\n46 55 47 54 48 53 49 52 50 51\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/334/A"
    },
    {
        "id": 337,
        "task_id": 2230,
        "test_case_id": 6,
        "question": "Gerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for each integer k from 1 to n^2 he has exactly one bag with k candies. \n\nHelp him give n bags of candies to each brother so that all brothers got the same number of candies.\n\n\n-----Input-----\n\nThe single line contains a single integer n (n is even, 2 ≤ n ≤ 100) — the number of Gerald's brothers.\n\n\n-----Output-----\n\nLet's assume that Gerald indexes his brothers with numbers from 1 to n. You need to print n lines, on the i-th line print n integers — the numbers of candies in the bags for the i-th brother. Naturally, all these numbers should be distinct and be within limits from 1 to n^2. You can print the numbers in the lines in any order. \n\nIt is guaranteed that the solution exists at the given limits.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1 4\n2 3\n\n\n\n-----Note-----\n\nThe sample shows Gerald's actions if he has two brothers. In this case, his bags contain 1, 2, 3 and 4 candies. He can give the bags with 1 and 4 candies to one brother and the bags with 2 and 3 to the other brother.",
        "solutions": "[\"n = int(input())\\nl = 0\\nr = n * n - 1\\n\\nfor i in range(n):\\n    for k in range(n // 2):\\n        print(l + 1, end = ' ')\\n        print(r + 1, end = ' ')\\n        l += 1\\n        r -= 1\\n    print()\\n\", \"n = int(input())\\na = 1\\nb = n * n\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(a, b, end = ' ')\\n        a += 1\\n        b -= 1\\n    print()\", \"def __starting_point():\\n    N = int(input())\\n    st = 1\\n    en = N*N\\n    for i in range(N):\\n        for j in range(N//2):\\n            print (st,end=\\\" \\\")\\n            st+=1\\n            print (en,end=\\\" \\\")\\n            en-=1\\n        print()\\n\\n__starting_point()\", \"def get_candies(n):\\n    result = []\\n    bags = list(range(1, n**2 +1))\\n\\n    for i in range(n):\\n        each = []\\n        for times in range(int(n / 2)):\\n            each.append(bags[0])\\n            each.append(bags[-1])\\n            bags = bags[1:len(bags)-1]\\n        each.sort()\\n        result.append(each)\\n\\n    return result\\n\\n\\ndef main():\\n    n = int(input())\\n    \\n\\n\\n    result = get_candies(n)\\n    \\n    for i in range(len(result)):\\n        string = \\\"\\\"\\n        for value in result[i]:\\n            string += str(value)\\n            string += \\\" \\\"\\n        print(string)\\n        \\n        \\n    \\n\\n#import doctest\\n#doctest.testmod()\\nmain()   \\n\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(1, n+1):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\na = int(n ** 2 + 1)\\nt = 1\\n\\nfor i in range(n):\\n    for j in range(int(n/2) - 1):\\n        print('%d %d' % (t, a - t), end = ' ')\\n        t += 1\\n    print('%d %d' % (t, a - t))\\n    t += 1\", \"n = int(input())\\ncnt1 = 1\\ncnt2 = n ** 2\\narr = []\\nfor i in range(n * n // 2):\\n    arr.append([cnt1, cnt2])\\n    cnt1 += 1\\n    cnt2 -= 1\\nfor i in range(0, len(arr), n // 2):\\n    for j in range(n // 2):\\n        print(arr[i + j][0], arr[i + j][1], sep=' ', end=' ')\\n    print('')\", \"n = input()\\nn = int(n)\\nbags = []\\nfor i in range(n**2):\\n\\tbags.append(i + 1)\\n\\nstart = 0\\nend = -1\\nstep = int(n / 2)\\n\\nfor i in range(n):\\n\\tfor j in range(start, start + step):\\n\\t\\tprint(bags[j], end=' ')\\n\\tstart += step\\n\\tfor j in range(end, end - step, -1):\\n\\t\\tprint(bags[j], end=' ')\\n\\tend -= step\\n\\tprint('')\\t\\n\", \"n = int(input())\\nt1, t2 = 1, n ** 2\\nfor i in range(0, n):\\n    for j in range(0, n, 2):\\n        print(t1, t2, sep = ' ', end = ' ')\\n        t1 += 1\\n        t2 -= 1\\n    print('')\", \"n = int(input())\\np = 0\\nfor i in range(n):\\n    for j in range(int(n/2)):\\n        p += 1\\n        print(p,n*n-p+1,end=\\\" \\\")\\n    print()\\n\", \"n = int(input()) \\nvec = [x + 1 for x in range(n * n)]\\nm = n // 2;\\nfor i in range(n):\\n    for j in range(m):\\n        print(vec[i * m + j], end = \\\" \\\")\\n        print(vec[-(i * m + j + 1)], end = \\\" \\\");\\n    print();\\n\", \"n = int(input())\\nleft = 1\\nright = n ** 2\\nfor i in range(n):\\n    for j in range(n // 2):\\n        print(left, right, end=' ')\\n        left, right = left + 1, right - 1\\n    print()\", \"def solve(n):\\n  start = 1\\n  end = n*n\\n  halfN = n // 2\\n  while(n):\\n    line = \\\"\\\"\\n    i=0\\n    while(i<halfN):\\n      line += str(start) + \\\" \\\"\\n      start += 1\\n      i += 1\\n    i=0\\n    while(i<halfN):\\n      line += str(end) + \\\" \\\"\\n      end -= 1\\n      i += 1\\n    n -= 1\\n    print(line)\\n\\nn = int(input())\\n\\nsolve(n)\"]",
        "difficulty": "interview",
        "input": "12\n",
        "output": "1 144 2 143 3 142 4 141 5 140 6 139\n7 138 8 137 9 136 10 135 11 134 12 133\n13 132 14 131 15 130 16 129 17 128 18 127\n19 126 20 125 21 124 22 123 23 122 24 121\n25 120 26 119 27 118 28 117 29 116 30 115\n31 114 32 113 33 112 34 111 35 110 36 109\n37 108 38 107 39 106 40 105 41 104 42 103\n43 102 44 101 45 100 46 99 47 98 48 97\n49 96 50 95 51 94 52 93 53 92 54 91\n55 90 56 89 57 88 58 87 59 86 60 85\n61 84 62 83 63 82 64 81 65 80 66 79\n67 78 68 77 69 76 70 75 71 74 72 73\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/334/A"
    },
    {
        "id": 338,
        "task_id": 2235,
        "test_case_id": 6,
        "question": "A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.\n\nThe fare is constructed in the following manner. There are three types of tickets:   a ticket for one trip costs 20 byteland rubles,  a ticket for 90 minutes costs 50 byteland rubles,  a ticket for one day (1440 minutes) costs 120 byteland rubles. \n\nNote that a ticket for x minutes activated at time t can be used for trips started in time range from t to t + x - 1, inclusive. Assume that all trips take exactly one minute.\n\nTo simplify the choice for the passenger, the system automatically chooses the optimal tickets. After each trip starts, the system analyses all the previous trips and the current trip and chooses a set of tickets for these trips with a minimum total cost. Let the minimum total cost of tickets to cover all trips from the first to the current is a, and the total sum charged before is b. Then the system charges the passenger the sum a - b.\n\nYou have to write a program that, for given trips made by a passenger, calculates the sum the passenger is charged after each trip.\n\n\n-----Input-----\n\nThe first line of input contains integer number n (1 ≤ n ≤ 10^5) — the number of trips made by passenger.\n\nEach of the following n lines contains the time of trip t_{i} (0 ≤ t_{i} ≤ 10^9), measured in minutes from the time of starting the system. All t_{i} are different, given in ascending order, i. e. t_{i} + 1 > t_{i} holds for all 1 ≤ i < n.\n\n\n-----Output-----\n\nOutput n integers. For each trip, print the sum the passenger is charged after it.\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\n20\n20\n10\n\nInput\n10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n\nOutput\n20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n\n\n\n-----Note-----\n\nIn the first example, the system works as follows: for the first and second trips it is cheaper to pay for two one-trip tickets, so each time 20 rubles is charged, after the third trip the system understands that it would be cheaper to buy a ticket for 90 minutes. This ticket costs 50 rubles, and the passenger had already paid 40 rubles, so it is necessary to charge 10 rubles only.",
        "solutions": "[\"import sys\\nimport bisect\\ninput = sys.stdin.readline\\n\\ntrips = int(input())\\ndyn = [int(input()) for i in range(trips)]\\n\\ncmap = [0,20] + [0 for i in range(trips-1)]\\n\\nfor i in range(2,trips+1):\\n    cmap[i] = min(cmap[i-1] + 20,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-89)] + 50,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-1439)] + 120)\\n\\nfor i in range(1,trips+1):\\n    print(cmap[i]-cmap[i-1])\\n\\n\", \"n = int(input())\\n\\ntravel_times = list()\\ntravel_pay = list()\\n\\npay_ticket1 = 0\\ntime_ticket1 = 0\\n\\npay_ticket2 = 0\\ntime_ticket2 = 0\\n\\nfor travel_id in range(n):\\n    t = int(input())\\n    travel_times.append(t)\\n    \\n    pay2 = 20\\n    \\n    sum_time1 = t - travel_times[time_ticket1]\\n    sum_time2 = t - travel_times[time_ticket2]\\n\\n    if sum_time1 >= 90:\\n        pay_ticket1 -= travel_pay[time_ticket1]\\n        \\n        for id2 in range(time_ticket1+1, travel_id+1):\\n            if t - travel_times[id2] < 90:\\n                time_ticket1 = id2\\n                break\\n            else:\\n                pay_ticket1 -= travel_pay[id2]\\n\\n        sum_time1 = t - travel_times[time_ticket1]\\n\\n\\n    if sum_time2 >= 1440:\\n        pay_ticket2 -= travel_pay[time_ticket2]\\n        \\n        for id2 in range(time_ticket2+1, travel_id+1):\\n            if t - travel_times[id2] < 1440:\\n                time_ticket2 = id2\\n                break\\n            else:\\n                pay_ticket2 -= travel_pay[id2]\\n\\n        sum_time2 = t - travel_times[time_ticket2]\\n\\n    \\n\\n    if pay_ticket1 + pay2 > 50:\\n        pay2 = 50 - pay_ticket1\\n\\n    if pay_ticket2 + pay2 > 120:\\n        pay2 = 120 - pay_ticket2\\n\\n    \\n    pay_ticket1 += pay2\\n    pay_ticket2 += pay2\\n    \\n    travel_pay.append(pay2)\\n    \\nfor pay in travel_pay:\\n    print(pay)\", \"import bisect\\n\\ndef getIndex(a, x):\\n    \\n    for i in range(0, len(a)):\\n        if  a[i] > x:\\n            return i\\n    return 0\\n\\n\\nn = int(input())\\n\\ntimes = []\\ntotal = 0\\nfor i in range(0, n):\\n    time = int(input())\\n    times.append(time)\\n    total += time \\n    \\ncost = [0 for i in range(0, n + 1)]\\ncost[0] = 0\\ncost[1] = 20\\n\\nfor i in range(2, n + 1):\\n    cost[i] =  min(cost[i - 1] + 20, \\n        cost[bisect.bisect_left(times, times[i-1] - 89)] + 50, \\n        cost[bisect.bisect_left(times, times[i-1] - 1439)] + 120)\\n    \\n    # print(cost[getIndex(89, times, i - 1)] + 50)\\n# print(cost)\\n# print(times)\\nfor i in range(1, n + 1):\\n    print(cost[i] - cost[i - 1])\\n\", \"def main():\\n\\tN = int(input())\\n\\tS = [0]\\n\\tT = [0]\\n\\tkh = 0\\n\\tkd = 0\\n\\tfor n in range(1, N+1):\\n\\t\\tT.append(int(input()))\\n\\t\\tfor i in range(kh + 1, n):\\n\\t\\t\\t#print(T[n], T[i])\\n\\t\\t\\tif T[n] - T[i] < 90:\\n\\t\\t\\t\\tkh = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkh = i\\n\\t\\tfor i in range(kd + 1, n):\\n\\t\\t\\tif T[n] - T[i] < 1440:\\n\\t\\t\\t\\tkd = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkd = i\\n\\t\\t#print(n, kh, kd)\\n\\t\\t#print(20, S[n - 1], 50, S[kh], 120, S[kd])\\n\\t\\tS.append(min(20 + S[n - 1], 50 + S[kh], 120 + S[kd]))\\n\\t\\t#print(T)\\n\\t\\t#print(S)\\n\\t\\tprint(S[n] - S[n - 1])\\n\\nmain()\\n\\n# 1509134058412\\n\", \"n=int(input())\\nex1=0\\nex2=0\\nL=[]\\nf=[0]*(n+1)\\nfor i in range(n):\\n    L.append(int(input()))\\n    while (L[i] - L[ex1 ] >= 90):\\n        ex1+=1\\n    while (L[i] - L[ex2 ] >= 1440):\\n        ex2+=1\\n    f[i+1] = min(min(f[ex1] + 50, f[ex2] + 120), f[i] + 20)\\n    print(f[i+1] - f[i])\\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n    \\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    \\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n\", \"\\nn = int(input())\\na = [0,]\\nfor i in range(n):\\n\\tx = int(input())\\n\\ta.append(x)\\n\\ndp = [0] * (n + 1)\\ndp[0] = 0\\np90 = 1\\np1440 = 1\\nfor i in range(1, n + 1):\\n\\tdp[i] = dp[i - 1] + 20\\n\\twhile a[p90] + 90 <= a[i]:\\n\\t\\tp90 = p90 + 1\\n\\tdp[i] = min(dp[i], dp[p90 - 1] + 50)\\n\\twhile a[p1440] + 1440 <= a[i]:\\n\\t\\tp1440 = p1440 + 1\\n\\tdp[i] = min(dp[i], dp[p1440 - 1] + 120)\\nfor i in range(1, n + 1):\\n\\tprint(dp[i] - dp[i - 1])\", \"n=int(input())\\n\\ntrips=[]\\n\\nprix=[0]\\n\\nk=0\\n\\nj=0\\n\\nfor i in range (n):\\n\\n    trips.append(int(input()))\\n\\n    while trips[i]-trips[j]>=90 :\\n\\n        j+=1\\n\\n    while trips[i]-trips[k]>=1440:\\n\\n        k+=1\\n\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n\\n    print(prix[-1]-prix[-2])\\n\\n    \\n\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"import math\\nimport sys\\nfrom bisect import bisect_right, bisect_left, insort_right\\nfrom collections import Counter, defaultdict\\nfrom heapq import heappop, heappush\\nfrom itertools import accumulate, permutations, combinations\\nfrom sys import stdout\\n\\nR = lambda: map(int, input().split())\\nn = int(input())\\narr = []\\nfor _ in range(n):\\n    arr.append(int(input()))\\ncst = [math.inf] * n + [0]\\nfor i in range(n):\\n    cst[i] = min(cst[i - 1] + 20, cst[bisect_left(arr, arr[i] - 89) - 1] + 50, cst[bisect_left(arr, arr[i] - 1439) - 1] + 120)\\nfor i in range(n):\\n    print(cst[i] - cst[i - 1])\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\"]",
        "difficulty": "interview",
        "input": "1\n0\n",
        "output": "20\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/756/B"
    },
    {
        "id": 339,
        "task_id": 2432,
        "test_case_id": 1,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($0 \\le a \\le 63$).\n\n\n-----Output-----\n\nOutput a single number.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n2\n\nInput\n5\n\nOutput\n24\n\nInput\n35\n\nOutput\n50",
        "solutions": "[\"n = int(input())\\na = (n & 32) >> 5\\nb = (n & 16) >> 4\\nc = (n & 8) >> 3\\nd = (n & 4) >> 2\\ne = (n & 2) >> 1\\nf = n & 1\\n\\nprint(32 * a + 16 * f + 8 * d + 4 * c + 2 * e + b)\\n\", \"p = [1, 6, 4, 3, 5, 2]\\np.reverse()\\nfor i in range(6):\\n  p[i] = 6 - p[i]\\n\\n# print(p)\\n\\na = int(input())\\nb = [(a & (2**i))//(2**i) for i in range(6)]\\nc = [0] * 6\\nfor i in range(6):\\n  c[i] = b[p[i]]\\n\\n# print(b)\\n# print(c)\\nprint(sum([c[i] * (2**i) for i in range(6)]))\\n\\n# \\\"And after happily lived ever they\\\"\\n\", \"a = int(input())\\nans = 0\\nif a & (1 << 5):\\n    ans += 1 << 5\\nif a & (1 << 4):\\n    ans += 1 << 0\\nif a & (1 << 3):\\n    ans += 1 << 2\\nif a & (1 << 2):\\n    ans += 1 << 3\\nif a & (1 << 1):\\n    ans += 1 << 1\\nif a & (1 << 0):\\n    ans += 1 << 4\\nprint(ans)\", \"perm = [5, 0, 2, 3, 1, 4]\\nn = int(input())\\nans = 0\\nfor i in range(len(perm)):\\n\\tans = ans * 2 + ((n >> perm[i]) & 1)\\n\\nprint(ans)\", \"a=int(input())\\na=bin(a+128)\\nprint(32*int(a[4])+16*int(a[9])+8*int(a[7])+4*int(a[6])+2*int(a[8])+int(a[5]))\", \"b = bin(int(input()))[2:].zfill(6)\\n\\nprint(int(b[0]+b[5]+b[3]+b[2]+b[4]+b[1],2))\\n\", \"x = int(input())\\ny = 0\\nif x & 1: y = y | 16\\nif x & 2: y = y | 2\\nif x & 4: y = y | 8\\nif x & 8: y = y | 4\\nif x & 16: y = y | 1\\nif x & 32: y = y | 32\\nprint(y)\\n\", \"a = bin(int(input()))[2:].zfill(6)\\nb = ''.join([a[0], a[5], a[3], a[2], a[4], a[1]])\\nprint(int(b, base=2))\\n\", \"x = int(input())\\nprint((x&32) + (x&16)//16 + (x&8)//2 + (x&4)*2 + (x&2) + (x&1)*16)\\n\", \"# And after happily lived ever they\\n\\nn = int(input())\\nd = [0,5,3,2,4,1]\\n\\nr=0\\nfor dd in d:\\n    r=r*2 + bool(n&1<<(5-dd))\\n\\nprint (r)\", \"n=int(input())\\nc=bin(n)[2:]\\nwhile(len(c))<6:\\n    c='0'+c\\nd=\\\"\\\"\\nd=d+c[0]\\nd=d+c[5]\\nd=d+c[3]\\nd=d+c[2]\\nd=d+c[4]\\nd=d+c[1]\\nprint(int(d,2))\\n\", \"n = int(input(''))\\nans = 0\\ni = 0\\nlst = [4, 1, 3, 2, 0, 5]\\nwhile n > 0:\\n    ans += (n % 2) * 2 ** lst[i]\\n    i += 1\\n    n //=2\\nprint(ans)\", \"a = int (input())\\nprint((((a & 32) >> 0) + ((a & 16) >> 4) + ((a & 8) >> 1) + \\n       ((a & 4) << 1) + ((a & 2) >> 0) + ((a & 1) << 4)))\\n\", \"lip = [0, 5, 3, 2, 4, 1]\\nn = int(input())\\na = []\\nfor i in range(6):\\n    a.append(n%2)\\n    n //= 2\\na.reverse()\\nb = [0]*6\\nfor i in range(6):\\n    b[lip[i]] = a[i]\\nans = 0\\nk = 1\\n#print(a)\\n#print(b)\\nfor i in range(6):\\n    ans += k*b[-i - 1]\\n    k *= 2\\nprint(ans)\\n\", \"ans=0\\na=[4, 1, 3, 2, 0, 5]\\nx=int(input())\\nfor i in range(6):\\n    if(x & (1 << i)):\\n        ans += (1<<a[i])\\nprint(ans)\", \"num=int(input())\\nadd=0\\nif(num%32<16):\\n  if(num%2==1):\\n    add+=15\\nelse:\\n  if(num%2==0):\\n    add-=15\\nif(num%16<8):\\n  if(num%8>=4):\\n    add+=4\\nelse:\\n  if(num%8<4):\\n    add-=4\\nnum+=add\\nprint(num)\\n\", \"n = int(input())\\nn = list(bin(n)[2:])\\nn = (6-len(n))*[\\\"0\\\"]+n \\nn_t = n.copy()\\nn[1] = n_t[5]\\nn[2] = n_t[3]\\nn[3] = n_t[2]\\nn[4] = n_t[4]\\nn[5] = n_t[1]\\nprint(int(''.join(n),2))\", \"idx = [0, 5, 3, 2, 4, 1]\\nn = int(input())\\nb = bin(n)[2:]\\nb = '0'*(6 - len(b)) + b\\noutput_str = ''.join([b[i] for i in idx])\\nprint(int(output_str, 2))\\n\", \"a=bin(int(input()))[2:]\\na='0'*(6-len(a))+a\\na=list(a)\\na[0],a[1],a[2],a[3],a[4],a[5]=a[0],a[5],a[3],a[2],a[4],a[1]\\nprint(int(''.join(a),2))\", \"a = int(input(''))\\nb = bin(a)[2:]\\nb = '0'*(6-len(b))+b\\nans = b[0]+b[5]+b[3]+b[2]+b[4]+b[1]\\nprint(int('0b'+ans,2))\", \"T = int(input())\\nbit = []\\narr = [4,1,3,2,0,5]\\ns = 0\\nfor i in range(6):\\n\\tif T % 2 == 0:\\n\\t\\tT = T // 2\\n\\t\\tbit.append(0)\\n\\telse:\\n\\t\\tT = T // 2\\n\\t\\tbit.append(1)\\n\\t\\ts += 2**arr.index(i)\\nprint(s)\\n\", \"N = int(input())\\nb = []\\nfor i in range(6):\\n    N, r = divmod(N, 2)\\n    b.append(r)\\nans = 0\\nif b[0]: \\n    ans += 16\\nif b[1]:\\n    ans += 2\\nif b[2]:\\n    ans += 8\\nif b[3]:\\n    ans += 4\\nif b[4]:\\n    ans += 1\\nif b[5]:\\n    ans += 32\\nprint(ans)\", \"a = int(input())\\nmult = [32, 1, 4, 8, 2, 16]\\n\\nout = 0\\nfor i, c in enumerate(format(a, '#08b')[2:]):\\n    if c == '1':\\n        out += mult[i]\\n        \\nprint(out)\", \"s = bin(int(input()))[2:].zfill(6)\\nprint(int(s[0]+s[5]+s[3]+s[2]+s[4]+s[1],2))\\n\", \"'''from math import sqrt, ceil\\na = int(input())\\nfor i in range(2, ceil(sqrt(a)) + 1):\\n    if a % i == 0:\\n        print(i, end='')\\n        print(a//i)\\n'''\\n\\n\\na = int(input())\\ns = [1, 2, 4, 8, 16, 32]\\ns1 = ''\\ns2 = ''\\nfor i in s[::-1]:\\n    if a - i >= 0:\\n        a -= i\\n        s1 += '1'\\n    else:\\n        s1 += '0'\\ns2 = s1[0]\\ns2 += s1[5]\\ns2 += s1[3]\\ns2 += s1[2]\\ns2 += s1[4]\\ns2 += s1[1]\\nb = 0\\nfor i in range(6):\\n    b += int(s2[5 - i]) * s[i]\\n\\nprint(b)\", \"seq = bin(int(input()))[2:].rjust(6, '0')\\nprint(int(seq[0] + seq[5] + seq[3] + seq[2] + seq[4] + seq[1], 2))\", \"s = bin(int(input()))[2:]\\ns = '0' * (7 - len(s)) + s\\nres = list('0' * 7)\\n\\na = [0, 1, 6, 4, 3, 5, 2]\\nfor i in range(7):\\n    res[i] = s[a[i]]\\n\\nprint(int(''.join(res), 2))\", \"x = int(input())\\nx = bin(x)[2:]\\nx = list(x)\\nx = [\\\"0\\\"]*(6-len(x)) + x\\ntemp = \\tx[5]\\nx[5] = x[1]\\nx[1] = temp\\ntemp = x[2]\\nx[2] = x[3]\\nx[3] = temp\\nx = ''.join(x)\\nprint(int(x,2))\\n\\n\", \"a=bin(int(input()))[2:]\\na=(6-len(a))*'0'+a\\nb=a[0]+a[5]+a[3]+a[2]+a[4]+a[1]\\nprint(int(b,2))\", \"a = int(input())\\n\\nbin_a = bin(a)[2:]\\nbin_a = (6 - len(bin_a)) * '0' + bin_a\\n\\nresult = bin_a[0] + bin_a[5] + bin_a[3] + bin_a[2] + bin_a[4] + bin_a[1]\\nprint(int(result, 2))\", \"#!/usr/bin/env python3\\n\\na = int(input())\\na = list(format(a, '#08b')[2:])\\nmap = [0, 5, 3, 2, 4, 1]\\na = [a[map[i]] for i in range(6)]\\na = ''.join(a)\\nprint(int(a, 2))\\n\", \"number = int(input())\\nreplacement = [16, 2, 8, 4, 1, 32]\\nresult = 0\\nfor k in range(6):\\n    if number % 2 == 1:\\n        result += replacement[k]\\n        number -= 1\\n    number /= 2\\nprint(result)\", \"a=int(input())\\nabin=format(a,'06b')\\n\\nl=[abin[0],abin[5],abin[3],abin[2],abin[4],abin[1]]\\nx=''.join(l)\\nprint(int(x,2))\", \"n=int(input())\\na=list(bin(n)[2:])\\na=['0']*(6-len(a))+a\\na[1],a[5]=a[5],a[1]\\na[2],a[3]=a[3],a[2]\\n#print(\\\"\\\".join(a))\\nprint(int(\\\"\\\".join(a),2))\", \"p = [0, 5, 3, 2, 4, 1]\\n# p = [0, 3, 5, 2, 4, 1]\\ns = bin(int(input()))[2:].zfill(6)\\nprint(int(\\\"\\\".join([s[x] for x in p]), 2))\\n\", \"p = { 0: 4, 1: 1, 2: 3, 3: 2, 4: 0, 5: 5 }\\nn = int(input())\\nres = 0\\nfor i in range(6):\\n    if (n & (1 << i)):\\n        res |= (1 << p[i])\\nprint(res)\", \"x=bin(int(input()))[2:]\\n\\nx=\\\"0\\\"*(6-len(x))+x\\nx1=list(x)\\ntemp=x1[1]\\nx1[1]=x1[5]\\nx1[5]=temp\\ntemp=x1[2]\\nx1[2]=x1[3]\\nx1[3]=temp\\nx2=\\\"\\\".join(x1)\\nprint(int(x2,2))\", \"n = int(input())\\ns = bin(n)[2:]\\nrem = 6-len(s)\\ns=\\\"0\\\"*rem+s\\nans = [0]*6\\nans[0]=s[0]\\nans[1]=s[5]\\nans[2]=s[3]\\nans[3]=s[2]\\nans[4]=s[4]\\nans[5]=s[1]\\nan = \\\"\\\".join(ans)\\nprint(int(an,2))\", \"'''\\n2 = 2^1\\n24 = 2^3*3^1\\n50 = 2^1*5^2\\n\\n2 = 10\\n5 = 101, 24 = 11000\\n35 = 100011, 50 = 110010\\n\\nAnd after happily lived ever they\\nand they lived happily ever after\\n\\n123456\\n164352\\n\\n2 = 000010\\n2 = 000010\\n\\n 5 = 000101\\n24 = 011000\\n\\n35 = 100011\\n50 = 110010\\n'''\\n\\nreplacement = [4, 1, 3, 2, 0, 5] + list(range(6, 64))\\nn = list('{:064b}'.format(int(input())))\\nn.reverse()\\n\\nans = list(n)\\nfor i in range(64):\\n    ans[i] = n[replacement[i]]\\nans.reverse()\\nprint(int(''.join(ans), 2))\\n\", \"a = int(input())\\na = bin(a)[2:]\\na = \\\"0\\\" * (6 - len(a)) + a\\np = [0, 5, 3, 2, 4, 1]\\nb = ['-'] * 6\\nfor i in range(6):\\n  b[i] = a[p[i]]\\nb = \\\"\\\".join(b)\\nprint(int(b, 2))\\n\", \"n = bin(int(input()))[2:].rjust(6, \\\"0\\\")\\nprint(int(n[0] + n[5] + n[3] + n[2] + n[4] + n[1], 2))\", \"n = int(input())\\nb = f'{n:b}'\\n\\nwhile len(b)<6:\\n    b = \\\"0\\\" + b\\n\\ns = b[0]+b[5]+b[3]+b[2]+b[4]+b[1]\\n\\nprint(int(s,2))\", \"import sys\\nimport atexit\\nimport io\\nfrom collections import defaultdict, Counter\\n\\ndef main():\\n    i = bin(int(input()))[2:]\\n    i =  ('0'*(6 - len(i))) + i\\n    i = ''.join(list(map(lambda x: i[x], [0,5,3,2,4,1])))\\n    print(int(i,2))\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"x=int(input())\\nA=[]\\nfor i in range(1,7):\\n    A.append(x//pow(2,7-i))\\n    x=x%pow(2,7-i)\\nA.append(x%2)\\n#print(A)\\n\\nnew=A[1]*pow(2,5)+A[6]*pow(2,4)+A[4]*pow(2,3)+A[3]*pow(2,2)+A[5]*pow(2,1)+A[2]\\nprint(new)\\n\\n\\n\\n\\n\", \"d = list(\\\"And after happily lived ever they\\\".split())\\nn = bin(int(input()))[2:]\\nn = \\\"0\\\" * (6 - len(n)) + n\\nm = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\\nprint(int('0b'+m, 2))\", \"x = int(input())\\n\\nr = [4, 1, 3, 2, 0, 5]\\n\\nans = 0\\nfor i in range(6):\\n    if x & (1 << i):\\n        ans |= (1 << r[i])\\n\\nprint(ans)\", \"b = bin(int(input()))[2:]\\nb=b[::-1]\\nval = [0 for i in range(6)]\\nfor c in range(len(b)):\\n\\tval[5-c]=b[c]\\n# print(val)\\n# val=val[::-1]\\n# print(val)\\nl=[0,5,3,2,4,1]\\nans = [0 for i in range(6)]\\nfor c in range(6):\\n\\tans[c]=val[l[c]]\\nprint(int(''.join(map(str,ans)),2))\", \"n=int(input())\\nb=''\\nn = \\\"{0:b}\\\".format(n)\\nif len(n)!=7:\\n    n = '0'*(7-len(n))+n\\n\\nb+=n[0]+n[1]+n[6]+n[4]+n[3]+n[5]+n[2]\\n\\nprint(int(b,2))\\n\", \"def to_bin(a):\\n    out = []\\n    while a >0:\\n        if a%2==1:out.append(1)\\n        else:out.append(0)\\n        a//=2\\n    while len(out)<6:\\n        out.append(0)\\n    return out\\ndef to_dec(a):\\n    c = 1\\n    out = 0\\n    for i in a:\\n        out += i*c\\n        c*=2\\n    return out\\na = int(input())\\nb = to_bin(a)\\nc =[]\\nc.append(b[4])\\nc.append(b[1])\\nc.append(b[3])\\nc.append(b[2])\\nc.append(b[0])\\nc.append(b[5])\\nprint(to_dec(c))\", \"n = int(input())\\nn = bin(n)[2:]\\nn = \\\"0\\\"*(6-len(n))+n\\n\\ns = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\\nprint(int(s,2))\", \"n = int(input())\\nme = [4, 1, 3, 2, 0, 5]\\n#0 3 5 2 4 1\\n#4 1 3 0 2 5\\n#0 5 3 1 4 2\\n#3 1 4 2 0 5\\nans = 0\\nfor _ in range(6):\\n    if (n % 2 == 1):\\n        ans += (2 ** me[_])\\n    n //= 2\\nprint(ans)\\n\", \"s = bin(int(input()))[2:].zfill(6)\\nl = []\\nfor i in [0, 5, 3, 2, 4, 1]:\\n    l.append(s[i])\\nprint(int(''.join(l), 2))\", \"n = int(input())\\na = (n >> 5) & 1\\nb = (n >> 4) & 1\\nc = (n >> 3) & 1\\nd = (n >> 2) & 1\\ne = (n >> 1) & 1\\nf = n & 1\\nprint(((((a*2+f)*2+d)*2+c)*2+e)*2+b)\\n\", \"n = bin(int(input()))[2:].rjust(6, '0')\\ns = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\\nprint(int(s, 2))\", \"# Python3 code to check if k-th bit \\n# of a given number is set or not \\n\\ndef isKthBitSet(n, k): \\n\\tif n & (1 << (k - 1)): \\n\\t\\treturn True\\n\\telse: \\n\\t\\treturn False\\n\\nx=int(input())\\nans=0\\nif(isKthBitSet(x,6)):ans+=2**5\\nif(isKthBitSet(x,5)):ans+=2**0\\nif(isKthBitSet(x,4)):ans+=2**2\\nif(isKthBitSet(x,3)):ans+=2**3\\nif(isKthBitSet(x,2)):ans+=2**1\\nif(isKthBitSet(x,1)):ans+=2**4\\nprint(ans)\", \"n = int(input())\\nn = bin(n)[2:]\\nwhile len(n) < 6:\\n\\tn = '0' + n\\n\\nres = list(n)\\n\\nres[1], res[5] = res[5] , res[1]\\nres[2], res[3] = res[3], res[2]\\n\\n\\nprint(int(''.join(res),2))\\n\", \"map = {0:0, 1:5, 2:3, 3:2, 4:4, 5:1}\\ns = \\\"{:>06b}\\\".format(int(input()))\\ns2 = [\\\"\\\"]*6\\nfor i in range(6):\\n\\ts2[map[i]]=s[i]\\nprint(int(\\\"\\\".join(s2), 2))\"]",
        "difficulty": "interview",
        "input": "2\n",
        "output": "",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1331/C"
    },
    {
        "id": 340,
        "task_id": 2432,
        "test_case_id": 2,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($0 \\le a \\le 63$).\n\n\n-----Output-----\n\nOutput a single number.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n2\n\nInput\n5\n\nOutput\n24\n\nInput\n35\n\nOutput\n50",
        "solutions": "[\"n = int(input())\\na = (n & 32) >> 5\\nb = (n & 16) >> 4\\nc = (n & 8) >> 3\\nd = (n & 4) >> 2\\ne = (n & 2) >> 1\\nf = n & 1\\n\\nprint(32 * a + 16 * f + 8 * d + 4 * c + 2 * e + b)\\n\", \"p = [1, 6, 4, 3, 5, 2]\\np.reverse()\\nfor i in range(6):\\n  p[i] = 6 - p[i]\\n\\n# print(p)\\n\\na = int(input())\\nb = [(a & (2**i))//(2**i) for i in range(6)]\\nc = [0] * 6\\nfor i in range(6):\\n  c[i] = b[p[i]]\\n\\n# print(b)\\n# print(c)\\nprint(sum([c[i] * (2**i) for i in range(6)]))\\n\\n# \\\"And after happily lived ever they\\\"\\n\", \"a = int(input())\\nans = 0\\nif a & (1 << 5):\\n    ans += 1 << 5\\nif a & (1 << 4):\\n    ans += 1 << 0\\nif a & (1 << 3):\\n    ans += 1 << 2\\nif a & (1 << 2):\\n    ans += 1 << 3\\nif a & (1 << 1):\\n    ans += 1 << 1\\nif a & (1 << 0):\\n    ans += 1 << 4\\nprint(ans)\", \"perm = [5, 0, 2, 3, 1, 4]\\nn = int(input())\\nans = 0\\nfor i in range(len(perm)):\\n\\tans = ans * 2 + ((n >> perm[i]) & 1)\\n\\nprint(ans)\", \"a=int(input())\\na=bin(a+128)\\nprint(32*int(a[4])+16*int(a[9])+8*int(a[7])+4*int(a[6])+2*int(a[8])+int(a[5]))\", \"b = bin(int(input()))[2:].zfill(6)\\n\\nprint(int(b[0]+b[5]+b[3]+b[2]+b[4]+b[1],2))\\n\", \"x = int(input())\\ny = 0\\nif x & 1: y = y | 16\\nif x & 2: y = y | 2\\nif x & 4: y = y | 8\\nif x & 8: y = y | 4\\nif x & 16: y = y | 1\\nif x & 32: y = y | 32\\nprint(y)\\n\", \"a = bin(int(input()))[2:].zfill(6)\\nb = ''.join([a[0], a[5], a[3], a[2], a[4], a[1]])\\nprint(int(b, base=2))\\n\", \"x = int(input())\\nprint((x&32) + (x&16)//16 + (x&8)//2 + (x&4)*2 + (x&2) + (x&1)*16)\\n\", \"# And after happily lived ever they\\n\\nn = int(input())\\nd = [0,5,3,2,4,1]\\n\\nr=0\\nfor dd in d:\\n    r=r*2 + bool(n&1<<(5-dd))\\n\\nprint (r)\", \"n=int(input())\\nc=bin(n)[2:]\\nwhile(len(c))<6:\\n    c='0'+c\\nd=\\\"\\\"\\nd=d+c[0]\\nd=d+c[5]\\nd=d+c[3]\\nd=d+c[2]\\nd=d+c[4]\\nd=d+c[1]\\nprint(int(d,2))\\n\", \"n = int(input(''))\\nans = 0\\ni = 0\\nlst = [4, 1, 3, 2, 0, 5]\\nwhile n > 0:\\n    ans += (n % 2) * 2 ** lst[i]\\n    i += 1\\n    n //=2\\nprint(ans)\", \"a = int (input())\\nprint((((a & 32) >> 0) + ((a & 16) >> 4) + ((a & 8) >> 1) + \\n       ((a & 4) << 1) + ((a & 2) >> 0) + ((a & 1) << 4)))\\n\", \"lip = [0, 5, 3, 2, 4, 1]\\nn = int(input())\\na = []\\nfor i in range(6):\\n    a.append(n%2)\\n    n //= 2\\na.reverse()\\nb = [0]*6\\nfor i in range(6):\\n    b[lip[i]] = a[i]\\nans = 0\\nk = 1\\n#print(a)\\n#print(b)\\nfor i in range(6):\\n    ans += k*b[-i - 1]\\n    k *= 2\\nprint(ans)\\n\", \"ans=0\\na=[4, 1, 3, 2, 0, 5]\\nx=int(input())\\nfor i in range(6):\\n    if(x & (1 << i)):\\n        ans += (1<<a[i])\\nprint(ans)\", \"num=int(input())\\nadd=0\\nif(num%32<16):\\n  if(num%2==1):\\n    add+=15\\nelse:\\n  if(num%2==0):\\n    add-=15\\nif(num%16<8):\\n  if(num%8>=4):\\n    add+=4\\nelse:\\n  if(num%8<4):\\n    add-=4\\nnum+=add\\nprint(num)\\n\", \"n = int(input())\\nn = list(bin(n)[2:])\\nn = (6-len(n))*[\\\"0\\\"]+n \\nn_t = n.copy()\\nn[1] = n_t[5]\\nn[2] = n_t[3]\\nn[3] = n_t[2]\\nn[4] = n_t[4]\\nn[5] = n_t[1]\\nprint(int(''.join(n),2))\", \"idx = [0, 5, 3, 2, 4, 1]\\nn = int(input())\\nb = bin(n)[2:]\\nb = '0'*(6 - len(b)) + b\\noutput_str = ''.join([b[i] for i in idx])\\nprint(int(output_str, 2))\\n\", \"a=bin(int(input()))[2:]\\na='0'*(6-len(a))+a\\na=list(a)\\na[0],a[1],a[2],a[3],a[4],a[5]=a[0],a[5],a[3],a[2],a[4],a[1]\\nprint(int(''.join(a),2))\", \"a = int(input(''))\\nb = bin(a)[2:]\\nb = '0'*(6-len(b))+b\\nans = b[0]+b[5]+b[3]+b[2]+b[4]+b[1]\\nprint(int('0b'+ans,2))\", \"T = int(input())\\nbit = []\\narr = [4,1,3,2,0,5]\\ns = 0\\nfor i in range(6):\\n\\tif T % 2 == 0:\\n\\t\\tT = T // 2\\n\\t\\tbit.append(0)\\n\\telse:\\n\\t\\tT = T // 2\\n\\t\\tbit.append(1)\\n\\t\\ts += 2**arr.index(i)\\nprint(s)\\n\", \"N = int(input())\\nb = []\\nfor i in range(6):\\n    N, r = divmod(N, 2)\\n    b.append(r)\\nans = 0\\nif b[0]: \\n    ans += 16\\nif b[1]:\\n    ans += 2\\nif b[2]:\\n    ans += 8\\nif b[3]:\\n    ans += 4\\nif b[4]:\\n    ans += 1\\nif b[5]:\\n    ans += 32\\nprint(ans)\", \"a = int(input())\\nmult = [32, 1, 4, 8, 2, 16]\\n\\nout = 0\\nfor i, c in enumerate(format(a, '#08b')[2:]):\\n    if c == '1':\\n        out += mult[i]\\n        \\nprint(out)\", \"s = bin(int(input()))[2:].zfill(6)\\nprint(int(s[0]+s[5]+s[3]+s[2]+s[4]+s[1],2))\\n\", \"'''from math import sqrt, ceil\\na = int(input())\\nfor i in range(2, ceil(sqrt(a)) + 1):\\n    if a % i == 0:\\n        print(i, end='')\\n        print(a//i)\\n'''\\n\\n\\na = int(input())\\ns = [1, 2, 4, 8, 16, 32]\\ns1 = ''\\ns2 = ''\\nfor i in s[::-1]:\\n    if a - i >= 0:\\n        a -= i\\n        s1 += '1'\\n    else:\\n        s1 += '0'\\ns2 = s1[0]\\ns2 += s1[5]\\ns2 += s1[3]\\ns2 += s1[2]\\ns2 += s1[4]\\ns2 += s1[1]\\nb = 0\\nfor i in range(6):\\n    b += int(s2[5 - i]) * s[i]\\n\\nprint(b)\", \"seq = bin(int(input()))[2:].rjust(6, '0')\\nprint(int(seq[0] + seq[5] + seq[3] + seq[2] + seq[4] + seq[1], 2))\", \"s = bin(int(input()))[2:]\\ns = '0' * (7 - len(s)) + s\\nres = list('0' * 7)\\n\\na = [0, 1, 6, 4, 3, 5, 2]\\nfor i in range(7):\\n    res[i] = s[a[i]]\\n\\nprint(int(''.join(res), 2))\", \"x = int(input())\\nx = bin(x)[2:]\\nx = list(x)\\nx = [\\\"0\\\"]*(6-len(x)) + x\\ntemp = \\tx[5]\\nx[5] = x[1]\\nx[1] = temp\\ntemp = x[2]\\nx[2] = x[3]\\nx[3] = temp\\nx = ''.join(x)\\nprint(int(x,2))\\n\\n\", \"a=bin(int(input()))[2:]\\na=(6-len(a))*'0'+a\\nb=a[0]+a[5]+a[3]+a[2]+a[4]+a[1]\\nprint(int(b,2))\", \"a = int(input())\\n\\nbin_a = bin(a)[2:]\\nbin_a = (6 - len(bin_a)) * '0' + bin_a\\n\\nresult = bin_a[0] + bin_a[5] + bin_a[3] + bin_a[2] + bin_a[4] + bin_a[1]\\nprint(int(result, 2))\", \"#!/usr/bin/env python3\\n\\na = int(input())\\na = list(format(a, '#08b')[2:])\\nmap = [0, 5, 3, 2, 4, 1]\\na = [a[map[i]] for i in range(6)]\\na = ''.join(a)\\nprint(int(a, 2))\\n\", \"number = int(input())\\nreplacement = [16, 2, 8, 4, 1, 32]\\nresult = 0\\nfor k in range(6):\\n    if number % 2 == 1:\\n        result += replacement[k]\\n        number -= 1\\n    number /= 2\\nprint(result)\", \"a=int(input())\\nabin=format(a,'06b')\\n\\nl=[abin[0],abin[5],abin[3],abin[2],abin[4],abin[1]]\\nx=''.join(l)\\nprint(int(x,2))\", \"n=int(input())\\na=list(bin(n)[2:])\\na=['0']*(6-len(a))+a\\na[1],a[5]=a[5],a[1]\\na[2],a[3]=a[3],a[2]\\n#print(\\\"\\\".join(a))\\nprint(int(\\\"\\\".join(a),2))\", \"p = [0, 5, 3, 2, 4, 1]\\n# p = [0, 3, 5, 2, 4, 1]\\ns = bin(int(input()))[2:].zfill(6)\\nprint(int(\\\"\\\".join([s[x] for x in p]), 2))\\n\", \"p = { 0: 4, 1: 1, 2: 3, 3: 2, 4: 0, 5: 5 }\\nn = int(input())\\nres = 0\\nfor i in range(6):\\n    if (n & (1 << i)):\\n        res |= (1 << p[i])\\nprint(res)\", \"x=bin(int(input()))[2:]\\n\\nx=\\\"0\\\"*(6-len(x))+x\\nx1=list(x)\\ntemp=x1[1]\\nx1[1]=x1[5]\\nx1[5]=temp\\ntemp=x1[2]\\nx1[2]=x1[3]\\nx1[3]=temp\\nx2=\\\"\\\".join(x1)\\nprint(int(x2,2))\", \"n = int(input())\\ns = bin(n)[2:]\\nrem = 6-len(s)\\ns=\\\"0\\\"*rem+s\\nans = [0]*6\\nans[0]=s[0]\\nans[1]=s[5]\\nans[2]=s[3]\\nans[3]=s[2]\\nans[4]=s[4]\\nans[5]=s[1]\\nan = \\\"\\\".join(ans)\\nprint(int(an,2))\", \"'''\\n2 = 2^1\\n24 = 2^3*3^1\\n50 = 2^1*5^2\\n\\n2 = 10\\n5 = 101, 24 = 11000\\n35 = 100011, 50 = 110010\\n\\nAnd after happily lived ever they\\nand they lived happily ever after\\n\\n123456\\n164352\\n\\n2 = 000010\\n2 = 000010\\n\\n 5 = 000101\\n24 = 011000\\n\\n35 = 100011\\n50 = 110010\\n'''\\n\\nreplacement = [4, 1, 3, 2, 0, 5] + list(range(6, 64))\\nn = list('{:064b}'.format(int(input())))\\nn.reverse()\\n\\nans = list(n)\\nfor i in range(64):\\n    ans[i] = n[replacement[i]]\\nans.reverse()\\nprint(int(''.join(ans), 2))\\n\", \"a = int(input())\\na = bin(a)[2:]\\na = \\\"0\\\" * (6 - len(a)) + a\\np = [0, 5, 3, 2, 4, 1]\\nb = ['-'] * 6\\nfor i in range(6):\\n  b[i] = a[p[i]]\\nb = \\\"\\\".join(b)\\nprint(int(b, 2))\\n\", \"n = bin(int(input()))[2:].rjust(6, \\\"0\\\")\\nprint(int(n[0] + n[5] + n[3] + n[2] + n[4] + n[1], 2))\", \"n = int(input())\\nb = f'{n:b}'\\n\\nwhile len(b)<6:\\n    b = \\\"0\\\" + b\\n\\ns = b[0]+b[5]+b[3]+b[2]+b[4]+b[1]\\n\\nprint(int(s,2))\", \"import sys\\nimport atexit\\nimport io\\nfrom collections import defaultdict, Counter\\n\\ndef main():\\n    i = bin(int(input()))[2:]\\n    i =  ('0'*(6 - len(i))) + i\\n    i = ''.join(list(map(lambda x: i[x], [0,5,3,2,4,1])))\\n    print(int(i,2))\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"x=int(input())\\nA=[]\\nfor i in range(1,7):\\n    A.append(x//pow(2,7-i))\\n    x=x%pow(2,7-i)\\nA.append(x%2)\\n#print(A)\\n\\nnew=A[1]*pow(2,5)+A[6]*pow(2,4)+A[4]*pow(2,3)+A[3]*pow(2,2)+A[5]*pow(2,1)+A[2]\\nprint(new)\\n\\n\\n\\n\\n\", \"d = list(\\\"And after happily lived ever they\\\".split())\\nn = bin(int(input()))[2:]\\nn = \\\"0\\\" * (6 - len(n)) + n\\nm = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\\nprint(int('0b'+m, 2))\", \"x = int(input())\\n\\nr = [4, 1, 3, 2, 0, 5]\\n\\nans = 0\\nfor i in range(6):\\n    if x & (1 << i):\\n        ans |= (1 << r[i])\\n\\nprint(ans)\", \"b = bin(int(input()))[2:]\\nb=b[::-1]\\nval = [0 for i in range(6)]\\nfor c in range(len(b)):\\n\\tval[5-c]=b[c]\\n# print(val)\\n# val=val[::-1]\\n# print(val)\\nl=[0,5,3,2,4,1]\\nans = [0 for i in range(6)]\\nfor c in range(6):\\n\\tans[c]=val[l[c]]\\nprint(int(''.join(map(str,ans)),2))\", \"n=int(input())\\nb=''\\nn = \\\"{0:b}\\\".format(n)\\nif len(n)!=7:\\n    n = '0'*(7-len(n))+n\\n\\nb+=n[0]+n[1]+n[6]+n[4]+n[3]+n[5]+n[2]\\n\\nprint(int(b,2))\\n\", \"def to_bin(a):\\n    out = []\\n    while a >0:\\n        if a%2==1:out.append(1)\\n        else:out.append(0)\\n        a//=2\\n    while len(out)<6:\\n        out.append(0)\\n    return out\\ndef to_dec(a):\\n    c = 1\\n    out = 0\\n    for i in a:\\n        out += i*c\\n        c*=2\\n    return out\\na = int(input())\\nb = to_bin(a)\\nc =[]\\nc.append(b[4])\\nc.append(b[1])\\nc.append(b[3])\\nc.append(b[2])\\nc.append(b[0])\\nc.append(b[5])\\nprint(to_dec(c))\", \"n = int(input())\\nn = bin(n)[2:]\\nn = \\\"0\\\"*(6-len(n))+n\\n\\ns = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\\nprint(int(s,2))\", \"n = int(input())\\nme = [4, 1, 3, 2, 0, 5]\\n#0 3 5 2 4 1\\n#4 1 3 0 2 5\\n#0 5 3 1 4 2\\n#3 1 4 2 0 5\\nans = 0\\nfor _ in range(6):\\n    if (n % 2 == 1):\\n        ans += (2 ** me[_])\\n    n //= 2\\nprint(ans)\\n\", \"s = bin(int(input()))[2:].zfill(6)\\nl = []\\nfor i in [0, 5, 3, 2, 4, 1]:\\n    l.append(s[i])\\nprint(int(''.join(l), 2))\", \"n = int(input())\\na = (n >> 5) & 1\\nb = (n >> 4) & 1\\nc = (n >> 3) & 1\\nd = (n >> 2) & 1\\ne = (n >> 1) & 1\\nf = n & 1\\nprint(((((a*2+f)*2+d)*2+c)*2+e)*2+b)\\n\", \"n = bin(int(input()))[2:].rjust(6, '0')\\ns = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\\nprint(int(s, 2))\", \"# Python3 code to check if k-th bit \\n# of a given number is set or not \\n\\ndef isKthBitSet(n, k): \\n\\tif n & (1 << (k - 1)): \\n\\t\\treturn True\\n\\telse: \\n\\t\\treturn False\\n\\nx=int(input())\\nans=0\\nif(isKthBitSet(x,6)):ans+=2**5\\nif(isKthBitSet(x,5)):ans+=2**0\\nif(isKthBitSet(x,4)):ans+=2**2\\nif(isKthBitSet(x,3)):ans+=2**3\\nif(isKthBitSet(x,2)):ans+=2**1\\nif(isKthBitSet(x,1)):ans+=2**4\\nprint(ans)\", \"n = int(input())\\nn = bin(n)[2:]\\nwhile len(n) < 6:\\n\\tn = '0' + n\\n\\nres = list(n)\\n\\nres[1], res[5] = res[5] , res[1]\\nres[2], res[3] = res[3], res[2]\\n\\n\\nprint(int(''.join(res),2))\\n\", \"map = {0:0, 1:5, 2:3, 3:2, 4:4, 5:1}\\ns = \\\"{:>06b}\\\".format(int(input()))\\ns2 = [\\\"\\\"]*6\\nfor i in range(6):\\n\\ts2[map[i]]=s[i]\\nprint(int(\\\"\\\".join(s2), 2))\"]",
        "difficulty": "interview",
        "input": "5\n",
        "output": "",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1331/C"
    },
    {
        "id": 341,
        "task_id": 2432,
        "test_case_id": 3,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($0 \\le a \\le 63$).\n\n\n-----Output-----\n\nOutput a single number.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n2\n\nInput\n5\n\nOutput\n24\n\nInput\n35\n\nOutput\n50",
        "solutions": "[\"n = int(input())\\na = (n & 32) >> 5\\nb = (n & 16) >> 4\\nc = (n & 8) >> 3\\nd = (n & 4) >> 2\\ne = (n & 2) >> 1\\nf = n & 1\\n\\nprint(32 * a + 16 * f + 8 * d + 4 * c + 2 * e + b)\\n\", \"p = [1, 6, 4, 3, 5, 2]\\np.reverse()\\nfor i in range(6):\\n  p[i] = 6 - p[i]\\n\\n# print(p)\\n\\na = int(input())\\nb = [(a & (2**i))//(2**i) for i in range(6)]\\nc = [0] * 6\\nfor i in range(6):\\n  c[i] = b[p[i]]\\n\\n# print(b)\\n# print(c)\\nprint(sum([c[i] * (2**i) for i in range(6)]))\\n\\n# \\\"And after happily lived ever they\\\"\\n\", \"a = int(input())\\nans = 0\\nif a & (1 << 5):\\n    ans += 1 << 5\\nif a & (1 << 4):\\n    ans += 1 << 0\\nif a & (1 << 3):\\n    ans += 1 << 2\\nif a & (1 << 2):\\n    ans += 1 << 3\\nif a & (1 << 1):\\n    ans += 1 << 1\\nif a & (1 << 0):\\n    ans += 1 << 4\\nprint(ans)\", \"perm = [5, 0, 2, 3, 1, 4]\\nn = int(input())\\nans = 0\\nfor i in range(len(perm)):\\n\\tans = ans * 2 + ((n >> perm[i]) & 1)\\n\\nprint(ans)\", \"a=int(input())\\na=bin(a+128)\\nprint(32*int(a[4])+16*int(a[9])+8*int(a[7])+4*int(a[6])+2*int(a[8])+int(a[5]))\", \"b = bin(int(input()))[2:].zfill(6)\\n\\nprint(int(b[0]+b[5]+b[3]+b[2]+b[4]+b[1],2))\\n\", \"x = int(input())\\ny = 0\\nif x & 1: y = y | 16\\nif x & 2: y = y | 2\\nif x & 4: y = y | 8\\nif x & 8: y = y | 4\\nif x & 16: y = y | 1\\nif x & 32: y = y | 32\\nprint(y)\\n\", \"a = bin(int(input()))[2:].zfill(6)\\nb = ''.join([a[0], a[5], a[3], a[2], a[4], a[1]])\\nprint(int(b, base=2))\\n\", \"x = int(input())\\nprint((x&32) + (x&16)//16 + (x&8)//2 + (x&4)*2 + (x&2) + (x&1)*16)\\n\", \"# And after happily lived ever they\\n\\nn = int(input())\\nd = [0,5,3,2,4,1]\\n\\nr=0\\nfor dd in d:\\n    r=r*2 + bool(n&1<<(5-dd))\\n\\nprint (r)\", \"n=int(input())\\nc=bin(n)[2:]\\nwhile(len(c))<6:\\n    c='0'+c\\nd=\\\"\\\"\\nd=d+c[0]\\nd=d+c[5]\\nd=d+c[3]\\nd=d+c[2]\\nd=d+c[4]\\nd=d+c[1]\\nprint(int(d,2))\\n\", \"n = int(input(''))\\nans = 0\\ni = 0\\nlst = [4, 1, 3, 2, 0, 5]\\nwhile n > 0:\\n    ans += (n % 2) * 2 ** lst[i]\\n    i += 1\\n    n //=2\\nprint(ans)\", \"a = int (input())\\nprint((((a & 32) >> 0) + ((a & 16) >> 4) + ((a & 8) >> 1) + \\n       ((a & 4) << 1) + ((a & 2) >> 0) + ((a & 1) << 4)))\\n\", \"lip = [0, 5, 3, 2, 4, 1]\\nn = int(input())\\na = []\\nfor i in range(6):\\n    a.append(n%2)\\n    n //= 2\\na.reverse()\\nb = [0]*6\\nfor i in range(6):\\n    b[lip[i]] = a[i]\\nans = 0\\nk = 1\\n#print(a)\\n#print(b)\\nfor i in range(6):\\n    ans += k*b[-i - 1]\\n    k *= 2\\nprint(ans)\\n\", \"ans=0\\na=[4, 1, 3, 2, 0, 5]\\nx=int(input())\\nfor i in range(6):\\n    if(x & (1 << i)):\\n        ans += (1<<a[i])\\nprint(ans)\", \"num=int(input())\\nadd=0\\nif(num%32<16):\\n  if(num%2==1):\\n    add+=15\\nelse:\\n  if(num%2==0):\\n    add-=15\\nif(num%16<8):\\n  if(num%8>=4):\\n    add+=4\\nelse:\\n  if(num%8<4):\\n    add-=4\\nnum+=add\\nprint(num)\\n\", \"n = int(input())\\nn = list(bin(n)[2:])\\nn = (6-len(n))*[\\\"0\\\"]+n \\nn_t = n.copy()\\nn[1] = n_t[5]\\nn[2] = n_t[3]\\nn[3] = n_t[2]\\nn[4] = n_t[4]\\nn[5] = n_t[1]\\nprint(int(''.join(n),2))\", \"idx = [0, 5, 3, 2, 4, 1]\\nn = int(input())\\nb = bin(n)[2:]\\nb = '0'*(6 - len(b)) + b\\noutput_str = ''.join([b[i] for i in idx])\\nprint(int(output_str, 2))\\n\", \"a=bin(int(input()))[2:]\\na='0'*(6-len(a))+a\\na=list(a)\\na[0],a[1],a[2],a[3],a[4],a[5]=a[0],a[5],a[3],a[2],a[4],a[1]\\nprint(int(''.join(a),2))\", \"a = int(input(''))\\nb = bin(a)[2:]\\nb = '0'*(6-len(b))+b\\nans = b[0]+b[5]+b[3]+b[2]+b[4]+b[1]\\nprint(int('0b'+ans,2))\", \"T = int(input())\\nbit = []\\narr = [4,1,3,2,0,5]\\ns = 0\\nfor i in range(6):\\n\\tif T % 2 == 0:\\n\\t\\tT = T // 2\\n\\t\\tbit.append(0)\\n\\telse:\\n\\t\\tT = T // 2\\n\\t\\tbit.append(1)\\n\\t\\ts += 2**arr.index(i)\\nprint(s)\\n\", \"N = int(input())\\nb = []\\nfor i in range(6):\\n    N, r = divmod(N, 2)\\n    b.append(r)\\nans = 0\\nif b[0]: \\n    ans += 16\\nif b[1]:\\n    ans += 2\\nif b[2]:\\n    ans += 8\\nif b[3]:\\n    ans += 4\\nif b[4]:\\n    ans += 1\\nif b[5]:\\n    ans += 32\\nprint(ans)\", \"a = int(input())\\nmult = [32, 1, 4, 8, 2, 16]\\n\\nout = 0\\nfor i, c in enumerate(format(a, '#08b')[2:]):\\n    if c == '1':\\n        out += mult[i]\\n        \\nprint(out)\", \"s = bin(int(input()))[2:].zfill(6)\\nprint(int(s[0]+s[5]+s[3]+s[2]+s[4]+s[1],2))\\n\", \"'''from math import sqrt, ceil\\na = int(input())\\nfor i in range(2, ceil(sqrt(a)) + 1):\\n    if a % i == 0:\\n        print(i, end='')\\n        print(a//i)\\n'''\\n\\n\\na = int(input())\\ns = [1, 2, 4, 8, 16, 32]\\ns1 = ''\\ns2 = ''\\nfor i in s[::-1]:\\n    if a - i >= 0:\\n        a -= i\\n        s1 += '1'\\n    else:\\n        s1 += '0'\\ns2 = s1[0]\\ns2 += s1[5]\\ns2 += s1[3]\\ns2 += s1[2]\\ns2 += s1[4]\\ns2 += s1[1]\\nb = 0\\nfor i in range(6):\\n    b += int(s2[5 - i]) * s[i]\\n\\nprint(b)\", \"seq = bin(int(input()))[2:].rjust(6, '0')\\nprint(int(seq[0] + seq[5] + seq[3] + seq[2] + seq[4] + seq[1], 2))\", \"s = bin(int(input()))[2:]\\ns = '0' * (7 - len(s)) + s\\nres = list('0' * 7)\\n\\na = [0, 1, 6, 4, 3, 5, 2]\\nfor i in range(7):\\n    res[i] = s[a[i]]\\n\\nprint(int(''.join(res), 2))\", \"x = int(input())\\nx = bin(x)[2:]\\nx = list(x)\\nx = [\\\"0\\\"]*(6-len(x)) + x\\ntemp = \\tx[5]\\nx[5] = x[1]\\nx[1] = temp\\ntemp = x[2]\\nx[2] = x[3]\\nx[3] = temp\\nx = ''.join(x)\\nprint(int(x,2))\\n\\n\", \"a=bin(int(input()))[2:]\\na=(6-len(a))*'0'+a\\nb=a[0]+a[5]+a[3]+a[2]+a[4]+a[1]\\nprint(int(b,2))\", \"a = int(input())\\n\\nbin_a = bin(a)[2:]\\nbin_a = (6 - len(bin_a)) * '0' + bin_a\\n\\nresult = bin_a[0] + bin_a[5] + bin_a[3] + bin_a[2] + bin_a[4] + bin_a[1]\\nprint(int(result, 2))\", \"#!/usr/bin/env python3\\n\\na = int(input())\\na = list(format(a, '#08b')[2:])\\nmap = [0, 5, 3, 2, 4, 1]\\na = [a[map[i]] for i in range(6)]\\na = ''.join(a)\\nprint(int(a, 2))\\n\", \"number = int(input())\\nreplacement = [16, 2, 8, 4, 1, 32]\\nresult = 0\\nfor k in range(6):\\n    if number % 2 == 1:\\n        result += replacement[k]\\n        number -= 1\\n    number /= 2\\nprint(result)\", \"a=int(input())\\nabin=format(a,'06b')\\n\\nl=[abin[0],abin[5],abin[3],abin[2],abin[4],abin[1]]\\nx=''.join(l)\\nprint(int(x,2))\", \"n=int(input())\\na=list(bin(n)[2:])\\na=['0']*(6-len(a))+a\\na[1],a[5]=a[5],a[1]\\na[2],a[3]=a[3],a[2]\\n#print(\\\"\\\".join(a))\\nprint(int(\\\"\\\".join(a),2))\", \"p = [0, 5, 3, 2, 4, 1]\\n# p = [0, 3, 5, 2, 4, 1]\\ns = bin(int(input()))[2:].zfill(6)\\nprint(int(\\\"\\\".join([s[x] for x in p]), 2))\\n\", \"p = { 0: 4, 1: 1, 2: 3, 3: 2, 4: 0, 5: 5 }\\nn = int(input())\\nres = 0\\nfor i in range(6):\\n    if (n & (1 << i)):\\n        res |= (1 << p[i])\\nprint(res)\", \"x=bin(int(input()))[2:]\\n\\nx=\\\"0\\\"*(6-len(x))+x\\nx1=list(x)\\ntemp=x1[1]\\nx1[1]=x1[5]\\nx1[5]=temp\\ntemp=x1[2]\\nx1[2]=x1[3]\\nx1[3]=temp\\nx2=\\\"\\\".join(x1)\\nprint(int(x2,2))\", \"n = int(input())\\ns = bin(n)[2:]\\nrem = 6-len(s)\\ns=\\\"0\\\"*rem+s\\nans = [0]*6\\nans[0]=s[0]\\nans[1]=s[5]\\nans[2]=s[3]\\nans[3]=s[2]\\nans[4]=s[4]\\nans[5]=s[1]\\nan = \\\"\\\".join(ans)\\nprint(int(an,2))\", \"'''\\n2 = 2^1\\n24 = 2^3*3^1\\n50 = 2^1*5^2\\n\\n2 = 10\\n5 = 101, 24 = 11000\\n35 = 100011, 50 = 110010\\n\\nAnd after happily lived ever they\\nand they lived happily ever after\\n\\n123456\\n164352\\n\\n2 = 000010\\n2 = 000010\\n\\n 5 = 000101\\n24 = 011000\\n\\n35 = 100011\\n50 = 110010\\n'''\\n\\nreplacement = [4, 1, 3, 2, 0, 5] + list(range(6, 64))\\nn = list('{:064b}'.format(int(input())))\\nn.reverse()\\n\\nans = list(n)\\nfor i in range(64):\\n    ans[i] = n[replacement[i]]\\nans.reverse()\\nprint(int(''.join(ans), 2))\\n\", \"a = int(input())\\na = bin(a)[2:]\\na = \\\"0\\\" * (6 - len(a)) + a\\np = [0, 5, 3, 2, 4, 1]\\nb = ['-'] * 6\\nfor i in range(6):\\n  b[i] = a[p[i]]\\nb = \\\"\\\".join(b)\\nprint(int(b, 2))\\n\", \"n = bin(int(input()))[2:].rjust(6, \\\"0\\\")\\nprint(int(n[0] + n[5] + n[3] + n[2] + n[4] + n[1], 2))\", \"n = int(input())\\nb = f'{n:b}'\\n\\nwhile len(b)<6:\\n    b = \\\"0\\\" + b\\n\\ns = b[0]+b[5]+b[3]+b[2]+b[4]+b[1]\\n\\nprint(int(s,2))\", \"import sys\\nimport atexit\\nimport io\\nfrom collections import defaultdict, Counter\\n\\ndef main():\\n    i = bin(int(input()))[2:]\\n    i =  ('0'*(6 - len(i))) + i\\n    i = ''.join(list(map(lambda x: i[x], [0,5,3,2,4,1])))\\n    print(int(i,2))\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"x=int(input())\\nA=[]\\nfor i in range(1,7):\\n    A.append(x//pow(2,7-i))\\n    x=x%pow(2,7-i)\\nA.append(x%2)\\n#print(A)\\n\\nnew=A[1]*pow(2,5)+A[6]*pow(2,4)+A[4]*pow(2,3)+A[3]*pow(2,2)+A[5]*pow(2,1)+A[2]\\nprint(new)\\n\\n\\n\\n\\n\", \"d = list(\\\"And after happily lived ever they\\\".split())\\nn = bin(int(input()))[2:]\\nn = \\\"0\\\" * (6 - len(n)) + n\\nm = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\\nprint(int('0b'+m, 2))\", \"x = int(input())\\n\\nr = [4, 1, 3, 2, 0, 5]\\n\\nans = 0\\nfor i in range(6):\\n    if x & (1 << i):\\n        ans |= (1 << r[i])\\n\\nprint(ans)\", \"b = bin(int(input()))[2:]\\nb=b[::-1]\\nval = [0 for i in range(6)]\\nfor c in range(len(b)):\\n\\tval[5-c]=b[c]\\n# print(val)\\n# val=val[::-1]\\n# print(val)\\nl=[0,5,3,2,4,1]\\nans = [0 for i in range(6)]\\nfor c in range(6):\\n\\tans[c]=val[l[c]]\\nprint(int(''.join(map(str,ans)),2))\", \"n=int(input())\\nb=''\\nn = \\\"{0:b}\\\".format(n)\\nif len(n)!=7:\\n    n = '0'*(7-len(n))+n\\n\\nb+=n[0]+n[1]+n[6]+n[4]+n[3]+n[5]+n[2]\\n\\nprint(int(b,2))\\n\", \"def to_bin(a):\\n    out = []\\n    while a >0:\\n        if a%2==1:out.append(1)\\n        else:out.append(0)\\n        a//=2\\n    while len(out)<6:\\n        out.append(0)\\n    return out\\ndef to_dec(a):\\n    c = 1\\n    out = 0\\n    for i in a:\\n        out += i*c\\n        c*=2\\n    return out\\na = int(input())\\nb = to_bin(a)\\nc =[]\\nc.append(b[4])\\nc.append(b[1])\\nc.append(b[3])\\nc.append(b[2])\\nc.append(b[0])\\nc.append(b[5])\\nprint(to_dec(c))\", \"n = int(input())\\nn = bin(n)[2:]\\nn = \\\"0\\\"*(6-len(n))+n\\n\\ns = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\\nprint(int(s,2))\", \"n = int(input())\\nme = [4, 1, 3, 2, 0, 5]\\n#0 3 5 2 4 1\\n#4 1 3 0 2 5\\n#0 5 3 1 4 2\\n#3 1 4 2 0 5\\nans = 0\\nfor _ in range(6):\\n    if (n % 2 == 1):\\n        ans += (2 ** me[_])\\n    n //= 2\\nprint(ans)\\n\", \"s = bin(int(input()))[2:].zfill(6)\\nl = []\\nfor i in [0, 5, 3, 2, 4, 1]:\\n    l.append(s[i])\\nprint(int(''.join(l), 2))\", \"n = int(input())\\na = (n >> 5) & 1\\nb = (n >> 4) & 1\\nc = (n >> 3) & 1\\nd = (n >> 2) & 1\\ne = (n >> 1) & 1\\nf = n & 1\\nprint(((((a*2+f)*2+d)*2+c)*2+e)*2+b)\\n\", \"n = bin(int(input()))[2:].rjust(6, '0')\\ns = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\\nprint(int(s, 2))\", \"# Python3 code to check if k-th bit \\n# of a given number is set or not \\n\\ndef isKthBitSet(n, k): \\n\\tif n & (1 << (k - 1)): \\n\\t\\treturn True\\n\\telse: \\n\\t\\treturn False\\n\\nx=int(input())\\nans=0\\nif(isKthBitSet(x,6)):ans+=2**5\\nif(isKthBitSet(x,5)):ans+=2**0\\nif(isKthBitSet(x,4)):ans+=2**2\\nif(isKthBitSet(x,3)):ans+=2**3\\nif(isKthBitSet(x,2)):ans+=2**1\\nif(isKthBitSet(x,1)):ans+=2**4\\nprint(ans)\", \"n = int(input())\\nn = bin(n)[2:]\\nwhile len(n) < 6:\\n\\tn = '0' + n\\n\\nres = list(n)\\n\\nres[1], res[5] = res[5] , res[1]\\nres[2], res[3] = res[3], res[2]\\n\\n\\nprint(int(''.join(res),2))\\n\", \"map = {0:0, 1:5, 2:3, 3:2, 4:4, 5:1}\\ns = \\\"{:>06b}\\\".format(int(input()))\\ns2 = [\\\"\\\"]*6\\nfor i in range(6):\\n\\ts2[map[i]]=s[i]\\nprint(int(\\\"\\\".join(s2), 2))\"]",
        "difficulty": "interview",
        "input": "35\n",
        "output": "",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1331/C"
    },
    {
        "id": 342,
        "task_id": 2687,
        "test_case_id": 1,
        "question": "Knights' tournaments were quite popular in the Middle Ages. A lot of boys were dreaming of becoming a knight, while a lot of girls were dreaming of marrying a knight on a white horse.\n\nIn this problem we consider one of these tournaments. \n\nLet's us call a tournament binary, if it runs according to the scheme described below:\n\n- Exactly N knights take part in the tournament, N=2K for some integer K > 0.\n\t\t\n- Each knight has a unique skill called strength, described as an integer from the interval [1, N].\n\t\t\n- Initially, all the knights are standing in a line, waiting for a battle. Since all their strengths are unique, each initial configuration can be described as a permutation of numbers from 1 to N.\n\t\t\n- There are exactly K rounds in the tournament, 2K - i + 1 knights take part in the i'th round. The K'th round is called the final.\n\t\t\n- The i'th round runs in the following way: for each positive integer j ≤ 2K - i happens a battle between a knight on the 2∙j'th position and a knight on the 2∙j+1'th position. The strongest of two continues his tournament, taking the j'th position on the next round, while the weakest of two is forced to leave.\n\t\t\n- The only knight, who has won K rounds, is the winner. The only knight, who has won K - 1 rounds, but lost the final, is the runner-up.   \n\t\n\nAs you can see from the scheme, the winner is always the same, an initial configuration doesn't change anything. So, your task is to determine chances of each knight to appear in the final.\n\nFormally, for each knight you need to count the number of initial configurations, which will lead him to the final. Since the number can be extremly huge, you are asked to do all the calculations under modulo 109 + 9.\n\n-----Input-----\n\nThe first line contains the only integer K, denoting the number of rounds of the tournament.\n\n-----Output-----\nOutput should consist of 2K lines. The i'th line should contain the number of initial configurations, which lead the participant with strength equals to i to the final.\n\n-----Constraints-----\n1 ≤ K < 20\n\n\n-----Examples-----\nInput:\n1\n\nOutput:\n2\n2\n\nInput:\n2\n\nOutput:\n0\n8\n16\n24\n\n-----Explanation-----\n\nIn the first example we have N=2 knights. Let's consider each initial configuration that could appear and simulate the tournament.\n\n(1, 2) -> (2)\n\n(2, 1) -> (2)\n\nIn the second example we have N=4 knights. Let's consider some initial configurations that could appear and simulate the tournament.\n\n(1, 2, 3, 4) -> (2, 4) -> (4)\n\n(3, 2, 4, 1) -> (3, 4) -> (4)\n\n(4, 1, 3, 2) -> (4, 3) -> (4)",
        "solutions": "[\"# cook your dish here\\nmod = 1000000009\\nimport math\\nK = int(input())\\nN = 2 ** K\\ntemp1 = N//2\\nfact = math.factorial((N/2-1))%mod\\ndiv = ((fact **2) * temp1)*N%mod\\ntemp2 = 1\\nfor i in range(1,N+1):\\n    if i < N/2:\\n        print(\\\"0\\\")\\n    else:\\n        print(div)\\n        div = (((div * pow(temp2,mod-2,mod))%mod)*temp1)%mod\\n        temp1 += 1\\n        temp2+= 1\", \"# cook your dish here\\nmod = 1000000009\\nimport math\\nK = int(input())\\nN = 2 ** K\\ntemp1 = N//2\\nfact = math.factorial((N/2-1))%mod\\ndiv = ((fact **2) * temp1)*N%mod\\ntemp2 = 1\\nfor i in range(1,N+1):\\n    if i < N/2:\\n        print(\\\"0\\\")\\n    else:\\n        print(div)\\n        div = (((div * pow(temp2,mod-2,mod))%mod)*temp1)%mod\\n        temp1 += 1\\n        temp2+= 1\"]",
        "difficulty": "interview",
        "input": [
            "1",
            "",
            ""
        ],
        "output": [
            "2",
            "2"
        ],
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://www.codechef.com/problems/BINTOUR"
    },
    {
        "id": 343,
        "task_id": 2687,
        "test_case_id": 2,
        "question": "Knights' tournaments were quite popular in the Middle Ages. A lot of boys were dreaming of becoming a knight, while a lot of girls were dreaming of marrying a knight on a white horse.\n\nIn this problem we consider one of these tournaments. \n\nLet's us call a tournament binary, if it runs according to the scheme described below:\n\n- Exactly N knights take part in the tournament, N=2K for some integer K > 0.\n\t\t\n- Each knight has a unique skill called strength, described as an integer from the interval [1, N].\n\t\t\n- Initially, all the knights are standing in a line, waiting for a battle. Since all their strengths are unique, each initial configuration can be described as a permutation of numbers from 1 to N.\n\t\t\n- There are exactly K rounds in the tournament, 2K - i + 1 knights take part in the i'th round. The K'th round is called the final.\n\t\t\n- The i'th round runs in the following way: for each positive integer j ≤ 2K - i happens a battle between a knight on the 2∙j'th position and a knight on the 2∙j+1'th position. The strongest of two continues his tournament, taking the j'th position on the next round, while the weakest of two is forced to leave.\n\t\t\n- The only knight, who has won K rounds, is the winner. The only knight, who has won K - 1 rounds, but lost the final, is the runner-up.   \n\t\n\nAs you can see from the scheme, the winner is always the same, an initial configuration doesn't change anything. So, your task is to determine chances of each knight to appear in the final.\n\nFormally, for each knight you need to count the number of initial configurations, which will lead him to the final. Since the number can be extremly huge, you are asked to do all the calculations under modulo 109 + 9.\n\n-----Input-----\n\nThe first line contains the only integer K, denoting the number of rounds of the tournament.\n\n-----Output-----\nOutput should consist of 2K lines. The i'th line should contain the number of initial configurations, which lead the participant with strength equals to i to the final.\n\n-----Constraints-----\n1 ≤ K < 20\n\n\n-----Examples-----\nInput:\n1\n\nOutput:\n2\n2\n\nInput:\n2\n\nOutput:\n0\n8\n16\n24\n\n-----Explanation-----\n\nIn the first example we have N=2 knights. Let's consider each initial configuration that could appear and simulate the tournament.\n\n(1, 2) -> (2)\n\n(2, 1) -> (2)\n\nIn the second example we have N=4 knights. Let's consider some initial configurations that could appear and simulate the tournament.\n\n(1, 2, 3, 4) -> (2, 4) -> (4)\n\n(3, 2, 4, 1) -> (3, 4) -> (4)\n\n(4, 1, 3, 2) -> (4, 3) -> (4)",
        "solutions": "[\"# cook your dish here\\nmod = 1000000009\\nimport math\\nK = int(input())\\nN = 2 ** K\\ntemp1 = N//2\\nfact = math.factorial((N/2-1))%mod\\ndiv = ((fact **2) * temp1)*N%mod\\ntemp2 = 1\\nfor i in range(1,N+1):\\n    if i < N/2:\\n        print(\\\"0\\\")\\n    else:\\n        print(div)\\n        div = (((div * pow(temp2,mod-2,mod))%mod)*temp1)%mod\\n        temp1 += 1\\n        temp2+= 1\", \"# cook your dish here\\nmod = 1000000009\\nimport math\\nK = int(input())\\nN = 2 ** K\\ntemp1 = N//2\\nfact = math.factorial((N/2-1))%mod\\ndiv = ((fact **2) * temp1)*N%mod\\ntemp2 = 1\\nfor i in range(1,N+1):\\n    if i < N/2:\\n        print(\\\"0\\\")\\n    else:\\n        print(div)\\n        div = (((div * pow(temp2,mod-2,mod))%mod)*temp1)%mod\\n        temp1 += 1\\n        temp2+= 1\"]",
        "difficulty": "interview",
        "input": [
            "2",
            "",
            ""
        ],
        "output": [
            "0",
            "8",
            "16",
            "24"
        ],
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://www.codechef.com/problems/BINTOUR"
    },
    {
        "id": 344,
        "task_id": 2818,
        "test_case_id": 1,
        "question": "There are $N$ balloons floating in the air in a large room, lined up from left to right. Young Perica likes to play with arrows and practice his hunting abilities. He shoots an arrow from the left to the right side of the room from an arbitrary height he chooses. The arrow moves from left to right, at a chosen height $H$ until it finds a balloon. The moment when an arrow touches a balloon, the balloon pops and disappears and the arrow continues its way from left to right at a height decreased by $1$. Therefore, if the arrow was moving at height $H$, after popping the balloon it travels on height $H-1$.\n\nOur hero’s goal is to pop all the balloons using as little arrows as possible.\n\n-----Input-----\nThe first line of input contains the integer $N$ ($1 \\leq N \\leq 1\\ 000\\ 000$). The second line of input contains an array of $N$ integers $H_ i$. Each integer $H_ i$ ($1 \\leq H_ i \\leq 1\\ 000\\ 000$) is the height at which the $i$-th balloon floats, respectively from left to right.\n\n-----Output-----\nThe first and only line of output must contain the minimal number of times Pero needs to shoot an arrow so that all balloons are popped.\n\n-----Examples-----\nSample Input 1:\n5\n2 1 5 4 3\nSample Output 1:\n2\n\nSample Input 2:\n5\n1 2 3 4 5\nSample Output 2:\n5",
        "solutions": "",
        "difficulty": "interview",
        "input": "5\n2 1 5 4 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/baloni"
    },
    {
        "id": 345,
        "task_id": 2818,
        "test_case_id": 2,
        "question": "There are $N$ balloons floating in the air in a large room, lined up from left to right. Young Perica likes to play with arrows and practice his hunting abilities. He shoots an arrow from the left to the right side of the room from an arbitrary height he chooses. The arrow moves from left to right, at a chosen height $H$ until it finds a balloon. The moment when an arrow touches a balloon, the balloon pops and disappears and the arrow continues its way from left to right at a height decreased by $1$. Therefore, if the arrow was moving at height $H$, after popping the balloon it travels on height $H-1$.\n\nOur hero’s goal is to pop all the balloons using as little arrows as possible.\n\n-----Input-----\nThe first line of input contains the integer $N$ ($1 \\leq N \\leq 1\\ 000\\ 000$). The second line of input contains an array of $N$ integers $H_ i$. Each integer $H_ i$ ($1 \\leq H_ i \\leq 1\\ 000\\ 000$) is the height at which the $i$-th balloon floats, respectively from left to right.\n\n-----Output-----\nThe first and only line of output must contain the minimal number of times Pero needs to shoot an arrow so that all balloons are popped.\n\n-----Examples-----\nSample Input 1:\n5\n2 1 5 4 3\nSample Output 1:\n2\n\nSample Input 2:\n5\n1 2 3 4 5\nSample Output 2:\n5",
        "solutions": "",
        "difficulty": "interview",
        "input": "5\n1 2 3 4 5\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/baloni"
    },
    {
        "id": 346,
        "task_id": 2818,
        "test_case_id": 3,
        "question": "There are $N$ balloons floating in the air in a large room, lined up from left to right. Young Perica likes to play with arrows and practice his hunting abilities. He shoots an arrow from the left to the right side of the room from an arbitrary height he chooses. The arrow moves from left to right, at a chosen height $H$ until it finds a balloon. The moment when an arrow touches a balloon, the balloon pops and disappears and the arrow continues its way from left to right at a height decreased by $1$. Therefore, if the arrow was moving at height $H$, after popping the balloon it travels on height $H-1$.\n\nOur hero’s goal is to pop all the balloons using as little arrows as possible.\n\n-----Input-----\nThe first line of input contains the integer $N$ ($1 \\leq N \\leq 1\\ 000\\ 000$). The second line of input contains an array of $N$ integers $H_ i$. Each integer $H_ i$ ($1 \\leq H_ i \\leq 1\\ 000\\ 000$) is the height at which the $i$-th balloon floats, respectively from left to right.\n\n-----Output-----\nThe first and only line of output must contain the minimal number of times Pero needs to shoot an arrow so that all balloons are popped.\n\n-----Examples-----\nSample Input 1:\n5\n2 1 5 4 3\nSample Output 1:\n2\n\nSample Input 2:\n5\n1 2 3 4 5\nSample Output 2:\n5",
        "solutions": "",
        "difficulty": "interview",
        "input": "5\n4 5 2 1 4\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/baloni"
    },
    {
        "id": 347,
        "task_id": 3024,
        "test_case_id": 1,
        "question": "Let $s$ be a given string of up to $10^6$ digits. Find the maximal $k$ for which it is possible to partition $s$ into $k$ consecutive contiguous substrings, such that the $k$ parts form a palindrome. More precisely, we say that strings $s_0, s_1, \\dots , s_{k-1}$ form a palindrome if $s_ i = s_{k-1-i}$ for all $0\\leq i < k$.\n\nIn the first sample case, we can split the string 652526 into $4$ parts as 6|52|52|6, and these parts together form a palindrome. It turns out that it is impossible to split this input into more than $4$ parts while still making sure the parts form a palindrome.\n\n-----Input-----\n - A nonempty string of up to $10^6$ digits.\n\n-----Output-----\n - Print the maximal value of $k$ on a single line.\n\n-----Examples-----\nSample Input 1:\n652526\nSample Output 1:\n4\n\nSample Input 2:\n12121131221\nSample Output 2:\n7\n\nSample Input 3:\n123456789\nSample Output 3:\n1",
        "solutions": "",
        "difficulty": "competition",
        "input": "652526\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/isomorphicinversion"
    },
    {
        "id": 348,
        "task_id": 3024,
        "test_case_id": 2,
        "question": "Let $s$ be a given string of up to $10^6$ digits. Find the maximal $k$ for which it is possible to partition $s$ into $k$ consecutive contiguous substrings, such that the $k$ parts form a palindrome. More precisely, we say that strings $s_0, s_1, \\dots , s_{k-1}$ form a palindrome if $s_ i = s_{k-1-i}$ for all $0\\leq i < k$.\n\nIn the first sample case, we can split the string 652526 into $4$ parts as 6|52|52|6, and these parts together form a palindrome. It turns out that it is impossible to split this input into more than $4$ parts while still making sure the parts form a palindrome.\n\n-----Input-----\n - A nonempty string of up to $10^6$ digits.\n\n-----Output-----\n - Print the maximal value of $k$ on a single line.\n\n-----Examples-----\nSample Input 1:\n652526\nSample Output 1:\n4\n\nSample Input 2:\n12121131221\nSample Output 2:\n7\n\nSample Input 3:\n123456789\nSample Output 3:\n1",
        "solutions": "",
        "difficulty": "competition",
        "input": "12121131221\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/isomorphicinversion"
    },
    {
        "id": 349,
        "task_id": 3024,
        "test_case_id": 3,
        "question": "Let $s$ be a given string of up to $10^6$ digits. Find the maximal $k$ for which it is possible to partition $s$ into $k$ consecutive contiguous substrings, such that the $k$ parts form a palindrome. More precisely, we say that strings $s_0, s_1, \\dots , s_{k-1}$ form a palindrome if $s_ i = s_{k-1-i}$ for all $0\\leq i < k$.\n\nIn the first sample case, we can split the string 652526 into $4$ parts as 6|52|52|6, and these parts together form a palindrome. It turns out that it is impossible to split this input into more than $4$ parts while still making sure the parts form a palindrome.\n\n-----Input-----\n - A nonempty string of up to $10^6$ digits.\n\n-----Output-----\n - Print the maximal value of $k$ on a single line.\n\n-----Examples-----\nSample Input 1:\n652526\nSample Output 1:\n4\n\nSample Input 2:\n12121131221\nSample Output 2:\n7\n\nSample Input 3:\n123456789\nSample Output 3:\n1",
        "solutions": "",
        "difficulty": "competition",
        "input": "123456789\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/isomorphicinversion"
    },
    {
        "id": 350,
        "task_id": 3024,
        "test_case_id": 4,
        "question": "Let $s$ be a given string of up to $10^6$ digits. Find the maximal $k$ for which it is possible to partition $s$ into $k$ consecutive contiguous substrings, such that the $k$ parts form a palindrome. More precisely, we say that strings $s_0, s_1, \\dots , s_{k-1}$ form a palindrome if $s_ i = s_{k-1-i}$ for all $0\\leq i < k$.\n\nIn the first sample case, we can split the string 652526 into $4$ parts as 6|52|52|6, and these parts together form a palindrome. It turns out that it is impossible to split this input into more than $4$ parts while still making sure the parts form a palindrome.\n\n-----Input-----\n - A nonempty string of up to $10^6$ digits.\n\n-----Output-----\n - Print the maximal value of $k$ on a single line.\n\n-----Examples-----\nSample Input 1:\n652526\nSample Output 1:\n4\n\nSample Input 2:\n12121131221\nSample Output 2:\n7\n\nSample Input 3:\n123456789\nSample Output 3:\n1",
        "solutions": "",
        "difficulty": "competition",
        "input": "132594414896459441321\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/isomorphicinversion"
    },
    {
        "id": 351,
        "task_id": 3822,
        "test_case_id": 1,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "5 10 1 2 5\n",
        "output": "5.0000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 352,
        "task_id": 3822,
        "test_case_id": 2,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "3 6 1 2 1\n",
        "output": "4.7142857143\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 353,
        "task_id": 3822,
        "test_case_id": 3,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "39 252 51 98 26\n",
        "output": "3.5344336938\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 354,
        "task_id": 3822,
        "test_case_id": 4,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "59 96 75 98 9\n",
        "output": "1.2315651330\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 355,
        "task_id": 3822,
        "test_case_id": 5,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "87 237 3 21 40\n",
        "output": "33.8571428571\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 356,
        "task_id": 3822,
        "test_case_id": 6,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "11 81 31 90 1\n",
        "output": "2.3331983806\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 357,
        "task_id": 3822,
        "test_case_id": 7,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "39 221 55 94 1\n",
        "output": "3.9608012268\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 358,
        "task_id": 3822,
        "test_case_id": 8,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "59 770 86 94 2\n",
        "output": "8.9269481589\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 359,
        "task_id": 3822,
        "test_case_id": 9,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1000000000 1 2 1\n",
        "output": "999925003.7498125093\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 360,
        "task_id": 3822,
        "test_case_id": 10,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1 999999999 1000000000 1\n",
        "output": "0.0000000010\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 361,
        "task_id": 3822,
        "test_case_id": 11,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "9102 808807765 95894 96529 2021\n",
        "output": "8423.2676366126\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 362,
        "task_id": 3822,
        "test_case_id": 12,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "87 422 7 90 3\n",
        "output": "49.2573051579\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 363,
        "task_id": 3822,
        "test_case_id": 13,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "15 563 38 51 5\n",
        "output": "13.4211211456\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 364,
        "task_id": 3822,
        "test_case_id": 14,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "39 407 62 63 2\n",
        "output": "6.5592662969\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 365,
        "task_id": 3822,
        "test_case_id": 15,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "18 518 99 100 4\n",
        "output": "5.2218163471\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 366,
        "task_id": 3822,
        "test_case_id": 16,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "8367 515267305 49370 57124 723\n",
        "output": "10310.3492287628\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 367,
        "task_id": 3822,
        "test_case_id": 17,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "6592 724149457 54877 85492 6302\n",
        "output": "10543.9213545882\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 368,
        "task_id": 3822,
        "test_case_id": 18,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "8811 929128198 57528 84457 6629\n",
        "output": "13306.2878107183\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 369,
        "task_id": 3822,
        "test_case_id": 19,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "8861 990217735 49933 64765 6526\n",
        "output": "17403.1926037323\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 370,
        "task_id": 3822,
        "test_case_id": 20,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "9538 765513348 52584 86675 8268\n",
        "output": "11295.6497404812\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 371,
        "task_id": 3822,
        "test_case_id": 21,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "9274 783669740 44989 60995 6973\n",
        "output": "14946.9402371816\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 372,
        "task_id": 3822,
        "test_case_id": 22,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "9103 555078149 86703 93382 8235\n",
        "output": "6168.7893283125\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 373,
        "task_id": 3822,
        "test_case_id": 23,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "9750 980765213 40044 94985 4226\n",
        "output": "18012.2266672490\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 374,
        "task_id": 3822,
        "test_case_id": 24,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "5884 943590784 42695 98774 3117\n",
        "output": "14275.9991046103\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 375,
        "task_id": 3822,
        "test_case_id": 25,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "1 1 1 2 1\n",
        "output": "0.5000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 376,
        "task_id": 3822,
        "test_case_id": 26,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1000000000 1 1000000000 1\n",
        "output": "19998.6000479986\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 377,
        "task_id": 3822,
        "test_case_id": 27,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1000000000 1 1000000000 10000\n",
        "output": "1.0000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 378,
        "task_id": 3822,
        "test_case_id": 28,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1000000000 999999999 1000000000 3\n",
        "output": "1.0000000010\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 379,
        "task_id": 3822,
        "test_case_id": 29,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "9999 1000000 10 20 3\n",
        "output": "99977.5011249438\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 380,
        "task_id": 3822,
        "test_case_id": 30,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "1 1 1 1000000000 1\n",
        "output": "0.0000000010\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 381,
        "task_id": 3822,
        "test_case_id": 31,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "1 1 999999999 1000000000 1\n",
        "output": "0.0000000010\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 382,
        "task_id": 3822,
        "test_case_id": 32,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "1 1000000000 1 2 1\n",
        "output": "500000000.0000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 383,
        "task_id": 3822,
        "test_case_id": 33,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "1 1000000000 1 1000000000 1\n",
        "output": "1.0000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 384,
        "task_id": 3822,
        "test_case_id": 34,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "1 1000000000 999999999 1000000000 1\n",
        "output": "1.0000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 385,
        "task_id": 3822,
        "test_case_id": 35,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1 1 2 1\n",
        "output": "0.9999250037\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 386,
        "task_id": 3822,
        "test_case_id": 36,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1 1 2 10000\n",
        "output": "0.5000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 387,
        "task_id": 3822,
        "test_case_id": 37,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1 1 1000000000 1\n",
        "output": "0.0000199986\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 388,
        "task_id": 3822,
        "test_case_id": 38,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1 1 1000000000 10000\n",
        "output": "0.0000000010\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 389,
        "task_id": 3822,
        "test_case_id": 39,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1 999999999 1000000000 10000\n",
        "output": "0.0000000010\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 390,
        "task_id": 3822,
        "test_case_id": 40,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1000000000 1 2 10000\n",
        "output": "500000000.0000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 391,
        "task_id": 3822,
        "test_case_id": 41,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1000000000 999999999 1000000000 1\n",
        "output": "1.0000000010\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 392,
        "task_id": 3822,
        "test_case_id": 42,
        "question": "On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v_2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.\n\nDetermine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected. \n\n\n-----Input-----\n\nThe first line of the input contains five positive integers n, l, v_1, v_2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 10^9, 1 ≤ v_1 < v_2 ≤ 10^9, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus. \n\n\n-----Output-----\n\nPrint the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10^{ - 6}.\n\n\n-----Examples-----\nInput\n5 10 1 2 5\n\nOutput\n5.0000000000\n\nInput\n3 6 1 2 1\n\nOutput\n4.7142857143\n\n\n\n-----Note-----\n\nIn the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.",
        "solutions": "[\"import sys\\nn, l, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k\\nif n == 1:\\n\\tprint(l / v2)\\n\\treturn\\n\\nL, R = 0, l\\nfor i in range(100):\\n\\tM = (L + R) / 2\\n\\tS = l - M\\n\\tT = M * (n * 2 - 1)- l\\n\\tif T * v1 > S * v2:\\n\\t\\tR = M\\n\\telse:\\n\\t\\tL = M\\n\\nprint(M / v2 + S / v1)\\n\", \"n, L, v1, v2, k = list(map(int, input().split()))\\nn = (n + k - 1) // k * 2\\ndif = v2 - v1\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nans = p1 / p2\\nprint(ans)\\n\", \"3\\n\\nimport sys\\nsys.setrecursionlimit(10 ** 9)\\n\\ndef bscheck(n, l, v1, v2, k, t):\\n    while True:\\n        if k > n:\\n            k = n\\n        if n == 0:\\n            return True\\n        if l / v2 > t:\\n            return False\\n    #    v2 * tx + v1 * (t - tx) = l\\n    #    (v2 - v1) * tx = l - v1 * t\\n        tx = (l - v1 * t) / (v2 - v1)\\n        ty = (tx * v2 - tx * v1) / (v1 + v2)\\n\\n        _n = n - k\\n        _l = l - tx * v1 - ty * v1\\n        _t = t - tx - ty\\n\\n        n = _n\\n        l = _l\\n        t = _t\\n\\n\\nn, l, v1, v2, k = list(map(int, input().split()))\\n\\nlt, rt = 0, 1791791791\\nfor i in range(100):\\n    mid = (lt + rt) / 2\\n    if bscheck(n, l, v1, v2, k, mid):\\n        rt = mid\\n    else:\\n        lt = mid\\n\\nprint(rt)\\n\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"n,l,v1,v2,k=list(map(int,input().split()))\\nm=(n-1)//k+1\\nv=v1+v2\\nx=l*v*v2/(m*v*v2-(m-1)*(v2-v1)*v2)\\nprint(x/v2+(l-x)/v1)\\n\", \"n, L, v1, v2, k = map(int, input().split())\\ndif = v2 - v1\\nn = (n + k - 1) // k * 2\\np1 = (n * v2 - dif) * L\\np2 = (n * v1 + dif) * v2\\nprint(p1 / p2)\", \"n,l,v1,v2,k=map(int,input().split())\\nn=(n+k-1)//k\\na=(v2-v1)/(v1+v2)\\nt=l/v2/(n-(n-1)*a)\\nprint(n*t+(n-1)*a*t)\", \"import sys\\nimport math\\n\\ndata = sys.stdin.read()\\ndata = data.split(' ')\\n\\nn = int(data[0])\\nl = int(data[1])\\nw = int(data[2])\\nv = int(data[3])\\nk = int(data[4])\\n\\nz = math.ceil(n/k)\\ntop = l/w - l/(2*w*z) + l/(2*v*z)\\nbot = 1 + v/(2*w*z) - 1/(2*z)\\nprint(top/bot)\\n\", \"n, s, v1, v2, k = map(int, input().split())\\nn = (n + k - 1) // k # k = 1\\nl, r, m = 0, 1000000000000000000, 0\\nfor _ in range(300):\\n  m = (l + r) / 2\\n  y = (s - v1 * m) / (v2 - v1)\\n  gap = y * (v2 - v1)\\n  pikap = gap / (v1 + v2)\\n  if pikap * (n - 1) + n * y <= m:\\n    r = m\\n  else:\\n    l = m\\nprint(\\\"%.10f\\\" % r)\", \"from sys import stdin, stdout\\nimport math\\n\\n\\ndef solution():\\n    n, l, v1, v2, k = map(int, stdin.readline().rstrip().split())\\n    grs = math.ceil(float(n)/k)\\n    c = grs/(v2-v1)+(grs-1)/(v1+v2)\\n    stdout.write(\\\"{}\\\".format(l/(v1+1/c)))\\n\\n\\ndef __starting_point():\\n    solution()\\n__starting_point()\", \"n,l,v1,v2,k=list(map(int,input().split()))\\n\\nn=(n+k-1)//k\\n\\na=(v2-v1)/(v1+v2)\\n\\nt=l/v2/(n-(n-1)*a)\\n\\nprint(n*t+(n-1)*a*t)\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n,l,v,o,k=list(map(int,input().split()))\\nT=(n+k-1)//k\\ne=1-v/o\\nL=l/v/(T/o+T*e/(v+o)-e/(v+o)-1/o+1/v)\\nprint((l-L)/v+L/o)\\n\", \"RYIawuypxfFqJOW = map\\nRYIawuypxfFqJOL = int\\nRYIawuypxfFqJOg = input\\nRYIawuypxfFqJOi = print\\nn, l, v1, v2, k = RYIawuypxfFqJOW(RYIawuypxfFqJOL, RYIawuypxfFqJOg().split())\\nn = (n + k - 1) // k\\na = (v2 - v1)/(v1 + v2)\\nt = l / v2 / (n - (n - 1) * a)\\nRYIawuypxfFqJOi(n * t + (n - 1) * a * t)\\n\", \"import math\\n\\nn,L,v1,v2,k = [int(x) for x in input().split()]\\nn = int(math.ceil(n/k))\\na = v2/v1\\nx = (2*L)/(a+2*n-1)\\ny = L-(n-1)*x\\n\\nprint((y*n+(n-1)*(y-x))/v2)\\n\"]",
        "difficulty": "competition",
        "input": "10000 1000000000 999999999 1000000000 10000\n",
        "output": "1.0000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/700/A"
    },
    {
        "id": 393,
        "task_id": 3836,
        "test_case_id": 36,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "54\n10 13\n10 45\n10 51\n01 44\n10 24\n10 26\n10 39\n10 38\n10 41\n10 33\n10 18\n10 12\n10 38\n10 30\n11 31\n10 46\n11 50\n00 26\n00 29\n00 50\n10 16\n10 40\n10 50\n00 43\n10 48\n10 32\n10 18\n10 8\n10 24\n10 32\n10 52\n00 41\n10 37\n10 38\n10 49\n00 35\n10 52\n00 44\n10 41\n10 36\n00 28\n00 43\n10 36\n00 21\n10 46\n00 23\n00 38\n10 30\n10 40\n01 22\n00 36\n10 49\n10 32\n01 33\n",
        "output": "435\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 394,
        "task_id": 4071,
        "test_case_id": 1,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "3\n",
        "output": "27\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 395,
        "task_id": 4071,
        "test_case_id": 2,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 396,
        "task_id": 4071,
        "test_case_id": 3,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "2\n",
        "output": "22\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 397,
        "task_id": 4071,
        "test_case_id": 4,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "4\n",
        "output": "58\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 398,
        "task_id": 4071,
        "test_case_id": 5,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "5\n",
        "output": "85\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 399,
        "task_id": 4071,
        "test_case_id": 6,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "6\n",
        "output": "94\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 400,
        "task_id": 4071,
        "test_case_id": 7,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "7\n",
        "output": "121\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 401,
        "task_id": 4071,
        "test_case_id": 8,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "8\n",
        "output": "166\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 402,
        "task_id": 4071,
        "test_case_id": 9,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "9\n",
        "output": "202\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 403,
        "task_id": 4071,
        "test_case_id": 10,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "10\n",
        "output": "265\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 404,
        "task_id": 4071,
        "test_case_id": 11,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "11\n",
        "output": "274\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 405,
        "task_id": 4071,
        "test_case_id": 12,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "12\n",
        "output": "319\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 406,
        "task_id": 4071,
        "test_case_id": 13,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "13\n",
        "output": "346\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 407,
        "task_id": 4071,
        "test_case_id": 14,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "14\n",
        "output": "355\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 408,
        "task_id": 4071,
        "test_case_id": 15,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "15\n",
        "output": "378\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 409,
        "task_id": 4071,
        "test_case_id": 16,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "16\n",
        "output": "382\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 410,
        "task_id": 4071,
        "test_case_id": 17,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "17\n",
        "output": "391\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 411,
        "task_id": 4071,
        "test_case_id": 18,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "18\n",
        "output": "438\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 412,
        "task_id": 4071,
        "test_case_id": 19,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "19\n",
        "output": "454\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 413,
        "task_id": 4071,
        "test_case_id": 20,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "20\n",
        "output": "483\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 414,
        "task_id": 4071,
        "test_case_id": 21,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "21\n",
        "output": "517\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 415,
        "task_id": 4071,
        "test_case_id": 22,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "22\n",
        "output": "526\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 416,
        "task_id": 4071,
        "test_case_id": 23,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "23\n",
        "output": "535\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 417,
        "task_id": 4071,
        "test_case_id": 24,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "24\n",
        "output": "562\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 418,
        "task_id": 4071,
        "test_case_id": 25,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "25\n",
        "output": "576\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 419,
        "task_id": 4071,
        "test_case_id": 26,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "26\n",
        "output": "588\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 420,
        "task_id": 4071,
        "test_case_id": 27,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "27\n",
        "output": "627\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 421,
        "task_id": 4071,
        "test_case_id": 28,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "28\n",
        "output": "634\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 422,
        "task_id": 4071,
        "test_case_id": 29,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "29\n",
        "output": "636\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 423,
        "task_id": 4071,
        "test_case_id": 30,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27",
        "solutions": "[\"a = [ 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645]\\n\\nprint(a[int(input()) - 1])\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(joke[int(input())-1])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n-1])\", \"ls = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, ]\\nprint(ls[int(input())])\", \"print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])\", \"a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(a[int(input())-1])\", \"n=int(input())\\na=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\n 627,634,636,645,648,654,663,666,690,706,728,729,\\n 762,778,825,852,861,895,913,915,922,958,985,1086,\\n 1111,1165]\\nprint(a[n-1])\\n\", \"a = {1: 4, 2: 22, 3: 27, 4: 58, 5: 85, 6: 94, 7: 121, 8: 166, 9: 202, 10: 265, 11: 274, 12: 319, 13: 346, 14: 355, 15: 378, 16: 382, 17: 391, 18: 438, 19: 454, 20: 483, 21: 517, 22: 526, 23: 535, 24: 562, 25: 576, 26: 588, 27: 627, 28: 634, 29: 636, 30: 645}\\nprint(a[int(input())])\", \"import collections as col\\nimport itertools as its\\nimport sys\\nimport operator\\nfrom bisect import bisect_left, bisect_right\\nfrom copy import copy, deepcopy\\n\\n\\nclass Solver:\\n    def __init__(self):\\n        pass\\n    \\n    def solve(self):\\n        a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n        x = int(input())\\n        print(a[x - 1])\\n\\n\\ndef __starting_point():\\n    s = Solver()\\n    s.solve()\\n\\n__starting_point()\", \"\\n\\ndef main():\\n    a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n         634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\n\\n    print(a[int(input()) - 1])\\n    \\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\ncnt = int(input())\\nprint(a[cnt-1])\", \"TASK = \\\"stars\\\"\\n# FIN = open(TASK + \\\".in\\\")\\n# FOUT = open(TASK + \\\".out\\\", \\\"w\\\")\\n\\na = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn = int(input())\\nprint(a[n - 1])\\n\\n# FIN.close()\\n# FOUT.close()\\n\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][n-1])\", \"n = int(input())\\nprint([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922][n - 1])\", \"3\\nl = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654]\\na = int(input())\\nprint(l[a - 1])\\n\\n\", \"a = int(input())\\na -= 1\\nb = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nprint(b[a])\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648]\\nb = int(input())\\nprint(a[b - 1])\\n\", \"a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825]\\n\\np = int(input())\\nprint(a[p - 1])\\n\", \"ls = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nprint(ls[int(input()) - 1])\\n\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nx = int(input())\\nprint(a[x])\\n\", \"print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1])\", \"import sys\\n\\nt = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627,\\n     634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nfor line in sys.stdin:\\n    x = int(line)\\n    print(t[x - 1])\\n\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111]\\nn = int(input())\\nprint(a[n])\", \"a = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nn=int(input())\\nprint('{}'.format(a[n]))\\n\", \"joke = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\\nN =int(input())\\nprint(joke[N-1])\\n\"]",
        "difficulty": "introductory",
        "input": "30\n",
        "output": "645\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/A"
    },
    {
        "id": 424,
        "task_id": 4091,
        "test_case_id": 1,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "8 3\n5 4 2 6 5 1 9 2\n",
        "output": "20\n4 1 3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 425,
        "task_id": 4091,
        "test_case_id": 2,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "5 1\n1 1 1 1 1\n",
        "output": "1\n5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 426,
        "task_id": 4091,
        "test_case_id": 3,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "4 2\n1 2000 2000 2\n",
        "output": "4000\n2 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 427,
        "task_id": 4091,
        "test_case_id": 4,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "1 1\n2000\n",
        "output": "2000\n1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 428,
        "task_id": 4091,
        "test_case_id": 5,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "1 1\n1234\n",
        "output": "1234\n1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 429,
        "task_id": 4091,
        "test_case_id": 6,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "3 2\n1 1 1\n",
        "output": "2\n2 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 430,
        "task_id": 4091,
        "test_case_id": 7,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "4 2\n3 5 1 1\n",
        "output": "8\n1 3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 431,
        "task_id": 4091,
        "test_case_id": 8,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "5 3\n5 5 6 7 1\n",
        "output": "18\n2 1 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 432,
        "task_id": 4091,
        "test_case_id": 9,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "6 4\n1 1 1 1 2 2\n",
        "output": "6\n3 1 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 433,
        "task_id": 4091,
        "test_case_id": 10,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "5 3\n5 5 6 6 4\n",
        "output": "17\n2 1 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 434,
        "task_id": 4091,
        "test_case_id": 11,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "16 15\n14 4 9 12 17 1 1 8 12 13 6 9 17 2 18 12\n",
        "output": "154\n1 1 1 1 1 2 1 1 1 1 1 1 1 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 435,
        "task_id": 4091,
        "test_case_id": 12,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "1 1\n1996\n",
        "output": "1996\n1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 436,
        "task_id": 4091,
        "test_case_id": 13,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "5 3\n5 5 5 9 10\n",
        "output": "24\n3 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 437,
        "task_id": 4091,
        "test_case_id": 14,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "18 15\n18 2 13 1 18 3 2 18 18 20 9 2 20 20 4 20 9 12\n",
        "output": "204\n1 2 2 1 2 1 1 1 1 1 1 1 1 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 438,
        "task_id": 4091,
        "test_case_id": 15,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "5 3\n1 20 20 50 50\n",
        "output": "120\n3 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 439,
        "task_id": 4091,
        "test_case_id": 16,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "8 3\n15 14 11 19 17 14 14 8\n",
        "output": "51\n1 3 4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 440,
        "task_id": 4091,
        "test_case_id": 17,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "5 2\n15 20 6 19 6\n",
        "output": "39\n2 3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 441,
        "task_id": 4091,
        "test_case_id": 18,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "6 3\n5 5 5 5 6 9\n",
        "output": "20\n4 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 442,
        "task_id": 4091,
        "test_case_id": 19,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "5 3\n2 2 2 3 3\n",
        "output": "8\n3 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 443,
        "task_id": 4091,
        "test_case_id": 20,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "7 3\n2 2 2 2 2 3 3\n",
        "output": "8\n5 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 444,
        "task_id": 4091,
        "test_case_id": 21,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "6 5\n1 1 6 6 6 6\n",
        "output": "25\n2 1 1 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 445,
        "task_id": 4091,
        "test_case_id": 22,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "8 4\n1 2 2 2 2 3 4 5\n",
        "output": "14\n5 1 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 446,
        "task_id": 4091,
        "test_case_id": 23,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "6 4\n1 1 1 5 5 5\n",
        "output": "16\n3 1 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 447,
        "task_id": 4091,
        "test_case_id": 24,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "6 3\n1 2 2 2 4 5\n",
        "output": "11\n4 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 448,
        "task_id": 4091,
        "test_case_id": 25,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "18 6\n17 17 19 14 10 20 18 16 6 7 2 15 14 16 13 6 12 11\n",
        "output": "107\n1 1 1 3 1 11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 449,
        "task_id": 4091,
        "test_case_id": 26,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "6 3\n1 1 2 2 3 4\n",
        "output": "9\n4 1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 450,
        "task_id": 4091,
        "test_case_id": 27,
        "question": "Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \\dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all $n$ problems in exactly $k$ days.\n\nThus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in $k$ days he will solve all the $n$ problems.\n\nThe profit of the $j$-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the $j$-th day (i.e. if he solves problems with indices from $l$ to $r$ during a day, then the profit of the day is $\\max\\limits_{l \\le i \\le r}a_i$). The total profit of his practice is the sum of the profits over all $k$ days of his practice.\n\nYou want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all $n$ problems between $k$ days satisfying the conditions above in such a way, that the total profit is maximum.\n\nFor example, if $n = 8, k = 3$ and $a = [5, 4, 2, 6, 5, 1, 9, 2]$, one of the possible distributions with maximum total profit is: $[5, 4, 2], [6, 5], [1, 9, 2]$. Here the total profit equals $5 + 6 + 9 = 20$.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 2000$) — the number of problems and the number of days, respectively.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2000$) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).\n\n\n-----Output-----\n\nIn the first line of the output print the maximum possible total profit.\n\nIn the second line print exactly $k$ positive integers $t_1, t_2, \\dots, t_k$ ($t_1 + t_2 + \\dots + t_k$ must equal $n$), where $t_j$ means the number of problems Polycarp will solve during the $j$-th day in order to achieve the maximum possible total profit of his practice.\n\nIf there are many possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n8 3\n5 4 2 6 5 1 9 2\n\nOutput\n20\n3 2 3\nInput\n5 1\n1 1 1 1 1\n\nOutput\n1\n5\n\nInput\n4 2\n1 2000 2000 2\n\nOutput\n4000\n2 2\n\n\n\n-----Note-----\n\nThe first example is described in the problem statement.\n\nIn the second example there is only one possible distribution.\n\nIn the third example the best answer is to distribute problems in the following way: $[1, 2000], [2000, 2]$. The total profit of this distribution is $2000 + 2000 = 4000$.",
        "solutions": "[\"\\ndef mi():\\n\\treturn map(int, input().split())\\n\\nn, k = mi()\\na = list(mi())\\nfor i in range(n):\\n\\ta[i] = [a[i],i]\\n\\na.sort(reverse= True)\\n\\na = a[:k]\\ns = 0\\nind = []\\nfor i in a:\\n\\ts+=i[0]\\n\\tind.append(i[1])\\nind.sort()\\nfor i in range(k):\\n\\tind[i]+=1\\nind1 = ind.copy()\\nfor i in range(1,len(ind)):\\n\\tind[i]-=ind1[i-1]\\nind[-1] = n-sum(ind[:k-1])\\nprint (s)\\nfor i in ind:\\n\\tprint (i, end = ' ')\", \"n,k = map(int,input().split())\\nl = list(map(int,input().split()))\\n\\nl = sorted([(x,i) for i,x in enumerate(l)],key = lambda x: (x[0],x[1]))\\nused = l[-k:]\\n\\ns = sum(x[0] for x in used)\\ndays = sorted(x[1] for x in used)\\nprint (s)\\n\\nd = []\\nt = 0\\nfor x in days[:-1]:\\n    d.append(x-t + 1)\\n    t = x + 1\\nd.append(n-t)\\nprint (*d)\", \"import sys\\nimport io\\n\\nstream_enable = 0\\n\\ninpstream = \\\"\\\"\\\"\\n\\n\\\"\\\"\\\"\\n\\nif stream_enable:\\n    sys.stdin = io.StringIO(inpstream)\\n    input()\\n\\ndef inpmap():\\n    return list(map(int, input().split()))\\n\\nn, k = inpmap()\\narr = inpmap()\\nar = arr[:]\\nar.sort()\\nb = ar[-k:]\\nprint(sum(b))\\nm = 0\\nr = []\\nfor i, x in enumerate(arr):\\n    if x in b:\\n        b.remove(x)\\n        r.append(i - m + 1)\\n        m = i + 1\\nr[-1] += n - m\\nprint(*r)\\n\", \"n, k = map(int, input().split())\\na=sorted(enumerate(map(int, input().split())), key=lambda x:-x[1])[:k]\\ns=0\\nfor i in a:\\n    s+=i[1]\\na.sort(key=lambda x:x[0])\\nprint(s)\\nprev=-1\\nfor i in a[:-1]:\\n    print(i[0]-prev, end=' ')\\n    prev=i[0]\\nprint(n-prev-1)\\n\", \"import heapq\\n\\nn,k = map(int, input().split())\\na = list(enumerate(map(int, input().split()), 1))\\ns = heapq.nlargest(k, a, key = lambda x: x[1])\\nsu = sum([si[1] for si in s])\\ns = sorted([si[0] for si in s])\\ns[-1] = n\\nfor i in range(len(s)-1, 0, -1):\\n    s[i] -= s[i-1]\\n\\nprint(su)\\nprint(*s)\", \"problems, days = list(map(int, input().split(\\\" \\\")))\\ndifficulties = list(map(int, input().split(\\\" \\\")))\\n\\ncopyDifficulties = difficulties.copy()\\ncopyDifficulties.sort()\\nmaxValues = {}\\n\\nfor i in range(days):\\n    if copyDifficulties[problems - 1 - i] in maxValues:\\n        maxValues[copyDifficulties[problems - i - 1]] += 1\\n    else:\\n        maxValues[copyDifficulties[problems - i - 1]] = 1\\n\\ngained = 0\\nsolved = []\\nsolvedDay = 0\\nfor i in range(problems):\\n    solvedDay += 1\\n    if difficulties[i] in maxValues and maxValues.get(difficulties[i]) >= 1:\\n        gained += difficulties[i]\\n        maxValues[difficulties[i]] -= 1\\n        solved.append(solvedDay)\\n        solvedDay = 0\\nsolved[len(solved) - 1] += problems - sum(solved)\\nprint(gained)\\nres = \\\" \\\"\\nfor i in solved:\\n    res += str(i) + \\\" \\\"\\nprint(res.strip())\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = [0] * 3000\\n\\nfor i in range(n):\\n    a[i] = (i, a[i])\\n\\na.sort(key=lambda x: x[1], reverse=True)\\n\\nfor i in range(k):\\n    b[a[i][0]] = 1\\n\\ncur = 0\\nans = []\\ntotal = 0\\naddtolast = 0\\na.sort(key=lambda x: x[0])\\n\\nfor i in range(n):\\n    if b[i] == 1:\\n        total += a[i][1]\\n        ans.append(i - cur + 1)\\n        addtolast = n - i - 1\\n        cur = i + 1\\n\\nans[-1] += addtolast\\n\\nprint(total)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nls = [int(i) for i in input().split()]\\n\\nt = sorted(ls)\\nt.reverse()\\nans = 0\\nst = []\\nfor i in range(m):\\n    ans += t[i]\\n    st.append(t[i])\\n\\nprint(ans)\\n\\nl = -1\\nfor i in range(n):\\n    if ls[i] in st:\\n        if len(st) == 1:\\n            print(n - 1 - l);return\\n\\n        st.pop(st.index(ls[i]))\\n        print(i - l, end=' ')\\n        l = i\\n\\n\", \"length, k = map(int, input().split())\\n\\nproblems = list(enumerate(map(int, input().split(' '))))\\n\\nproblems.sort(key=lambda i: i[1], reverse=True)\\n\\nmaxs = problems[:k]\\n\\nmaxs.sort()\\n\\ndistr = []\\n\\nprev = -1\\ntotal = 0\\nfor i in range(k):\\n    distr.append(maxs[i][0] - prev)\\n    prev = maxs[i][0]\\n    total += distr[-1]\\n\\ndistr[-1] += length - total\\n\\nprint(sum(map(lambda i: i[1], maxs)))\\nprint(*distr)\", \"n, k = list(map(int, input().split(\\\" \\\")))\\n\\nnumbers = [int(i) for i in input().split(\\\" \\\")]\\nnumbers = [(num, i + 1) for i, num in enumerate(numbers)]\\n\\nnumbers = sorted(numbers)\\nnumbers = numbers[::-1][:k]\\nindices = [i[1] for i in numbers]\\nindices = sorted(indices)\\n\\nfor i in range(k -1, 0, -1):\\n    indices[i] -= indices[i - 1]\\n\\ns = sum(indices)\\nindices[-1] += n - s\\nprint(sum([i[0] for i in numbers]))\\nprint(*indices)\\n\", \"R = lambda: map(int, input().split())\\n\\nn, k = R()\\na = list(R())\\nb = sorted(a)\\nb = b[n-k:]\\nans = []\\n\\nprint(sum(b))\\n\\nk = 0\\nfor t in a:\\n    k += 1\\n    if t in b:\\n        del b[b.index(t)]\\n        ans.append(k)\\n        k = 0\\nif k:\\n    ans[-1] += k\\n\\nprint(*ans, sep=' ')\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nneed = sorted(a, reverse=True)\\n\\nind = list()\\nfor el in need[:k]:\\n    ind.append(a.index(el))\\n    a[a.index(el)] = 0\\n\\nind.sort()\\n\\nprint(sum(need[:k]))\\n\\nind[-1] = n - 1\\nind.insert(0, -1)\\nans = [el - ind[i] for i, el in enumerate(ind[1:])]\\n\\nprint(' '.join(map(str, ans)))\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = sorted(a, reverse=True)\\nb = b[:k]\\ns = sum(b)\\nrec = []\\nk = 1\\nfor i in range(n):\\n    if a[i] not in b:\\n        k += 1\\n        continue\\n    else:\\n        b.remove(a[i])\\n        rec.append(k)\\n        k = 1\\n\\nrec[-1] += n - sum(rec)\\nprint(s)\\nprint(\\\" \\\".join(map(str, rec)))\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\n\\nres = sorted(a, reverse = True)\\nres = res[0:k]\\nprint(sum(res))\\ns = res\\nprev = 0\\ncounter = 1\\nfor i in range(len(a)):\\n\\tif a[i] in s:\\n\\t\\ts.pop(s.index(a[i]))\\n\\t\\tif counter == k:\\n\\t\\t\\tprint(n - prev)\\n\\t\\telse:\\n\\t\\t\\tprint(i + 1 - prev, end=' ')\\n\\t\\tcounter += 1\\n\\t\\tprev = i + 1\\n\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\nat = []\\n\\nz = 0\\nfor i in a:\\n    at.append( (z, i) )\\n    z = z + 1\\n\\nat.sort(key = lambda x:-x[1])\\n\\nzt = sorted(at[:k], key = lambda x:x[0])\\n\\nprev = -1\\nai = []\\nsuma = 0\\nfor i in zt:\\n    ai.append(i[0] - prev)\\n    prev = i[0]\\n    suma += i[1]\\n\\n\\nai[-1] = ai[-1] + (n - sum(ai))\\n\\nprint(suma)\\nprint(\\\" \\\".join(str(i) for i in ai))\\n\", \"n, k  =map(int,input().split())\\n\\ndata = list(map(int,input().split()))\\n\\n\\nan_data = [(data[i],i ) for i in range(n)]\\n\\nan_data.sort(key = lambda x:x[0])\\nan_data = an_data[::-1]\\nans = 0\\nanswer = []\\nfor i in range(k):\\n    ans += an_data[i][0]\\n    answer.append(an_data[i][1])\\n\\n\\nprint(ans)\\n\\nprev = 0\\nanswer.sort()\\n\\nfor i in range(k):\\n    el = answer[i]\\n    if i == k - 1:\\n        print(n - prev)\\n        break\\n    \\n    if prev == 0:\\n        print(el  + 1 ,end=\\\" \\\")\\n        prev = el  +1\\n        continue\\n        \\n    print(el - prev  +1, end = \\\" \\\")\\n    prev = el  + 1\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = []\\nfor i in range(n):\\n    b.append((a[i], i))\\nb.sort(reverse=True)\\nsum = 0\\nlol = [-1]\\nfor i in range(k):\\n    sum += b[i][0]\\n    lol.append(b[i][1])\\nlol.sort()\\nans = []\\nfor i in range(1, k + 1):\\n    ans.append(lol[i] - lol[i - 1])\\nans[k - 1] += n - 1 - lol[k]\\nprint(sum)\\nprint(*ans)\", \"# from collections import Counter as cc\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ns = sorted(zip(arr, list(range(n))), reverse=True)\\ns = s[:k]\\nprint(sum(x for x, _ in s))\\ns.sort(key=lambda x: x[1])\\nprev = -1\\nans = []\\nfor x, i in s[:-1]:\\n    n -= i - prev\\n    ans.append(i - prev)\\n    prev = i\\nans.append(n)\\nprint(*ans)\\n\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = sorted(a)[-k:]\\nprint(sum(b))\\nused = [0 for i in range(n)]\\nfor elem in b:\\n    for i in range(n):\\n        if a[i] == elem and used[i] == 0:\\n            used[i] = 1\\n            break\\nlast = 0\\ncount = 0\\nans = []\\nfor i in range(n):\\n    if used[i]:\\n        ans.append(i - last + 1)\\n        last = i + 1\\n        count += 1\\n    if count == k:\\n        ans.pop()\\n        ans.append(n - sum(ans))\\nprint(*ans)\\n\", \"#codeforces_1006_B\\nn,k = [ int(e) for e in input().split(\\\" \\\") ]\\nL = [ int(e) for e in input().split(\\\" \\\") ]\\nM = L[:]\\nM.sort()\\nM = M[-1:-k-1:-1]\\ncursor = 0\\nprint(sum(M))\\nfor e in L:\\n    cursor += 1\\n    if e in M:\\n        M.remove(e)\\n        if M != []:\\n            print(cursor,end=\\\" \\\")\\n            cursor = 0\\n        else:\\n            pass;\\nprint(cursor)\", \"n, k = map(int, input().split())\\ns = [int(elem) for elem in input().split()]\\nanses = []\\ns2 = s[:]\\ns2.sort(reverse = True)\\ns2 = s2[:k]\\nans = sum(s2)\\narr = []\\ne = 0\\nfor i in range(n):\\n    if s[i] in s2:\\n        anses.append(str(i - e + 1))\\n        e = i + 1\\n        b = s2.index(s[i])\\n        del s2[b]\\nif e - 1 < n:\\n    anses[len(anses) - 1] = str(int(anses[len(anses) - 1]) + n - e)\\nprint(ans)\\nprint(' '.join(anses))\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [[a[i], i] for i in range(n)]\\nb.sort(reverse = True)\\n# print(b)\\nb = b[:k]\\nb.sort( key = lambda x : x[1])\\n# print(b)\\nans = 0\\nfor i in b:\\n    ans += i[0]\\nprint(ans)\\nprev = 0\\nfor iter, i  in enumerate(b):\\n    if iter != len(b) - 1:\\n        print(i[1] + 1 - prev, end = ' ')\\n        prev = i[1] + 1\\n    else:\\n        print(n - prev)\", \"n, k = [int(i) for i in input().split()]\\na = [int(i) for i in input().split()]\\nb = [i for i in a]\\na.sort()\\nd = {}\\ncount = 0\\nans = []\\nans_sum = 0\\nfor i in range(n):\\n    if not b[i] in d:\\n        d[b[i]] = []\\n    d[b[i]].append(i)\\n\\nfor i in reversed(range(n)):\\n    ans_sum += a[i]\\n    ans.append(d[a[i]][0])\\n    d[a[i]] = d[a[i]][1:]\\n    count += 1\\n    if count == k:\\n        break\\n\\nprint(ans_sum)\\nans.sort()\\nans = [-1] + ans\\nl = len(ans)\\nfor i in range(1, l - 1):\\n    print(ans[i] - ans[i - 1], end = \\\" \\\")\\nprint(n - ans[-2] - 1)\", \"n, m = map(int, input().split())\\na = list(map(int, input().split()))\\nq = []\\nfor i in range(n):\\n    q.append(a[i])\\nq.sort()\\nq = q[(-m):]\\ns = 0\\nfor i in range(m):\\n    s += q[i]\\nprint(s)\\ns = 1\\nw = []\\nf = 1\\nfor i in range(n):\\n    if(a[0] in q):\\n        w.append(s)\\n        f+=s\\n        s = 0\\n        q.remove(a[0])\\n    a.remove(a[0])\\n    s+=1\\nw[-1] += n-f+1\\nfor i in range(m):\\n    print(w[i], end = \\\" \\\")\\n\"]",
        "difficulty": "introductory",
        "input": "8 3\n5 4 2 5 6 1 9 2\n",
        "output": "20\n4 1 3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1006/B"
    },
    {
        "id": 451,
        "task_id": 4130,
        "test_case_id": 1,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "4\n3 2 4 1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 452,
        "task_id": 4130,
        "test_case_id": 2,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "6\n1 1 1 4 4 4\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 453,
        "task_id": 4130,
        "test_case_id": 3,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "10\n8 9 4 9 6 10 8 2 7 1\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 454,
        "task_id": 4130,
        "test_case_id": 4,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "7\n1 1 2 3 5 6 6\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 455,
        "task_id": 4130,
        "test_case_id": 5,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "1\n1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 456,
        "task_id": 4130,
        "test_case_id": 6,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "10\n2 3 5 2 4 3 1 1 5 4\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 457,
        "task_id": 4130,
        "test_case_id": 7,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "8\n3 2 2 1 1 2 1 2\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 458,
        "task_id": 4130,
        "test_case_id": 8,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "5\n1 1 1 3 3\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 459,
        "task_id": 4130,
        "test_case_id": 9,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "6\n1 9 2 6 4 3\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 460,
        "task_id": 4130,
        "test_case_id": 10,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "10\n6 7 3 10 2 2 10 9 8 9\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 461,
        "task_id": 4130,
        "test_case_id": 11,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "10\n10 3 1 3 9 1 8 4 10 9\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 462,
        "task_id": 4130,
        "test_case_id": 12,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "10\n9 6 6 5 1 10 4 3 4 8\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 463,
        "task_id": 4130,
        "test_case_id": 13,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "111\n117 101 127 127 119 172 19 117 28 119 119 54 163 136 37 145 11 83 117 9 145 2 11 19 73 18 3 65 164 100 36 101 64 1 45 11 2 137 11 136 128 110 117 91 54 3 47 64 164 155 137 63 117 65 63 90 81 99 136 136 38 172 109 117 127 172 127 126 28 38 164 137 162 99 91 145 172 90 101 110 64 91 92 56 173 18 27 74 108 45 173 173 29 173 3 73 10 54 173 27 145 19 74 64 100 73 47 27 9 56 18\n",
        "output": "83\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 464,
        "task_id": 4130,
        "test_case_id": 14,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "2\n1 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 465,
        "task_id": 4130,
        "test_case_id": 15,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "2\n2 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 466,
        "task_id": 4130,
        "test_case_id": 16,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "10\n9 1 6 2 7 3 10 8 4 5\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 467,
        "task_id": 4130,
        "test_case_id": 17,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "9\n2 1 3 3 1 3 2 1 2\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 468,
        "task_id": 4130,
        "test_case_id": 18,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "5\n2 1 5 2 4\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 469,
        "task_id": 4130,
        "test_case_id": 19,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "8\n5 6 2 1 2 5 6 10\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 470,
        "task_id": 4130,
        "test_case_id": 20,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "125\n8 85 125 177 140 158 2 152 67 102 9 61 29 188 102 193 112 194 15 7 133 134 145 7 89 193 130 149 134 51 13 194 191 149 73 106 151 85 42 53 163 134 127 7 51 61 178 105 117 197 35 21 122 164 133 165 135 12 192 60 54 187 173 75 74 195 85 62 166 195 131 109 191 196 61 44 61 20 95 147 199 142 71 198 36 153 58 141 2 101 6 182 58 137 166 30 146 199 10 108 18 182 132 70 168 183 3 10 124 153 12 135 76 94 124 169 177 115 79 200 184 76 77 145 147\n",
        "output": "118\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 471,
        "task_id": 4130,
        "test_case_id": 21,
        "question": "There are $n$ boxers, the weight of the $i$-th boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.\n\nIt is necessary to choose the largest boxing team in terms of the number of people, that all the boxers' weights in the team are different (i.e. unique).\n\nWrite a program that for given current values ​$a_i$ will find the maximum possible number of boxers in a team.\n\nIt is possible that after some change the weight of some boxer is $150001$ (but no more).\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 150000$) — the number of boxers. The next line contains $n$ integers $a_1, a_2, \\dots, a_n$, where $a_i$ ($1 \\le a_i \\le 150000$) is the weight of the $i$-th boxer.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of people in a team.\n\n\n-----Examples-----\nInput\n4\n3 2 4 1\n\nOutput\n4\n\nInput\n6\n1 1 1 4 4 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example, boxers should not change their weights — you can just make a team out of all of them.\n\nIn the second example, one boxer with a weight of $1$ can be increased by one (get the weight of $2$), one boxer with a weight of $4$ can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of $3$ and $5$, respectively). Thus, you can get a team consisting of boxers with weights of $5, 4, 3, 2, 1$.",
        "solutions": "[\"n=int(input())\\narr=list(map(int,input().split()))\\narr=sorted(arr)\\ns=set()\\nfor val in arr:\\n  if val!=1 and val-1 not in s:\\n      s.add(val-1)\\n  elif val not in s:\\n    s.add(val)\\n  elif val+1 not in s:\\n    s.add(val+1)\\nprint(len(s))\", \"n = int(input())\\narr = list(map(int,input().split()))\\narr = sorted(arr)\\nl = [0 for i in range(150150)]\\nfor val in arr:\\n    for j in range(-1, 2):\\n        if val + j == 0:\\n            continue\\n        if l[val + j] == 0:\\n            l[val + j] = 1\\n            break\\nans = 0\\nfor i in range(1, 150150):\\n    ans += l[i]\\nprint(ans)\", \"n = int(input())\\nc = sorted(list(map(int,input().split())))\\nlast = 0\\nans = 0\\nfor i in (c):\\n\\tif(last>i):\\n\\t\\tcontinue\\n\\telif(last<i-1):\\n\\t\\tlast = i-1\\n\\t\\tans+=1\\n\\telif(last==i-1):\\n\\t\\tlast = i\\n\\t\\tans+=1\\n\\telse:\\n\\t\\tlast = i+1\\n\\t\\tans+=1\\nprint(ans)\\n\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\n\\nA.sort()\\n\\nif A[0] > 1:\\n    A[0] -= 1\\n\\nans = 1\\n\\nfor i in range(1,n):\\n    if A[i] == A[i-1]:\\n        A[i]+=1\\n        ans += 1\\n    elif A[i] > A[i-1] + 1:\\n        A[i]-=1\\n        ans +=1\\n    elif A[i] > A[i-1]:\\n        ans += 1\\n    else:\\n        A[i] = A[i-1]\\n\\nprint(ans)\\n\", \"n=int(input())\\nr=[int(x) for x in input().split()]\\nr.sort()\\nt=0\\nboxers=0\\nfor i in range(n):\\n    if r[i]>t+1:\\n        boxers+=1\\n        t=r[i]-1\\n    elif r[i]==t+1:\\n        boxers+=1\\n        t=r[i]\\n    elif r[i]==t:\\n        boxers+=1\\n        t=r[i]+1\\nprint(boxers)\", \"import math\\n# helpful:\\n# r,g,b=map(int,input().split())\\n#list1 = input().split()\\n#for i in range(len(list1)):\\n#    list1[i] = int(list1[i])\\n#print(list1)\\n# arr = [[0 for x in range(columns)] for y in range(rows)]\\n\\n\\nn = int(input())\\nlist1 = input().split()\\nfor i in range(n):\\n    list1[i] = int(list1[i])\\nlist1.sort()\\nfor i in range(n):\\n    if(i==0):\\n        if(list1[i] > 1):\\n            list1[i] -= 1\\n    else:\\n        if(list1[i] < list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] == list1[i-1]):\\n            list1[i] += 1\\n        elif(list1[i] > list1[i-1] + 1):\\n            list1[i] -= 1\\nlist1.sort()\\nnum = 0\\ncurr= 0\\nfor i in range(n):\\n    if(list1[i] != curr):\\n        num += 1\\n        curr = list1[i]\\nprint(num)\\n\", \"import sys\\nI = sys.stdin.readline\\nb = [0]*150003\\nn = I()\\nfor i in map( int, I().split() ):\\n    b[ i ] += 1\\na = 0\\nfor i in range( 1, 150002 ):\\n    if b[ i - 1 ] > 0:\\n        b[ i - 1 ] -= 1\\n    elif b[ i ] > 0:\\n        b[ i ] -= 1\\n    elif b[ i + 1 ] > 0:\\n        b[ i + 1 ] -= 1\\n    else:\\n        a -= 1\\n    a += 1\\nprint( a )\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\nmaksik = -10000000\\nfor i in range(n):\\n\\tif l[i] == 1 and maksik < 1:\\n\\t\\tmaksik = 1\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tif l[i] - 1 > maksik:\\n\\t\\t\\tl[i] -= 1\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telif l[i] - 1 == maksik:\\n\\t\\t\\tmaksik = l[i]\\n\\t\\telse:\\n\\t\\t\\tl[i] += 1\\n\\t\\t\\tmaksik = l[i]\\nwyn = 0\\nfor i in range(1, n):\\n\\tif l[i] != l[i-1]:\\n\\t\\twyn += 1\\nprint(wyn + 1)\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nimport math\\nfrom math import gcd,sqrt\\n\\n#T = int(input())\\nN = int(input())\\n#s = input()\\n#N,M,Q = [int(x) for x in stdin.readline().split()]\\narr = [int(x) for x in stdin.readline().split()]\\n\\nadd = [-1,0,1]\\n\\narr.sort()\\n\\nfreq = {}\\nres = 0\\nfor i in range(N):\\n    for j in range(3):\\n        w = arr[i] + add[j]\\n        if w>0 and w not in freq:\\n            freq[w] = 1\\n            res += 1\\n            break\\n            \\nprint(res)\", \"import os, sys\\n\\nn = int(input())\\ntext = sys.stdin.readline()\\na = list(sorted(map(int, text.strip().split())))\\n\\nm = 150002\\nlsg = []\\nwhile a:\\n    n = a.pop()\\n    if n+1 < m:\\n        m = n+1\\n        lsg.append(m)\\n    elif n < m:\\n        m = n\\n        lsg.append(m)\\n    elif n-1 < m:\\n        m = n-1\\n        lsg.append(m)\\n\\nl = len(lsg)\\nprint(l-1 if lsg[-1] == 0 else l)\\n\", \"n = int(input())\\nms = sorted(map(int, input().split()))\\nws = set()\\nfor i in ms:\\n\\tif (i != 1 and i - 1 not in ws):\\n\\t\\tws.add(i - 1)\\n\\telif (i not in ws):\\n\\t\\tws.add(i)\\n\\telif (i + 1 not in ws):\\n\\t\\tws.add(i + 1)\\nprint(len(ws))\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nres = set()\\nfor elt in ls:\\n    if elt>1 and elt-1 not in res:\\n        res.add(elt-1)\\n    elif elt not in res:\\n        res.add(elt)\\n    elif elt+1 not in res:\\n        res.add(elt+1)\\n\\nprint(len(res))\\n\", \"n = int(input())\\nres = prev = 0\\nfor e in sorted(map(int, input().split())):\\n    if e < prev: continue\\n    res += 1\\n    if e == prev:\\n        e += 1\\n    if e - 1 > prev:\\n        e -= 1\\n    prev = e\\nprint(res)\", \"ans = int(input())\\nlast = 0\\nfor a in sorted(map(int, input().split())):\\n    if last > a:\\n        ans -= 1\\n    else:\\n        last = max(a - 1, last + 1)\\nprint(ans)\\n\", \"from sys import stdin\\nn=int(stdin.readline().strip())\\n\\ns=list(map(int,stdin.readline().strip().split()))\\ns.sort()\\nvis=[False for i in range(150100)]\\nans=0\\nfor i in range(n):\\n    if not vis[s[i]-1] and (s[i]-1)!=0:\\n        vis[s[i]-1]=True\\n        ans+=1\\n    elif not vis[s[i]] :\\n        ans+=1\\n        vis[s[i]]=True\\n    elif not vis[s[i]+1]:\\n        ans+=1\\n        vis[s[i]+1]=True\\nprint(ans)\\n        \\n\", \"import math\\nn=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nhsh=[1]+[0]*(max(a)+1)\\nfor i in a:\\n    if(hsh[i-1]==0):\\n        hsh[i-1]=1\\n    else:\\n        if(hsh[i]==0):\\n            hsh[i]=1\\n        else:\\n            if(hsh[i+1]==0):\\n                hsh[i+1]=1\\nprint(hsh.count(1)-1)\\n\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\n\\npre = 0\\nans = 0\\nfor a in A:\\n    if a > pre+1:\\n        ans += 1\\n        pre = a-1\\n    elif a > pre:\\n        ans += 1\\n        pre = a\\n    elif a == pre:\\n        ans += 1\\n        pre = a+1\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    arr = list(map(int,input().split()))\\n    arr.sort()\\n\\n    nums = set()\\n    for i in arr:\\n        if i-1 > 0 and ((i-1) not in nums):\\n            nums.add(i-1)\\n        elif i not in nums:\\n            nums.add(i)\\n        elif (i+1) not in nums:\\n            nums.add(i+1)\\n\\n    print(len(nums))\\n            \\n\\n\\nmain()\\n\", \"def gns():\\n    return list(map(int,input().split()))\\n\\n# t=int(input())\\nimport math\\nt=1\\n\\n\\nfor i in range(t):\\n    n=int(input())\\n    ns=gns()\\n    ns.sort()\\n    nd=1\\n\\n    ans=0\\n    for i in range(n):\\n        n=ns[i]\\n        if n-1>=nd:\\n            ans+=1\\n            nd=n\\n        elif n==nd:\\n            ans+=1\\n            nd=n+1\\n        elif n+1==nd:\\n            ans+=1\\n            nd=n+2\\n        else:\\n            continue\\n    print(ans)\\n\\n\\n\\n\\n\\n\\n\", \"import sys\\nfrom collections import Counter\\nimport math\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr=list(map(int,input().split()))\\n\\nd=Counter(arr)\\nkeys=sorted(d.keys())\\n\\nres=0\\nmax=0\\n\\nfor i in range(len(keys)):\\n    while(d[keys[i]]>0):\\n        if d[keys[i]]>3:\\n            d[keys[i]]=3\\n        d[keys[i]]-=1\\n        if max<keys[i]-1:\\n            max=keys[i]-1\\n            res+=1\\n        elif max==keys[i]-1:\\n            max=keys[i]\\n            res+=1\\n        elif max==keys[i]:\\n            max=keys[i]+1\\n            res+=1\\n\\nprint(res)\", \"N = int(input())\\nA = sorted([int(a) for a in input().split()])\\n\\nk = 0\\nans = 0\\nfor i in range(N):\\n    if k > A[i]:\\n        pass\\n    elif k >= A[i] - 1:\\n        ans += 1\\n        k += 1\\n    else:\\n        ans += 1\\n        k = A[i] - 1\\nprint(ans)\\n\\n\", \"from math import gcd\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor c in a:\\n\\td[c] = d.get(c, 0) + 1\\nt = sorted(d)\\nfor x in t:\\n\\tif x == 1:\\n\\t\\tif d[x] > 1:\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\telse:\\n\\t\\tif d[x] > 2:\\n\\t\\t\\td[x - 1] = d.get(x - 1, 0) + 1\\n\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\telif d[x] == 2:\\n\\t\\t\\tif d.get(x - 1, 0) == 0:\\n\\t\\t\\t\\td[x - 1] = 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\td[x + 1] = d.get(x + 1, 0) + 1\\n\\t\\tif d[x] == 1 and d.get(x - 1, 0) == 0:\\n\\t\\t\\td[x - 1] = 1\\n\\t\\t\\td[x] = 0\\n\\nans = 0\\nfor c in d:\\n\\tif d[c]:\\n\\t\\tans += 1\\nprint(ans)\\n\", \"n=int(input())\\nA=sorted(map(int,input().split()))\\nSET=set()\\n\\nfor a in A:\\n  if a==1:\\n    if not(1 in SET):\\n      SET.add(1)\\n    else:\\n      SET.add(2)\\n      \\n  else:\\n    if not(a-1 in SET):\\n      SET.add(a-1)\\n      \\n    elif not (a in SET):\\n      SET.add(a)\\n      \\n    else:\\n      SET.add(a+1)\\n      \\nprint(len(SET))\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nn = int(input())\\narr = list(map(int, input().split()))\\nd = defaultdict(int)\\n\\nfor i in arr:\\n  d[i] += 1\\n  if d[i] == 4:\\n    d[i] = 3\\n\\ncnt = [0] * 150009\\n\\nfor i, j in sorted(d.items()):\\n  if j == 3:\\n    if i-1 > 0:\\n      cnt[i-1] = 1\\n    cnt[i] = 1\\n    cnt[i+1] = 1\\n  \\n  elif j == 1:\\n    #print(cnt[i-1], cnt[i], cnt[i+1])\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      continue\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      continue\\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\n  else:\\n    cnt2 = 0\\n    if i-1 > 0 and cnt[i-1] == 0:\\n      cnt[i-1] = 1\\n      cnt2 += 1\\n    if cnt[i] == 0:\\n      cnt[i] = 1\\n      cnt2 += 1\\n    if cnt2 == 2:\\n      continue\\n  \\n    if cnt[i+1] == 0:\\n      cnt[i+1] = 1\\n      continue\\n\\nprint(sum(cnt))\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\nA=[int(i) for i in input().split()]\\nA.sort()\\nans=1\\ncur=max(1,A[0]-1)\\nfor i in range(1,n):\\n  a=A[i]\\n  if a<cur:\\n    continue\\n  elif a==cur:\\n    ans+=1\\n    cur+=1\\n  elif a>cur+1:\\n    ans+=1\\n    cur=a-1\\n  else:\\n    ans+=1\\n    cur=a\\nprint(ans)\\n\"]",
        "difficulty": "introductory",
        "input": "116\n105 88 185 188 182 117 178 167 135 86 200 138 200 27 40 38 125 134 1 200 193 160 199 25 114 132 44 182 170 191 58 177 160 63 81 166 93 160 167 47 88 104 140 185 18 92 162 45 43 121 131 191 171 156 106 34 81 10 112 179 176 57 33 34 197 157 29 60 138 196 103 139 15 42 121 60 27 22 110 144 103 195 119 76 172 88 151 41 47 65 39 4 188 51 51 47 152 180 50 158 166 176 10 107 91 69 33 51 179 16 45 71 89 46 150 156\n",
        "output": "115\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1203/E"
    },
    {
        "id": 472,
        "task_id": 4188,
        "test_case_id": 1,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 473,
        "task_id": 4188,
        "test_case_id": 2,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "7\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 474,
        "task_id": 4188,
        "test_case_id": 3,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "13\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 475,
        "task_id": 4188,
        "test_case_id": 4,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "3\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 476,
        "task_id": 4188,
        "test_case_id": 5,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "8\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 477,
        "task_id": 4188,
        "test_case_id": 6,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "16\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 478,
        "task_id": 4188,
        "test_case_id": 7,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "11\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 479,
        "task_id": 4188,
        "test_case_id": 8,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "2\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 480,
        "task_id": 4188,
        "test_case_id": 9,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "5\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 481,
        "task_id": 4188,
        "test_case_id": 10,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 482,
        "task_id": 4188,
        "test_case_id": 11,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "9\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 483,
        "task_id": 4188,
        "test_case_id": 12,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "15\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 484,
        "task_id": 4188,
        "test_case_id": 13,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "4\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 485,
        "task_id": 4188,
        "test_case_id": 14,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "12\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 486,
        "task_id": 4188,
        "test_case_id": 15,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "6\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 487,
        "task_id": 4188,
        "test_case_id": 16,
        "question": "Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: The highest mountain above sea level in the world is Mount Everest. Its peak rises to 8848 m.  The largest board game tournament consisted of 958 participants playing chapaev. The largest online maths competition consisted of 12766 participants. The Nile is credited as the longest river in the world. From its farthest stream in Burundi, it extends 6695 km in length. While not in flood, the main stretches of the Amazon river in South America can reach widths of up to 1100 km at its widest points. Angel Falls is the highest waterfall. Its greatest single drop measures 807 m. The Hotel Everest View above Namche, Nepal — the village closest to Everest base camp – is at a record height of 31962 m Uranium is the heaviest of all the naturally occurring elements. Its most common isotope has a nucleus containing 146 neutrons. The coldest permanently inhabited place is the Siberian village of Oymyakon, where the temperature of -68°C was registered in the twentieth century. The longest snake held in captivity is over 25 feet long. Its name is Medusa. Colonel Meow holds the world record for longest fur on a cat — almost 134 centimeters. Sea otters can have up to 10000 hairs per square inch. This is the most dense fur in the animal kingdom. The largest state of USA is Alaska; its area is 663268 square miles Alaska has a longer coastline than all of the other 49 U.S. States put together: it is 154103 miles long. Lake Baikal is the largest freshwater lake in the world. It reaches 1642 meters in depth and contains around one-fifth of the world’s unfrozen fresh water. The most colorful national flag is the one of Turkmenistan, with 106 colors. \n\n\n-----Input-----\n\nThe input will contain a single integer between 1 and 16.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n1\n\nInput\n7\n\nOutput\n0",
        "solutions": "[\"\\n# arr = [\\n# 1, # 1\\n# 0,\\n# 0,\\n# 1, # think so\\n# 1, # not sure\\n# 0, # not sure\\n# 0, # 2\\n# 1,\\n# 1, # think so\\n# 1,\\n# 0,\\n# 0,\\n# 1,\\n# 0,\\n# 1,\\n# 0,\\n# ]\\n\\narr = [\\n1, # 1\\n0,\\n0,\\n1, # think so\\n0, # not sure\\n1, # not sure\\n0, # 2\\n1,\\n1, # think so\\n1,\\n0,\\n0,\\n1,\\n0,\\n1,\\n0,\\n]\\n\\nn = int(input()) - 1\\nprint(arr[n])\\n\\n# assert n in {1, 7} or n <= \\n\\n\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\n\\nn = int(input())\\n\\nprint (a[n - 1])\", \"print('1001010111001010'[int(input())-1])\", \"a = [1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nn = int(input())\\nprint(a[n - 1])\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem D\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nanswers = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\n\\nx = int(input())\\n\\n# tests: 1 7 13 3 8 16 11 2 5 10 9 12- 12- 4 _ _\\n#if x not in [1,7,13,3,16,8,11,2,5,10] and x < 7: print(1/0)\\n\\nprint(answers[x-1])\", \"a = int(input())\\nb = [\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"1\\\",\\\"1\\\",\\\"0\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\",\\\"1\\\",\\\"0\\\"]\\nc = [\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"6\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"+\\\",\\\"C\\\",\\\"+\\\",\\\"E\\\",\\\"+\\\",\\\"+\\\"]\\n#1 == test1(1)\\n#7 == test2(0)\\n#D == test3(1)\\n#3 == test4(0)\\n#8 == test5(1)\\n\\n#G == test6(0)\\n#B == test7(0)\\n#2 == test8(0)\\n#5 == test9(0)\\n#A == test10(1)\\n#9 == test11(1)\\n#F == test12(1)\\n#4 == test13(1)\\nprint(b[a])\\n\", \"#a = [1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0]4\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0]3  1-1 2-8 3-4 4-13 5-9 7-2 8-5 9-11 10-10 11-7 12-14 13-3 15-12 16-6 \\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0]3\\n#a = [1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0]5\\n#a = [1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0]4\\n#a = [1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0]9\\n#a = [1,1,0,1,1,1,0,1,1,0,0,0,1,0,0,0]8\\n#a = [1,0,0,1,1,1,0,1,1,1,0,0,1,0,0,1]6\\n#a = [1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0]11!\\n#a = [1,0,0,1,0,1,0,1,1,1,0,1,1,1,1,0]14!\\n#a = [1,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0]15!\\na = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\", \"print(' 1001010111001010'[int(input())])\", \"a = [1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nb=int(input())\\nprint(a[b-1])\\n\", \"print(' 1001010111001010'[int(input())])\", \"print('1001010111001010'[int(input())-1])\", \"print([1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0][int(input())-1])\", \"g=[0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nz=int(input())\\nprint(g[z])\\n\", \"# Nile?\\na=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\\n\", \"l = [0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0]\\nk = int(input())\\nprint(l[k])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nn=int(input())\\nprint(a[n-1])\", \"s = '1001010111001010'\\nprint(s[int(input()) - 1])\", \"a = ['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nx = int(input())\\nprint (a[x - 1])\", \"print(\\\"01001010111001010\\\"[int(input())]);\", \"s = \\\"A1001010111001010\\\";print(s[int(input())])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nn=int(input())\\nprint(a[n-1])\", \"a=['1','0','0','1','0','1','0','1','1','1','0','0','1','0','1','0']\\nprint(a[int(input())-1])\", \"a=[1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0]\\nprint(a[int(input())-1])\"]",
        "difficulty": "introductory",
        "input": "14\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/D"
    },
    {
        "id": 488,
        "task_id": 4421,
        "test_case_id": 7,
        "question": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by $k$. In other words, two boxes $i$ and $j$ ($i \\ne j$) can be combined as a gift if $d_i + d_j$ is divisible by $k$.\n\nHow many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes \"partially\" or redistribute candies between them. \n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le n \\le 2 \\cdot 10^5, 1 \\le k \\le 100$) — the number the boxes and the number the girls.\n\nThe second line of the input contains $n$ integers $d_1, d_2, \\dots, d_n$ ($1 \\le d_i \\le 10^9$), where $d_i$ is the number of candies in the $i$-th box.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of the boxes Polycarp can give as gifts.\n\n\n-----Examples-----\nInput\n7 2\n1 2 2 3 2 4 10\n\nOutput\n6\n\nInput\n8 2\n1 2 2 3 2 4 6 10\n\nOutput\n8\n\nInput\n7 3\n1 2 2 3 2 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(2, 3)$;  $(5, 6)$;  $(1, 4)$. \n\nSo the answer is $6$.\n\nIn the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(6, 8)$;  $(2, 3)$;  $(1, 4)$;  $(5, 7)$. \n\nSo the answer is $8$.\n\nIn the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(1, 2)$;  $(6, 7)$. \n\nSo the answer is $4$.",
        "solutions": "[\"n, k = map(int, input().split())\\nD = list(map(int, input().split()))\\nz = {i: 0 for i in range(k)}\\nfor i in range(n):\\n    z[D[i] % k] += 1\\ncnt = z[0] // 2\\nfor q in range(1, k // 2 + k % 2):\\n    cnt += min(z[q], z[k - q])\\nif k % 2 == 0:\\n    cnt += z[k // 2] // 2\\nprint(cnt * 2)\", \"n, k = map(int, input().split())\\nd = list(map(int, input().split()))\\n\\ncount = [0] * k\\nfor x in d:\\n    count[x%k] += 1\\n\\nresult = count[0]//2\\nfor i in range(1, k):\\n    if i*2 >= k:\\n        break\\n    result += min(count[i], count[k-i])\\n\\nif k%2==0:\\n    result += count[k//2]//2\\nprint(result*2)\", \"n, k = list(map(int, input().split()))\\ncounts = [0] * k\\nfor i in map(int, input().split()):\\n    counts[i % k] += 1\\n\\nc = counts[0] // 2\\nfor i in range(1, k):\\n    if 2 * i >= k:\\n        break\\n    c += min(counts[i], counts[k - i])\\nif k % 2 == 0:\\n    c += counts[k // 2] // 2\\n\\nprint(2 * c)\\n\", \"def main():\\n    n, k = list(map(int, input().split()))\\n    cnt = [0] * k\\n    ans = 0\\n    arr = list(map(int, input().split()))\\n    for el in arr:\\n        t = el % k\\n        if (cnt[(k - t) % k] > 0):\\n            cnt[(k - t) % k] -= 1\\n            ans += 2\\n        else:\\n            cnt[t] += 1\\n    print(ans)\\n \\n \\nmain()\\n\", \"n, k = list(map(int, input().split()))\\n\\nans = [0] * k\\n\\na = list(map(int, input().split()))\\n\\nfor c in a:\\n\\tans[c % k] += 1\\nkol = ans[0] - ans[0] % 2\\nfor i in range(1, int(k / 2 + 0.5)):\\n\\tkol += min(ans[i], ans[k - i]) * 2\\n\\t#print(ans[i], ans[k - i], i)\\n\\nif k % 2 == 0:\\n\\tkol += ans[k // 2] - ans[k // 2] % 2\\n#print(ans)\\nprint(kol)\\n\", \"n, k = list(map(int,input().split()))\\ndi = list(map(int,input().split()))\\nai  = [0] * k\\nfor i in di:\\n    ai[i % k] += 1\\nans = ai[0] // 2\\nai[0] = 0\\nfor i in range(1,k):\\n    num = i\\n    num2 = k - i\\n    if num != num2:\\n        ans += min(ai[num], ai[num2])\\n    else:\\n        ans += ai[num] // 2\\n    ai[num] = 0\\n    ai[num2] = 0\\nprint(ans * 2)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\ndi = dict()\\nfor i in range(n):\\n    if d[i] % k in di:\\n        di[d[i] % k] += 1\\n    else:\\n        di[d[i] % k] = 1\\nans = 0\\nif 0 in di:\\n    ans = di[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i in di and k - i in di:\\n        if i == k - i:\\n            ans += di[i] // 2\\n        else:\\n            ans += min(di[i], di[k - i])\\nprint(ans * 2)\\n\", \"n,k = [int(x) for x in input().split()]\\n\\nL = [int(x) for x in input().split()]\\n\\nD = [0]*k\\n\\nfor i in L:\\n    D[i%k] += 1\\n    \\ns = 0    \\nfor i in range((k+2)//2):\\n    if i == 0:\\n        s += 2*(D[0]//2)\\n    elif (k%2 == 0) and (i == k//2):\\n        s += 2*(D[i]//2)\\n    else:\\n        s += 2*min(D[i],D[k-i])\\n    \\nprint(s)\", \"n,k=map(int,input().split())\\nd=[*map(int,input().split())]\\ncnt=[0]*k\\nfor i in d:\\n    cnt[i%k]+=1\\nans=cnt[0]//2\\nfor i in range(1,k):\\n    req=k-i\\n    if i<req:\\n        ans+=min(cnt[i],cnt[req])\\n    elif i==req:\\n        ans+=cnt[i]//2\\nprint(ans*2)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nd = [0] * k\\nfor i in range(n):\\n    d[a[i] % k] += 1\\n\\nnum = 0\\nfor i in range(k):\\n    if k - i < i:\\n        break\\n    if i == 0:\\n        num += d[i] // 2\\n    elif i == k - i:\\n        num += d[i] // 2\\n    else:\\n        num += min(d[i], d[k - i])\\n\\nprint(num * 2)\\n\", \"from collections import Counter as C\\nn, k = map(int, input().split())\\nl = [int(x) % k for x in input().split()]\\nc = C(l)\\nres = 0\\nfor i in range(k):\\n    j = -i % k\\n    vi, vj = c.get(i, 0), c.get(j, 0)\\n    if i == j:\\n        res += vi // 2\\n    else:\\n        res += min(vi, vj)\\n    c[i] = 0\\nprint(res * 2)\", \"n, K = map(int, input().split())\\narr = map(int, input().split())\\nfreq = [0 for _ in range(K)]\\nfor x in arr:\\n    freq[x%K] += 1\\nans = 2*(freq[0]//2)\\nfor i in range(1, K):\\n    if i < K-i:\\n        ans += 2*(min(freq[i], freq[K-i]))\\n    elif i == K-i:\\n        ans += 2*(freq[i]//2)\\nprint(ans)\", \"n,k = list(map(int,input().split()))\\nl   = list(map(int,input().split()))\\n\\nd = {}\\n\\nfor i in range(k):\\n    d[i] = 0\\n\\nfor i in range(len(l)):\\n    l[i] = l[i]%k\\n    d[l[i]] += 1 \\n\\ns = 0\\n\\ns += d[0]//2\\n\\nfor i in range(1,k//2):\\n    s += min(d[i],d[k-i])\\n\\nif k % 2 == 0:\\n    s += d[k//2] // 2\\nelse:\\n    if k != 1:\\n        s += min(d[k//2],d[k-k//2])\\n        \\nprint(s*2)\\n\", \"n,k=list(map(int,input().split()))\\nD=list(map(int,input().split()))\\n\\nD2=[d%k for d in D]\\n\\nfrom collections import Counter\\nc=Counter(D2)\\n\\nANS=c[0]//2*2\\nif k%2==0:\\n    ANS+=c[k//2]//2*2\\nfor i in range(1,-(-k//2)):\\n    ANS+=min(c[i],c[k-i])*2\\n\\nprint(ANS)\\n    \\n\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/3/7 23:13\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B. Preparation for International Women's Day.py\\n\\nfrom collections import Counter\\n\\n\\ndef main():\\n    n, k = map(int, input().split())\\n    d = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    for x in d:\\n        counter[x % k] += 1\\n\\n    ret = counter[0] // 2 * 2\\n    for i in range(1, k):\\n        if i != k - i:\\n            ret += min(counter[i], counter[k - i])\\n        else:\\n            ret += counter[i] // 2 * 2\\n    print(ret)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\ndivs = {}\\nhandled = [False, ] * k\\n\\nfor x in a:\\n    divs[x % k] = divs.get(x % k, 0) + 1\\n\\nresult = divs.get(0, 0) - divs.get(0, 0) % 2\\n\\nfor i in range(1, k):\\n    if not handled[i] and not handled[k - i]:\\n        if i != k - i:\\n            result += 2 * min(divs.get(i, 0), divs.get(k - i, 0))\\n        else:\\n            result += divs.get(i, 0) - divs.get(i, 0) % 2\\n        handled[i] = handled[k - i] = True\\n\\nprint(result)\\n\", \"#map(int,input().split())\\n#int(input())\\nn,k=map(int,input().split())\\na=list(map(int,input().split()))\\nd = dict()\\nfor i in range(n):\\n    m=a[i]%k\\n    if m not in d:\\n       d[m]=1\\n    else:\\n        d[m]+=1\\nans=0\\nif 0 in d:\\n   ans = d[0]//2\\nh=k//2\\nif k%2==0 and h in d:\\n    ans  += d[h]//2\\nfor i in range(1,(k+1)//2):\\n    if i in d and k-i in d:\\n       ans += min(d[i],d[k-i])\\nprint(ans*2)\", \"from math import floor\\nfrom collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = defaultdict(int)\\nfor i in input().split():\\n    i = int(i) % k\\n    a[i] += 1\\nr = 0\\nfor i in range(floor(k / 2) + 1):\\n    if i == 0 or i == k - i:\\n        r += a[i] // 2\\n    else:\\n        r += min(a[i], a[k - i])\\nprint(r * 2)\", \"n,k=tuple(map(int,input().strip().split(\\\" \\\")))\\nnumbers=tuple(map(int,input().strip().split(\\\" \\\")))\\nl=[]\\nfor i in range(k):\\n    l.append(0)\\nfor i in numbers:\\n    l[i%k]+=1\\ns=(l[0]//2)*2\\nimport math\\nfor g in range(1,math.ceil(k/2)):\\n    s=s+(min(l[g],l[k-g])*2)\\nif(k%2==0):\\n    s=s+((l[k//2]//2)*2)\\nprint(s)\", \"def main():\\n    n,k = list(map(int,input().split()))\\n    candy = list(map(int,input().split()))\\n    candies = []\\n    zeroes = 0\\n    for i in candy:\\n        mod = i%k\\n        if mod == 0:\\n            zeroes += 1\\n        else:\\n            candies.append(mod)\\n\\n    candies.sort()\\n\\n    boxes = zeroes//2\\n\\n    candy_dict = {}\\n\\n    for i in candies:\\n        if i not in list(candy_dict.keys()):\\n            candy_dict[i] = 1\\n        else:\\n            candy_dict[i] += 1\\n\\n    #print (candy_dict)\\n    for i in candy_dict:\\n        if candy_dict[i] > 0:\\n            if (k-i) in list(candy_dict.keys()):\\n                if candy_dict[k-i] > 0:\\n                    if i == (k-i):\\n                        box = candy_dict[i]//2\\n                        candy_dict[i] = candy_dict[i]%2\\n                    else:\\n                        box = min(candy_dict[i],candy_dict[k-i])\\n                        candy_dict[i] -= box\\n                        candy_dict[k-i] -= box\\n                    boxes += box\\n\\n    print(2*boxes)\\n    \\n\\nmain()\\n\", \"n,k=list(map(int,input().split()))\\na=[int(x)%k for x in input().split()]\\nf={}\\nan=0\\nfor i in a:\\n    if -i in f and f[-i]>0:\\n        an+=2\\n        f[-i]-=1\\n    elif k-i in f and f[k-i]>0:\\n        an+=2\\n        f[k-i]-=1\\n    else:\\n        if i not in f:f[i]=0\\n        f[i]+=1\\nprint(an)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\nost = [0] * k\\nfor i in range(n):\\n    ost[d[i] % k] += 1\\nans = ost[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i != k - i:\\n        ans += min(ost[i], ost[k - i])\\n    else:\\n        ans += ost[i] // 2\\nprint(ans * 2)\\n\", \"n, k = map(int, input().split())\\ncandies = list(map(int, input().split()))\\n\\ndiv = [0 for i in range(k)]\\n\\nfor i in candies:\\n    div[i % k] += 1\\n\\n\\nres = (div[0] // 2)*2\\nif k % 2 == 1:\\n    c = k//2 +1\\nelse:\\n    c = k//2 + 1\\nfor i in range(1, c):\\n    res += 2 * min(div[i], div[k - i]) if i != k - i else (div[i] // 2)*2\\nprint(res)\", \"n,k = list(map(int,input().split()))\\nnum = list(map(int,input().split()))\\ngay = []\\nfor i in num:\\n\\tgay.append(i%k)\\nnumber = [0] * 101\\nfor i in gay:\\n\\tnumber[i] += 1\\n#print(number)\\ni = 0\\nchuj = 1\\nwynik = 0\\nwhile i<k:\\n\\tif i == (k-i)%k:\\n\\t\\tif number[i] > 1:\\n\\t\\t\\tnumber[i] -= 2\\n\\t\\t\\twynik += 1\\n\\t\\telse:\\n\\t\\t\\tnumber[i] = 0\\n\\t\\t\\ti += 1\\n\\telse:\\n\\t\\tif number[i] > 0:\\n\\t\\t\\tif number[(k-i)%k]>0:\\n\\t\\t\\t\\tnumber[i] -= 1\\n\\t\\t\\t\\tnumber[(k-i)%k] -= 1\\n\\t\\t\\t\\twynik += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tnumber[i] = 0\\n\\t\\tif number[i] == 0:\\n\\t\\t\\ti += 1\\nprint(2*wynik)\"]",
        "difficulty": "introductory",
        "input": "3 1\n1 1 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1133/B"
    },
    {
        "id": 489,
        "task_id": 4735,
        "test_case_id": 1,
        "question": "You are an eccentric billionaire with an affinity for sending stuff to Mars. In an ideal world you would send stuff to Mars all the time, but your engineers tell you that it is most efficient to do it when Earth and Mars are somewhat close to each other. \n\nYour engineers have calculated that optimal launch windows occur once every 26 months, and that one of them occurs in April 2018. They also tell you that they will not have any Big Finished Rockets by then, so you will have to wait for a later launch window.\n\nSince your rocket scientists apparently can not be bothered to tell you about the optimal launch windows before it is too late, you have to keep track of that yourself. Write a program that determines if there is an optimal launch window in any given year.\n\n-----Input-----\nThe only line of input contains an integer $y$ ($2018 \\le y \\le 10000$), the year you are interested in.\n\n-----Output-----\nOutput “yes” if there is an optimal launch window in the year $y$, otherwise output “no”.\n\n-----Examples-----\nSample Input 1:\n2018\nSample Output 1:\nyes\n\nSample Input 2:\n2019\nSample Output 2:\nno\n\nSample Input 3:\n2020\nSample Output 3:\nyes",
        "solutions": "",
        "difficulty": "introductory",
        "input": "2018\n",
        "output": "yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/marswindow"
    },
    {
        "id": 490,
        "task_id": 4735,
        "test_case_id": 2,
        "question": "You are an eccentric billionaire with an affinity for sending stuff to Mars. In an ideal world you would send stuff to Mars all the time, but your engineers tell you that it is most efficient to do it when Earth and Mars are somewhat close to each other. \n\nYour engineers have calculated that optimal launch windows occur once every 26 months, and that one of them occurs in April 2018. They also tell you that they will not have any Big Finished Rockets by then, so you will have to wait for a later launch window.\n\nSince your rocket scientists apparently can not be bothered to tell you about the optimal launch windows before it is too late, you have to keep track of that yourself. Write a program that determines if there is an optimal launch window in any given year.\n\n-----Input-----\nThe only line of input contains an integer $y$ ($2018 \\le y \\le 10000$), the year you are interested in.\n\n-----Output-----\nOutput “yes” if there is an optimal launch window in the year $y$, otherwise output “no”.\n\n-----Examples-----\nSample Input 1:\n2018\nSample Output 1:\nyes\n\nSample Input 2:\n2019\nSample Output 2:\nno\n\nSample Input 3:\n2020\nSample Output 3:\nyes",
        "solutions": "",
        "difficulty": "introductory",
        "input": "2019\n",
        "output": "no\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/marswindow"
    },
    {
        "id": 491,
        "task_id": 4735,
        "test_case_id": 3,
        "question": "You are an eccentric billionaire with an affinity for sending stuff to Mars. In an ideal world you would send stuff to Mars all the time, but your engineers tell you that it is most efficient to do it when Earth and Mars are somewhat close to each other. \n\nYour engineers have calculated that optimal launch windows occur once every 26 months, and that one of them occurs in April 2018. They also tell you that they will not have any Big Finished Rockets by then, so you will have to wait for a later launch window.\n\nSince your rocket scientists apparently can not be bothered to tell you about the optimal launch windows before it is too late, you have to keep track of that yourself. Write a program that determines if there is an optimal launch window in any given year.\n\n-----Input-----\nThe only line of input contains an integer $y$ ($2018 \\le y \\le 10000$), the year you are interested in.\n\n-----Output-----\nOutput “yes” if there is an optimal launch window in the year $y$, otherwise output “no”.\n\n-----Examples-----\nSample Input 1:\n2018\nSample Output 1:\nyes\n\nSample Input 2:\n2019\nSample Output 2:\nno\n\nSample Input 3:\n2020\nSample Output 3:\nyes",
        "solutions": "",
        "difficulty": "introductory",
        "input": "2020\n",
        "output": "yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/marswindow"
    },
    {
        "id": 492,
        "task_id": 4735,
        "test_case_id": 4,
        "question": "You are an eccentric billionaire with an affinity for sending stuff to Mars. In an ideal world you would send stuff to Mars all the time, but your engineers tell you that it is most efficient to do it when Earth and Mars are somewhat close to each other. \n\nYour engineers have calculated that optimal launch windows occur once every 26 months, and that one of them occurs in April 2018. They also tell you that they will not have any Big Finished Rockets by then, so you will have to wait for a later launch window.\n\nSince your rocket scientists apparently can not be bothered to tell you about the optimal launch windows before it is too late, you have to keep track of that yourself. Write a program that determines if there is an optimal launch window in any given year.\n\n-----Input-----\nThe only line of input contains an integer $y$ ($2018 \\le y \\le 10000$), the year you are interested in.\n\n-----Output-----\nOutput “yes” if there is an optimal launch window in the year $y$, otherwise output “no”.\n\n-----Examples-----\nSample Input 1:\n2018\nSample Output 1:\nyes\n\nSample Input 2:\n2019\nSample Output 2:\nno\n\nSample Input 3:\n2020\nSample Output 3:\nyes",
        "solutions": "",
        "difficulty": "introductory",
        "input": "2028\n",
        "output": "no\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/marswindow"
    },
    {
        "id": 493,
        "task_id": 4747,
        "test_case_id": 2,
        "question": "Recently your town has been infested by swindlers who convince unknowing tourists to play a simple dice game with them for money. The game works as follows: given is an $n$-sided die, whose sides have $1, 2, \\ldots , n$ pips, and a positive integer $k$. You then roll the die, and then have to make a choice. Option $1$ is to stop rolling. Option $2$ is to reroll the die, with the limitation that the die can only be rolled $k$ times in total. Your score is the number of pips showing on your final roll.\n\nObviously the swindlers are better at this game than the tourists are. You, proud supporter of the Battle Against Probabilistic Catastrophes, decide to fight this problem not by banning the swindlers but by arming the tourists with information.\n\nYou create pamphlets on which tourists can find the maximum expected score for many values of $n$ and $k$. You are sure that the swindlers will soon stop their swindling if the tourists are better prepared than they are!\n\nThe layout of the flyers is done, and you have distribution channels set up. All that is left to do is to calculate the numbers to put on the pamphlet.\n\nGiven the number of sides of the die and the number of times you are allowed to roll, calculate the expected (that is, average) score when the game is played optimally.\n\n-----Input-----\n - A single line with two integers $1\\leq n\\leq 100$, the number of sides of the die, and $1\\leq k\\leq 100$, the number of times the die may be rolled.\n\n-----Output-----\nOutput the expected score when playing optimally. Your answer should have an absolute or relative error of at most $10^{-7}$.\n\n-----Examples-----\nSample Input 1:\n1 1\nSample Output 1:\n1\n\nSample Input 2:\n2 3\nSample Output 2:\n1.875\n\nSample Input 3:\n6 2\nSample Output 3:\n4.25",
        "solutions": "",
        "difficulty": "introductory",
        "input": "2 3\n",
        "output": "1.875\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/deceptivedice"
    },
    {
        "id": 494,
        "task_id": 4747,
        "test_case_id": 3,
        "question": "Recently your town has been infested by swindlers who convince unknowing tourists to play a simple dice game with them for money. The game works as follows: given is an $n$-sided die, whose sides have $1, 2, \\ldots , n$ pips, and a positive integer $k$. You then roll the die, and then have to make a choice. Option $1$ is to stop rolling. Option $2$ is to reroll the die, with the limitation that the die can only be rolled $k$ times in total. Your score is the number of pips showing on your final roll.\n\nObviously the swindlers are better at this game than the tourists are. You, proud supporter of the Battle Against Probabilistic Catastrophes, decide to fight this problem not by banning the swindlers but by arming the tourists with information.\n\nYou create pamphlets on which tourists can find the maximum expected score for many values of $n$ and $k$. You are sure that the swindlers will soon stop their swindling if the tourists are better prepared than they are!\n\nThe layout of the flyers is done, and you have distribution channels set up. All that is left to do is to calculate the numbers to put on the pamphlet.\n\nGiven the number of sides of the die and the number of times you are allowed to roll, calculate the expected (that is, average) score when the game is played optimally.\n\n-----Input-----\n - A single line with two integers $1\\leq n\\leq 100$, the number of sides of the die, and $1\\leq k\\leq 100$, the number of times the die may be rolled.\n\n-----Output-----\nOutput the expected score when playing optimally. Your answer should have an absolute or relative error of at most $10^{-7}$.\n\n-----Examples-----\nSample Input 1:\n1 1\nSample Output 1:\n1\n\nSample Input 2:\n2 3\nSample Output 2:\n1.875\n\nSample Input 3:\n6 2\nSample Output 3:\n4.25",
        "solutions": "",
        "difficulty": "introductory",
        "input": "6 2\n",
        "output": "4.25\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/deceptivedice"
    },
    {
        "id": 495,
        "task_id": 4747,
        "test_case_id": 4,
        "question": "Recently your town has been infested by swindlers who convince unknowing tourists to play a simple dice game with them for money. The game works as follows: given is an $n$-sided die, whose sides have $1, 2, \\ldots , n$ pips, and a positive integer $k$. You then roll the die, and then have to make a choice. Option $1$ is to stop rolling. Option $2$ is to reroll the die, with the limitation that the die can only be rolled $k$ times in total. Your score is the number of pips showing on your final roll.\n\nObviously the swindlers are better at this game than the tourists are. You, proud supporter of the Battle Against Probabilistic Catastrophes, decide to fight this problem not by banning the swindlers but by arming the tourists with information.\n\nYou create pamphlets on which tourists can find the maximum expected score for many values of $n$ and $k$. You are sure that the swindlers will soon stop their swindling if the tourists are better prepared than they are!\n\nThe layout of the flyers is done, and you have distribution channels set up. All that is left to do is to calculate the numbers to put on the pamphlet.\n\nGiven the number of sides of the die and the number of times you are allowed to roll, calculate the expected (that is, average) score when the game is played optimally.\n\n-----Input-----\n - A single line with two integers $1\\leq n\\leq 100$, the number of sides of the die, and $1\\leq k\\leq 100$, the number of times the die may be rolled.\n\n-----Output-----\nOutput the expected score when playing optimally. Your answer should have an absolute or relative error of at most $10^{-7}$.\n\n-----Examples-----\nSample Input 1:\n1 1\nSample Output 1:\n1\n\nSample Input 2:\n2 3\nSample Output 2:\n1.875\n\nSample Input 3:\n6 2\nSample Output 3:\n4.25",
        "solutions": "",
        "difficulty": "introductory",
        "input": "8 9\n",
        "output": "7.268955230712891\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/deceptivedice"
    },
    {
        "id": 496,
        "task_id": 4986,
        "test_case_id": 2,
        "question": "Oh no! Joanna just spilled some syrup on her keyboard and now some of the keys are sticky. This causes her considerable frustration, as every time she presses one of the sticky keys, the corresponding character gets entered twice on her computer. \n\nThis could not have happened at a more inconvenient time; it is the start of the contest and she was just about to type in the solution to the first problem! Joanna does not have time to remove and clean every key on her keyboard, so she wonders if there is a way to quickly identify the sticky keys. Starting to panic, she quickly types some text on her keyboard and stares at the resulting text displayed on her screen.\n\nGiven the line of text that Joanna typed on her keyboard and the resulting text displayed on her screen, help her determine which keys must be sticky.\n\n-----Input-----\nThe input consists of:\n - One line containing a string $s$ ($1 \\leq \\mathrm{length}(s) \\leq 1000$), the text that Joanna typed on her keyboard.\n - One line containing a string $t$ ($1 \\leq \\mathrm{length}(t) \\leq 1000$), the text displayed on Joanna’s screen as a result.\n\nBoth $s$ and $t$ consist only of lower-case letters (‘a’–‘z’) and spaces (‘ ’), and start and end with a letter.\n\nIt is guaranteed that $t$ is the result of doubling each character in $s$ that corresponds to a sticky key. At least one character in $s$ corresponds to a sticky key (i.e. $s \\neq t$).\n\n-----Output-----\nOutput all characters (letters and space) corresponding to keys that must be sticky, in any order.\n\n-----Examples-----\nSample Input:\nthis is very annoying\nthiss iss veery annoying\nSample Output:\nse",
        "solutions": "",
        "difficulty": "introductory",
        "input": "so sticky\nssoo  ssttiicckkyy\n",
        "output": "its yock\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/keyboardd"
    },
    {
        "id": 497,
        "task_id": 22,
        "test_case_id": 1,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "oXoxoXo\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 498,
        "task_id": 22,
        "test_case_id": 2,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bod\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 499,
        "task_id": 22,
        "test_case_id": 3,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ER\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 500,
        "task_id": 22,
        "test_case_id": 4,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "o\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 501,
        "task_id": 22,
        "test_case_id": 5,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "a\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 502,
        "task_id": 22,
        "test_case_id": 6,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "opo\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 503,
        "task_id": 22,
        "test_case_id": 7,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "HCMoxkgbNb\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 504,
        "task_id": 22,
        "test_case_id": 8,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "vMhhXCMWDe\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 505,
        "task_id": 22,
        "test_case_id": 9,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "iIcamjTRFH\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 506,
        "task_id": 22,
        "test_case_id": 10,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "WvoWvvWovW\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 507,
        "task_id": 22,
        "test_case_id": 11,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "WXxAdbAxXW\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 508,
        "task_id": 22,
        "test_case_id": 12,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "vqMTUUTMpv\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 509,
        "task_id": 22,
        "test_case_id": 13,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "iii\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 510,
        "task_id": 22,
        "test_case_id": 14,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AAWW\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 511,
        "task_id": 22,
        "test_case_id": 15,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ss\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 512,
        "task_id": 22,
        "test_case_id": 16,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "i\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 513,
        "task_id": 22,
        "test_case_id": 17,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ii\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 514,
        "task_id": 22,
        "test_case_id": 18,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 515,
        "task_id": 22,
        "test_case_id": 19,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "LJ\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 516,
        "task_id": 22,
        "test_case_id": 20,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "m\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 517,
        "task_id": 22,
        "test_case_id": 21,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ioi\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 518,
        "task_id": 22,
        "test_case_id": 22,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "OA\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 519,
        "task_id": 22,
        "test_case_id": 23,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aaaiaaa\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 520,
        "task_id": 22,
        "test_case_id": 24,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "SS\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 521,
        "task_id": 22,
        "test_case_id": 25,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "iiii\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 522,
        "task_id": 22,
        "test_case_id": 26,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ssops\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 523,
        "task_id": 22,
        "test_case_id": 27,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ssss\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 524,
        "task_id": 22,
        "test_case_id": 28,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ll\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 525,
        "task_id": 22,
        "test_case_id": 29,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "s\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 526,
        "task_id": 22,
        "test_case_id": 30,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bb\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 527,
        "task_id": 22,
        "test_case_id": 31,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "uu\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 528,
        "task_id": 22,
        "test_case_id": 32,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ZoZ\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 529,
        "task_id": 22,
        "test_case_id": 33,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mom\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 530,
        "task_id": 22,
        "test_case_id": 34,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "uou\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 531,
        "task_id": 22,
        "test_case_id": 35,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "u\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 532,
        "task_id": 22,
        "test_case_id": 36,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "JL\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 533,
        "task_id": 22,
        "test_case_id": 37,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mOm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 534,
        "task_id": 22,
        "test_case_id": 38,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "llll\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 535,
        "task_id": 22,
        "test_case_id": 39,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ouo\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 536,
        "task_id": 22,
        "test_case_id": 40,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aa\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 537,
        "task_id": 22,
        "test_case_id": 41,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "olo\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 538,
        "task_id": 22,
        "test_case_id": 42,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "S\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 539,
        "task_id": 22,
        "test_case_id": 43,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "lAl\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 540,
        "task_id": 22,
        "test_case_id": 44,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "nnnn\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 541,
        "task_id": 22,
        "test_case_id": 45,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ZzZ\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 542,
        "task_id": 22,
        "test_case_id": 46,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bNd\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 543,
        "task_id": 22,
        "test_case_id": 47,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ZZ\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 544,
        "task_id": 22,
        "test_case_id": 48,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "oNoNo\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 545,
        "task_id": 22,
        "test_case_id": 49,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "l\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 546,
        "task_id": 22,
        "test_case_id": 50,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "zz\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 547,
        "task_id": 22,
        "test_case_id": 51,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "NON\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 548,
        "task_id": 22,
        "test_case_id": 52,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "nn\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 549,
        "task_id": 22,
        "test_case_id": 53,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "NoN\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 550,
        "task_id": 22,
        "test_case_id": 54,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "sos\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 551,
        "task_id": 22,
        "test_case_id": 55,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "lol\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 552,
        "task_id": 22,
        "test_case_id": 56,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mmm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 553,
        "task_id": 22,
        "test_case_id": 57,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "YAiAY\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 554,
        "task_id": 22,
        "test_case_id": 58,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ipIqi\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 555,
        "task_id": 22,
        "test_case_id": 59,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AAA\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 556,
        "task_id": 22,
        "test_case_id": 60,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "uoOou\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 557,
        "task_id": 22,
        "test_case_id": 61,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "SOS\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 558,
        "task_id": 22,
        "test_case_id": 62,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "NN\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 559,
        "task_id": 22,
        "test_case_id": 63,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "n\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 560,
        "task_id": 22,
        "test_case_id": 64,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "h\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 561,
        "task_id": 22,
        "test_case_id": 65,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "blld\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 562,
        "task_id": 22,
        "test_case_id": 66,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ipOqi\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 563,
        "task_id": 22,
        "test_case_id": 67,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "pop\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 564,
        "task_id": 22,
        "test_case_id": 68,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "BB\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 565,
        "task_id": 22,
        "test_case_id": 69,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "OuO\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 566,
        "task_id": 22,
        "test_case_id": 70,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "lxl\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 567,
        "task_id": 22,
        "test_case_id": 71,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "Z\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 568,
        "task_id": 22,
        "test_case_id": 72,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "vvivv\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 569,
        "task_id": 22,
        "test_case_id": 73,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "nnnnnnnnnnnnn\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 570,
        "task_id": 22,
        "test_case_id": 74,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AA\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 571,
        "task_id": 22,
        "test_case_id": 75,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "t\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 572,
        "task_id": 22,
        "test_case_id": 76,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "z\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 573,
        "task_id": 22,
        "test_case_id": 77,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mmmAmmm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 574,
        "task_id": 22,
        "test_case_id": 78,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "qlililp\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 575,
        "task_id": 22,
        "test_case_id": 79,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mpOqm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 576,
        "task_id": 22,
        "test_case_id": 80,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "iiiiiiiiii\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 577,
        "task_id": 22,
        "test_case_id": 81,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "BAAAB\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 578,
        "task_id": 22,
        "test_case_id": 82,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "UA\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 579,
        "task_id": 22,
        "test_case_id": 83,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mmmmmmm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 580,
        "task_id": 22,
        "test_case_id": 84,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "NpOqN\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 581,
        "task_id": 22,
        "test_case_id": 85,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "uOu\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 582,
        "task_id": 22,
        "test_case_id": 86,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "uuu\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 583,
        "task_id": 22,
        "test_case_id": 87,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "NAMAN\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 584,
        "task_id": 22,
        "test_case_id": 88,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "lllll\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 585,
        "task_id": 22,
        "test_case_id": 89,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "T\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 586,
        "task_id": 22,
        "test_case_id": 90,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mmmmmmmmmmmmmmmm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 587,
        "task_id": 22,
        "test_case_id": 91,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AiiA\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 588,
        "task_id": 22,
        "test_case_id": 92,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "iOi\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 589,
        "task_id": 22,
        "test_case_id": 93,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "lll\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 590,
        "task_id": 22,
        "test_case_id": 94,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "N\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 591,
        "task_id": 22,
        "test_case_id": 95,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "viv\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 592,
        "task_id": 22,
        "test_case_id": 96,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "oiio\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 593,
        "task_id": 22,
        "test_case_id": 97,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AiiiA\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 594,
        "task_id": 22,
        "test_case_id": 98,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "NNNN\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 595,
        "task_id": 22,
        "test_case_id": 99,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ixi\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 596,
        "task_id": 22,
        "test_case_id": 100,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AuuA\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 597,
        "task_id": 22,
        "test_case_id": 101,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AAAANANAAAA\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 598,
        "task_id": 22,
        "test_case_id": 102,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mmmmm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 599,
        "task_id": 22,
        "test_case_id": 103,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "oYo\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 600,
        "task_id": 22,
        "test_case_id": 104,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "dd\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 601,
        "task_id": 22,
        "test_case_id": 105,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "A\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 602,
        "task_id": 22,
        "test_case_id": 106,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ioh\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 603,
        "task_id": 22,
        "test_case_id": 107,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mmmm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 604,
        "task_id": 22,
        "test_case_id": 108,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "uuuu\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 605,
        "task_id": 22,
        "test_case_id": 109,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "puq\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 606,
        "task_id": 22,
        "test_case_id": 110,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "rrrrrr\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 607,
        "task_id": 22,
        "test_case_id": 111,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "c\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 608,
        "task_id": 22,
        "test_case_id": 112,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AbpA\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 609,
        "task_id": 22,
        "test_case_id": 113,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "qAq\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 610,
        "task_id": 22,
        "test_case_id": 114,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "tt\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 611,
        "task_id": 22,
        "test_case_id": 115,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mnmnm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 612,
        "task_id": 22,
        "test_case_id": 116,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "sss\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 613,
        "task_id": 22,
        "test_case_id": 117,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "yy\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 614,
        "task_id": 22,
        "test_case_id": 118,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bob\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 615,
        "task_id": 22,
        "test_case_id": 119,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "NAN\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 616,
        "task_id": 22,
        "test_case_id": 120,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mAm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 617,
        "task_id": 22,
        "test_case_id": 121,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "tAt\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 618,
        "task_id": 22,
        "test_case_id": 122,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "yAy\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 619,
        "task_id": 22,
        "test_case_id": 123,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "zAz\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 620,
        "task_id": 22,
        "test_case_id": 124,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aZ\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 621,
        "task_id": 22,
        "test_case_id": 125,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "hh\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 622,
        "task_id": 22,
        "test_case_id": 126,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bbbb\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 623,
        "task_id": 22,
        "test_case_id": 127,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "ZAZ\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 624,
        "task_id": 22,
        "test_case_id": 128,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "Y\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 625,
        "task_id": 22,
        "test_case_id": 129,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AAMM\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 626,
        "task_id": 22,
        "test_case_id": 130,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "lml\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 627,
        "task_id": 22,
        "test_case_id": 131,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AZA\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 628,
        "task_id": 22,
        "test_case_id": 132,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mXm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 629,
        "task_id": 22,
        "test_case_id": 133,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bd\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 630,
        "task_id": 22,
        "test_case_id": 134,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "H\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 631,
        "task_id": 22,
        "test_case_id": 135,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "uvu\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 632,
        "task_id": 22,
        "test_case_id": 136,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "dxxd\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 633,
        "task_id": 22,
        "test_case_id": 137,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "dp\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 634,
        "task_id": 22,
        "test_case_id": 138,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "vV\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 635,
        "task_id": 22,
        "test_case_id": 139,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "vMo\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 636,
        "task_id": 22,
        "test_case_id": 140,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "O\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 637,
        "task_id": 22,
        "test_case_id": 141,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "vYv\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 638,
        "task_id": 22,
        "test_case_id": 142,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "fv\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 639,
        "task_id": 22,
        "test_case_id": 143,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "U\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 640,
        "task_id": 22,
        "test_case_id": 144,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "iAi\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 641,
        "task_id": 22,
        "test_case_id": 145,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "I\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 642,
        "task_id": 22,
        "test_case_id": 146,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "VxrV\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 643,
        "task_id": 22,
        "test_case_id": 147,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "POP\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 644,
        "task_id": 22,
        "test_case_id": 148,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bid\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 645,
        "task_id": 22,
        "test_case_id": 149,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bmd\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 646,
        "task_id": 22,
        "test_case_id": 150,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "AiA\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 647,
        "task_id": 22,
        "test_case_id": 151,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "mmmmmm\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 648,
        "task_id": 22,
        "test_case_id": 152,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "XHX\n",
        "output": "TAK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 649,
        "task_id": 22,
        "test_case_id": 153,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "llllll\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 650,
        "task_id": 22,
        "test_case_id": 154,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "aAa\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 651,
        "task_id": 22,
        "test_case_id": 155,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "Db\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 652,
        "task_id": 22,
        "test_case_id": 156,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "lOl\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 653,
        "task_id": 22,
        "test_case_id": 157,
        "question": "Let's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the string \"oHo\" is \"s-palindrome\", but the string \"aa\" is not. The string \"aa\" is not \"s-palindrome\", because the second half of it is not a mirror reflection of the first half.\n\n [Image] English alphabet \n\nYou are given a string s. Check if the string is \"s-palindrome\".\n\n\n-----Input-----\n\nThe only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.\n\n\n-----Output-----\n\nPrint \"TAK\" if the string s is \"s-palindrome\" and \"NIE\" otherwise.\n\n\n-----Examples-----\nInput\noXoxoXo\n\nOutput\nTAK\n\nInput\nbod\n\nOutput\nTAK\n\nInput\nER\n\nOutput\nNIE",
        "solutions": "[\"import sys, math\\ns=input()\\npal='AHIMOoTUVvWwXxY'\\nn=len(s)\\nl=0\\nr=n-1\\nflag=True\\nfir='pq'\\nsec='bd'\\nwhile l<=r:\\n    if s[l]==s[r] and s[l] in pal:\\n        l+=1\\n        r-=1\\n        continue\\n    elif s[l]==s[r]:\\n        flag=False\\n        break\\n    elif (s[l] in fir) and (s[r] in fir):\\n        l+=1\\n        r-=1\\n        continue\\n    elif (s[l] in sec) and (s[r] in sec):\\n        l+=1\\n        r-=1\\n        continue\\n    else:\\n        flag=False\\n        break\\nif flag:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n    \\n\", \"s = input()\\nitself = {'A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'}\\nd = {'p' : 'q', 'q' : 'p', 'b' : 'd', 'd' : 'b'}\\nfor i in itself:\\n\\td[i] = i\\nok = True\\nfor i in range(len(s)):\\n\\tok &= s[i] in d.keys() and s[len(s) - i - 1] == d[s[i]]\\nprint(\\\"TAK\\\" if ok else \\\"NIE\\\")\", \"d = {\\n  'A' : 'A',\\n  'b' : 'd',\\n  'd' : 'b',\\n  'H' : 'H',\\n  'I' : 'I',\\n  'M' : 'M',\\n  'O' : 'O',\\n  'o' : 'o',\\n  'X' : 'X',\\n  'x' : 'x',\\n  'Y' : 'Y',\\n  'W' : 'W',\\n  'V' : 'V',\\n  'w' : 'w',\\n  'v' : 'v',\\n  'T' : 'T',\\n  'p' : 'q',\\n  'q' : 'p',\\n  'U' : 'U'\\n  }\\ng = lambda c : '*' if c not in list(d.keys()) else d[c]\\ns = input()\\nfor i in range(len(s)) :\\n  if s[i] != g(s[len(s)-i-1]) :\\n    print('NIE')\\n    return\\nprint('TAK')\\n\", \"sl = 'AHIMOoTUVvWwXxY'\\ns = input()\\nn = len(s)\\nfor i in range((n + 1) // 2):\\n    a, b = s[i], s[n - i - 1]\\n    if a == b and a in sl:\\n        continue\\n    elif sorted(a + b) in [['b', 'd'], ['p', 'q']]:\\n        continue\\n    else:\\n        print('NIE')\\n        return\\nprint('TAK')\", \"d = \\\"AHIMOoTUVvWwXxY\\\"\\ns = input()\\nfor i in range(len(s) // 2 + 1):\\n\\tif not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in [\\\"bd\\\", \\\"db\\\", \\\"pq\\\", \\\"qp\\\"]):\\n\\t\\tprint(\\\"NIE\\\")\\n\\t\\tbreak\\nelse:\\n\\tprint(\\\"TAK\\\")\", \"s = input()\\n\\np = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'\\n\\nfor c in s:\\n    if c in p:\\n        print('NIE')\\n        return\\n\\ndef trans(c):\\n    d = {\\n        'b': 'd',\\n        'd': 'b',\\n        'p': 'q',\\n        'q': 'p',\\n    }\\n    if c in d:\\n        return d[c]\\n    return c\\n\\nt = ''.join(map(trans, s[::-1]))\\nif t == s:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"midsym = 'AHIMOoTUVvWwXxY'\\nsym = 'pqbd'\\n\\ns = input()\\n\\nif len(s) % 2 == 1:\\n\\tt = len(s) // 2\\n\\tif s[t] not in midsym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\ts = s[:t] + s[t+1:]\\n\\n#print(s)\\n\\t\\nf = s[:int(len(s)/2)]\\nl = s[int(len(s)/2):]\\nl = l[::-1]\\nfor k in range(len(f)):\\n\\tif f[k] not in midsym and f[k] not in sym:\\n\\t\\tprint('NIE')\\n\\t\\treturn\\n\\tif f[k] in midsym:\\n\\t\\tif l[k] != f[k]:\\n\\t\\t\\tprint('NIE')\\n\\t\\t\\treturn\\n\\tif f[k] in sym:\\n\\t\\tif f[k] == 'p' and l[k] == 'q': continue\\n\\t\\tif f[k] == 'q' and l[k] == 'p': continue\\n\\t\\tif f[k] == 'b' and l[k] == 'd': continue\\n\\t\\tif f[k] == 'd' and l[k] == 'b': continue\\n\\t\\tprint('NIE')\\n\\t\\treturn\\nprint('TAK')\", \"# You lost the game.\\ns = str(input())\\nn = len(s)\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\n\\nif n % 2 and sym.count(s[n//2]) == 0:\\n    print(\\\"NIE\\\")\\nelse:\\n    r = \\\"\\\"\\n    ok = 1\\n    for i in range(n//2):\\n        if sym.count(s[i]):\\n            r = s[i] + r\\n        elif s[i] == \\\"b\\\":\\n            r = \\\"d\\\" + r\\n        elif s[i] == \\\"d\\\":\\n            r = \\\"b\\\" + r\\n        elif s[i] == \\\"p\\\":\\n            r = \\\"q\\\" + r\\n        elif s[i] == \\\"q\\\":\\n            r = \\\"p\\\" + r\\n        else:\\n            ok = 0\\n            break\\n    if ok == 0:\\n        print(\\\"NIE\\\")\\n    else:\\n        if s[n//2 + n%2:] == r:\\n            print(\\\"TAK\\\")\\n        else:\\n            print(\\\"NIE\\\")\\n\", \"s = input()\\n\\nselfs = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] # u and m???\\n\\nopps = {'b':'d', 'p':'q', 'd':'b', 'q':'p'}\\n\\nfor i in range(int(len(s)/2)+1):\\n    if s[i] not in selfs:\\n        if s[i] in opps.keys():\\n            if opps[s[i]] == s[len(s)-i-1]:\\n                pass\\n            else:\\n                print(\\\"NIE\\\")\\n                return\\n        else:\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if s[i] != s[len(s)-i-1]:\\n            print(\\\"NIE\\\")\\n            return\\n\\nif len(s) % 2 == 1:\\n    if s[int(len(s)/2)] not in selfs:\\n        print(\\\"NIE\\\")\\n        return\\n\\nprint(\\\"TAK\\\")\", \"a = \\\"AHIMOTUVWXYovwx\\\"\\nb = \\\"bdpq\\\"\\nc = \\\"dbqp\\\"\\n\\nl = list(zip(a, a)) + list(zip(b, c))\\n\\ns = input()\\n\\ndef f(c):\\n    for x in l:\\n        if c == x[0]:\\n            return x[1]\\n    return ' '\\n\\nt = ''.join(map(f, s[::-1]))\\n\\nprint(\\\"TAK\\\" if s == t else \\\"NIE\\\")\\n\", \"s = input()\\ngood = ['A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y']\\nfor i in range(len(s) // 2):\\n    if (s[i] == s[len(s) - i - 1] and s[i] in good) or (s[i] == 'b' and s[len(s) - i - 1] == 'd') or (s[i] == 'p' and s[len(s) - i - 1] == 'q') or (s[i] == 'd' and s[len(s) - i - 1] == 'b') or (s[i] == 'q' and s[len(s) - i - 1] == 'p'):\\n        pass\\n    else:\\n        print(\\\"NIE\\\")\\n        return\\nif len(s) % 2 == 1:\\n    if s[len(s) // 2] in good:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\", \"s = list(input())\\nif len(s) % 2 == 0:\\n    s1 = s[0 : len(s) // 2 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\nelse:\\n    s1 = s[0 : len(s) // 2 + 1 : ]\\n    s2 = s[len(s) // 2 : len(s) : ]\\ns2.reverse()\\nd = dict()\\nd['A'] = 'A'\\nd['b'] = 'd'\\nd['d'] = 'b'\\nd['H'] = 'H'\\nd['I'] = 'I'\\nd['M'] = 'M'\\nd['O'] = 'O'\\nd['o'] = 'o'\\nd['T'] = 'T'\\nd['U'] = 'U'\\nd['V'] = 'V'\\nd['v'] = 'v'\\nd['W'] = 'W'\\nd['w'] = 'w'\\nd['X'] = 'X'\\nd['x'] = 'x'\\nd['Y'] = 'Y'\\nd['p'] = 'q'\\nd['q'] = 'p'\\nf = True\\nfor i in range(len(s1)):\\n   if not(s1[i] in d and d[s1[i]] == s2[i]):\\n       f = False\\n       break\\nif f:\\n    print('TAK')\\nelse:\\n    print('NIE')\\n\", \"s = str(input())\\n\\nn = len(s)\\n\\nss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']\\nss2 = [('d','b'),('q','p'),('p','q'),('b','d')]\\n\\nfor i in range(0, n//2):\\n    if s[i]==s[n-1-i]:\\n        if not (s[i] in ss):\\n            print(\\\"NIE\\\")\\n            return\\n    else:\\n        if not ((s[i],s[n-1-i]) in ss2):\\n            print(\\\"NIE\\\")\\n            return\\n\\nif n%2 != 0:\\n    if s[n//2] in ss:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"TAK\\\")\\n\\n\\n\\n\", \"s = input()\\nn = len(s)\\n\\nN = 0\\n\\nif n % 2 == 0:\\n\\tN =  n // 2\\nelse:\\n\\tN = n // 2 + 1\\nflag = True\\n\\ndef check(l, r):\\n\\tsame = [\\\"A\\\", \\\"H\\\", \\\"I\\\", \\\"M\\\", \\\"O\\\", \\\"o\\\", \\\"T\\\", \\\"U\\\", \\\"V\\\", \\\"v\\\", \\\"W\\\", \\\"w\\\", \\\"X\\\", \\\"x\\\", \\\"Y\\\"]\\n\\tif (l == r) and (l in same):\\n\\t\\treturn True\\n\\tif l == \\\"b\\\" and r ==\\\"d\\\":\\n\\t\\treturn True\\n\\tif l == \\\"d\\\" and r == \\\"b\\\":\\n\\t\\treturn True\\n\\tif l == \\\"p\\\" and r == \\\"q\\\":\\n\\t\\treturn True\\n\\tif l == \\\"q\\\" and r == \\\"p\\\":\\n\\t\\treturn True\\n\\treturn False\\nfor i in range(N):\\n\\tleft = i\\n\\tright = n-1-i\\n\\tlc = s[left]\\n\\trc = s[right]\\n\\n\\tif ( not check(lc, rc) ):\\n\\t\\tflag = False\\n\\nif flag:\\n\\tprint(\\\"TAK\\\")\\nelse:\\n\\tprint(\\\"NIE\\\")\\n\\n\", \"d = {'A': 'A',\\n     'b': 'd',\\n     'd': 'b',\\n     'H': 'H',\\n     'I': 'I',\\n     'M': 'M',\\n     'O': 'O',\\n     'o': 'o',\\n     'p': 'q',\\n     'q': 'p',\\n     'T': 'T',\\n     'U': 'U',\\n     'V': 'V',\\n     'v': 'v',\\n     'W': 'W',\\n     'w': 'w',\\n     'X': 'X',\\n     'x': 'x',\\n     'Y': 'Y'}\\ns = input()\\n\\nf = True\\n\\nif len(s) % 2 == 0:\\n    l = s[:len(s) // 2]\\n    r = s[len(s) // 2:]\\nelse:\\n    l = s[:len(s) // 2]\\n    if s[len(s) // 2] not in d or d[s[len(s) // 2]] != s[len(s) // 2]:\\n        f = False\\n    r = s[len(s) // 2 + 1:]\\n\\nr = list(r)\\nfor i in range(len(r)):\\n    if r[i] not in d:\\n        f = False\\n    else:\\n        r[i] = d[r[i]]\\n\\nif r[::-1] == list(l) and f:\\n    print(\\\"TAK\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"from string import ascii_letters\\n\\nmirror_symmetry = 'AHIMOoTUVvWwXxY'\\n\\nsymmetric_to = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p',\\n}\\n\\nothers = set(ascii_letters) - set(mirror_symmetry + 'bdpq')\\n\\nstring = input()\\n\\n\\ndef f(s):\\n    if set(s) & others:\\n        return 'NIE'\\n    if len(s) % 2 == 1:\\n        if s[len(s) // 2] not in mirror_symmetry:\\n            return 'NIE'\\n        s = s[:len(s) // 2] + s[len(s) // 2 + 1:]\\n    for i in range(len(s) // 2):\\n        if s[i] in mirror_symmetry and s[-1 - i] == s[i]:\\n            continue\\n        if s[i] in symmetric_to and symmetric_to[s[i]] == s[-1 - i]:\\n            continue\\n        return 'NIE'\\n    return 'TAK'\\n\\nprint(f(string))\\n\", \"tak = {\\n    'b': 'd',\\n    'd': 'b',\\n    'p': 'q',\\n    'q': 'p'\\n}\\n\\ntok = 'AHIMOoTUVvWwXxY'\\n\\ns = input()\\nle = len(s)\\nle2 = le // 2\\n\\nif (1 == le & 1) and not s[le2] in tok:\\n    print(\\\"NIE\\\")\\n    return\\n    \\ns1 = s[0:le2]\\ns2 = s[le2 + (le & 1):][::-1]\\n\\n\\n\\nfor i in range(0, le2):\\n    \\n    if s1[i] == s2[i] and s1[i] in tok: continue\\n    if s1[i] in tak and tak[s1[i]] == s2[i]: continue\\n    print(\\\"NIE\\\")\\n    return\\n    \\nprint(\\\"TAK\\\")\", \"s = input()\\n\\nmirror={'b':'d','d':'b','p':'q','q':'p'}\\nwhile len(s)>1:\\n        if s[0] in 'AoOIMHTUVvWwXxY':\\n                if s[0]==s[-1]: s=s[1:-1:]\\n                else: break\\n        elif s[0] in mirror:\\n                if s[0]==mirror[s[-1]]: s=s[1:-1:]\\n                else: break\\n        else: break\\n\\nif len(s)==0 or (s[0] in 'AoOIMHTUVvWwXxY' and len(s)==1):\\n        print('TAK')\\nelse: print('NIE')\\n\", \"__author__ = 'Alexander'\\nimport sys\\nstring = sys.stdin.readline().strip()\\nideal = {'A','b','d','H','I','M','O','o','p','q','T','U','V','v','W','w','X','x','Y'}\\n\\nfor i in range(int((len(string)+1)/2)):\\n    if string[i] not in ideal:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\n    elif string[i] == 'b' or string[i] == 'd' or string[i] == 'p' or string[i] == 'q':\\n        if (string[i] == 'b' and string[-i-1] != 'd') or \\\\\\n        (string[i] == 'd' and string[-i-1] != 'b') or \\\\\\n        (string[i] == 'q' and string[-i-1] != 'p') or \\\\\\n        (string[i] == 'p' and string[-i-1] != 'q'):\\n            sys.stdout.write(\\\"NIE\\\")\\n            return\\n    elif string[i] != string[-i-1]:\\n        sys.stdout.write(\\\"NIE\\\")\\n        return\\nsys.stdout.write(\\\"TAK\\\")\", \"insym = set(('A', 'H', 'I', 'M', 'O', 'o', 'T', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'))\\ndisym = {'b':'d', 'd':'b', 'p':'q', 'q':'p'}\\nfor c in insym:\\n    disym[c] = c\\ns = input()\\nn = len(s)\\nif n%2==0 or s[n//2] in insym:\\n    s1 = s[0:n//2]\\n    s2 = s[::-1][0:n//2]\\n    flg = True\\n    for i in range(n//2):\\n        if s1[i] not in disym or disym[s1[i]] != s2[i]:\\n            flg = False\\n    if flg:\\n        print(\\\"TAK\\\")\\n    else:\\n        print(\\\"NIE\\\")\\nelse:\\n    print(\\\"NIE\\\")\\n\", \"import re\\n\\ns = input().strip()\\nt = re.sub('[^AbdHIMOopqTUVvWwXxY]{1}', '', s)\\n\\nm = {}\\nfor i in range(ord('A'), ord('z') + 1):\\n    m[chr(i)] = chr(i)\\n\\nm['b'] = 'd'\\nm['d'] = 'b'\\nm['p'] = 'q'\\nm['q'] = 'p'\\n\\ndef is_sp():\\n    sl = len(t)\\n    for i in range(sl // 2 + 1):\\n        if m[t[i]] != t[sl - 1 - i]:\\n            return False\\n    return True\\n\\nif len(t) == len(s):\\n    if is_sp():\\n        print('TAK')\\n    else:\\n        print('NIE')\\nelse:\\n    print('NIE')\\n\", \"s = input()\\nD = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}\\nfor (c1, c2) in zip(s, s[::-1]):\\n    if D.get(c1, '') != c2:\\n        print(\\\"NIE\\\")\\n        return\\nprint(\\\"TAK\\\")\\n\\n    \\n\", \"s = input()\\n\\nsym = \\\"AHIMOoTUVvWwXxY\\\"\\nmir = {'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p'}\\n\\nans = True\\nl = len(s)\\nif l % 2 != 0 and s[l // 2] not in sym:\\n    ans = False\\nelse:\\n    #ans = False\\n    for i in range(l // 2):\\n        if not (s[i] in mir and mir[s[i]] == s[l - i - 1] or s[i] in sym and s[i] == s[l - i - 1]):\\n            ans = False\\n            break\\nprint(\\\"TAK\\\" if ans else \\\"NIE\\\")\\n\"]",
        "difficulty": "interview",
        "input": "bzd\n",
        "output": "NIE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/691/B"
    },
    {
        "id": 654,
        "task_id": 27,
        "test_case_id": 1,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\nabcabca\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 655,
        "task_id": 27,
        "test_case_id": 2,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nabcdefgh\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 656,
        "task_id": 27,
        "test_case_id": 3,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "100\nmhnzadklojbuumkrxjayikjhwuxihgkinllackcavhjpxlydxcmhnzadklojbuumkrxjayikjhwuxihgkinllackcavhjpxlydxc\n",
        "output": "51\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 657,
        "task_id": 27,
        "test_case_id": 4,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "99\ntrolnjmzxxrfxuexcqpjvefndwuxwsukxwmjhhkqmlzuhrplrtrolnjmzxxrfxuexcqpjvefndwuxwsukxwmjhhkqmlzuhrplrm\n",
        "output": "51\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 658,
        "task_id": 27,
        "test_case_id": 5,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "100\nyeywsnxcwslfyiqbbeoaawtmioksfdndptxxcwzfmrpcixjbzvicijofjrbcvzaedglifuoczgjlqylddnsvsjfmfsccxbdveqgu\n",
        "output": "100\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 659,
        "task_id": 27,
        "test_case_id": 6,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\naaaaaaaa\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 660,
        "task_id": 27,
        "test_case_id": 7,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "4\nabab\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 661,
        "task_id": 27,
        "test_case_id": 8,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\nababbcc\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 662,
        "task_id": 27,
        "test_case_id": 9,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\nabcaabc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 663,
        "task_id": 27,
        "test_case_id": 10,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\naaaaaaaaaa\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 664,
        "task_id": 27,
        "test_case_id": 11,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\naabbbb\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 665,
        "task_id": 27,
        "test_case_id": 12,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\nabbbba\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 666,
        "task_id": 27,
        "test_case_id": 13,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "9\nabcdeabcd\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 667,
        "task_id": 27,
        "test_case_id": 14,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nabcdabcefg\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 668,
        "task_id": 27,
        "test_case_id": 15,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "9\naaaaaaaaa\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 669,
        "task_id": 27,
        "test_case_id": 16,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nababababab\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 670,
        "task_id": 27,
        "test_case_id": 17,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "9\nzabcdabcd\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 671,
        "task_id": 27,
        "test_case_id": 18,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\naaaaa\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 672,
        "task_id": 27,
        "test_case_id": 19,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nadcbeadcfg\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 673,
        "task_id": 27,
        "test_case_id": 20,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "12\nabcabcabcabc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 674,
        "task_id": 27,
        "test_case_id": 21,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "16\naaaaaaaaaaaaaaaa\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 675,
        "task_id": 27,
        "test_case_id": 22,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "4\naaaa\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 676,
        "task_id": 27,
        "test_case_id": 23,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "17\nababababzabababab\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 677,
        "task_id": 27,
        "test_case_id": 24,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nabcabcabca\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 678,
        "task_id": 27,
        "test_case_id": 25,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\ndabcabc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 679,
        "task_id": 27,
        "test_case_id": 26,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\naaaaaa\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 680,
        "task_id": 27,
        "test_case_id": 27,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\nabcbc\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 681,
        "task_id": 27,
        "test_case_id": 28,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\naabaaaa\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 682,
        "task_id": 27,
        "test_case_id": 29,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "100\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n",
        "output": "51\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 683,
        "task_id": 27,
        "test_case_id": 30,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\nablfab\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 684,
        "task_id": 27,
        "test_case_id": 31,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nabcdefef\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 685,
        "task_id": 27,
        "test_case_id": 32,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\naavaa\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 686,
        "task_id": 27,
        "test_case_id": 33,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "1\na\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 687,
        "task_id": 27,
        "test_case_id": 34,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nabcabcdddd\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 688,
        "task_id": 27,
        "test_case_id": 35,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "16\naaaaaabbaaaaaabb\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 689,
        "task_id": 27,
        "test_case_id": 36,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "17\nabcdefggggglelsoe\n",
        "output": "17\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 690,
        "task_id": 27,
        "test_case_id": 37,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "17\nabcdefgggggabcdef\n",
        "output": "17\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 691,
        "task_id": 27,
        "test_case_id": 38,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "27\naaaaaaaaaaaaaaaaaaaaaaaaaaa\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 692,
        "task_id": 27,
        "test_case_id": 39,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nabbbbbbb\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 693,
        "task_id": 27,
        "test_case_id": 40,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "2\naa\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 694,
        "task_id": 27,
        "test_case_id": 41,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\nbaaaa\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 695,
        "task_id": 27,
        "test_case_id": 42,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nabcdeeeeee\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 696,
        "task_id": 27,
        "test_case_id": 43,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "12\naaaaaaaaaaaa\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 697,
        "task_id": 27,
        "test_case_id": 44,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\nabcabd\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 698,
        "task_id": 27,
        "test_case_id": 45,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nababcababc\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 699,
        "task_id": 27,
        "test_case_id": 46,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "16\nbbbbbbaaaaaaaaaa\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 700,
        "task_id": 27,
        "test_case_id": 47,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nbbbbbbbbbc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 701,
        "task_id": 27,
        "test_case_id": 48,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "9\nasdfpasdf\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 702,
        "task_id": 27,
        "test_case_id": 49,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "9\nbaaaabaaa\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 703,
        "task_id": 27,
        "test_case_id": 50,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "11\nabcabcabcab\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 704,
        "task_id": 27,
        "test_case_id": 51,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nabccaaaaba\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 705,
        "task_id": 27,
        "test_case_id": 52,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nabbbbbba\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 706,
        "task_id": 27,
        "test_case_id": 53,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\naaaaaass\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 707,
        "task_id": 27,
        "test_case_id": 54,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "20\nhhhhhhhhhhhhhhhhhhhh\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 708,
        "task_id": 27,
        "test_case_id": 55,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\naabcabca\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 709,
        "task_id": 27,
        "test_case_id": 56,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\nababab\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 710,
        "task_id": 27,
        "test_case_id": 57,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nababcdef\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 711,
        "task_id": 27,
        "test_case_id": 58,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nabababab\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 712,
        "task_id": 27,
        "test_case_id": 59,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "14\nabcdefgabcdepq\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 713,
        "task_id": 27,
        "test_case_id": 60,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\nabcaca\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 714,
        "task_id": 27,
        "test_case_id": 61,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "11\nababababccc\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 715,
        "task_id": 27,
        "test_case_id": 62,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nababcabc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 716,
        "task_id": 27,
        "test_case_id": 63,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "20\naabaabaabaabaabaabaa\n",
        "output": "12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 717,
        "task_id": 27,
        "test_case_id": 64,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "20\nabcdabcdeeeeeeeeabcd\n",
        "output": "17\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 718,
        "task_id": 27,
        "test_case_id": 65,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "9\nasdfgasdf\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 719,
        "task_id": 27,
        "test_case_id": 66,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\navavavavbc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 720,
        "task_id": 27,
        "test_case_id": 67,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "63\njhkjhadlhhsfkadalssaaggdagggfahsakkdllkhldfdskkjssghklkkgsfhsks\n",
        "output": "63\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 721,
        "task_id": 27,
        "test_case_id": 68,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "3\naaa\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 722,
        "task_id": 27,
        "test_case_id": 69,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "13\naabbbkaakbbbb\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 723,
        "task_id": 27,
        "test_case_id": 70,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\nabababa\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 724,
        "task_id": 27,
        "test_case_id": 71,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\najkoaj\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 725,
        "task_id": 27,
        "test_case_id": 72,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\nabcdbcd\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 726,
        "task_id": 27,
        "test_case_id": 73,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "46\nkgadjahfdhjajagdkffsdfjjlsksklgkshfjkjdajkddlj\n",
        "output": "46\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 727,
        "task_id": 27,
        "test_case_id": 74,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\naabab\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 728,
        "task_id": 27,
        "test_case_id": 75,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "16\nabcdabcdabcdabcd\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 729,
        "task_id": 27,
        "test_case_id": 76,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\nzabcabc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 730,
        "task_id": 27,
        "test_case_id": 77,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nabcdeabc\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 731,
        "task_id": 27,
        "test_case_id": 78,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "11\nababcabcabc\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 732,
        "task_id": 27,
        "test_case_id": 79,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nffffffff\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 733,
        "task_id": 27,
        "test_case_id": 80,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nabbababa\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 734,
        "task_id": 27,
        "test_case_id": 81,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "13\naabaabaabaabx\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 735,
        "task_id": 27,
        "test_case_id": 82,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "9\nabcabcabc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 736,
        "task_id": 27,
        "test_case_id": 83,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "99\nlhgjlskfgldjgadhdjjgskgakslflalhjfgfaaalkfdfgdkdffdjkjddfgdhalklhsgslskfdhsfjlhgajlgdfllhlsdhlhadaa\n",
        "output": "99\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 737,
        "task_id": 27,
        "test_case_id": 84,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "1\ns\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 738,
        "task_id": 27,
        "test_case_id": 85,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "87\nfhjgjjagajllljffggjjhgfffhfkkaskksaalhksfllgdjsldagshhlhhgslhjaaffkahlskdagsfasfkgdfjka\n",
        "output": "87\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 739,
        "task_id": 27,
        "test_case_id": 86,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nasafaass\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 740,
        "task_id": 27,
        "test_case_id": 87,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "14\nabcabcabcabcjj\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 741,
        "task_id": 27,
        "test_case_id": 88,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\nababa\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 742,
        "task_id": 27,
        "test_case_id": 89,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nbaaaaaaa\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 743,
        "task_id": 27,
        "test_case_id": 90,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nadadadadad\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 744,
        "task_id": 27,
        "test_case_id": 91,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "12\naabaabaabaab\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 745,
        "task_id": 27,
        "test_case_id": 92,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\nabcbcd\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 746,
        "task_id": 27,
        "test_case_id": 93,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\nabacbac\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 747,
        "task_id": 27,
        "test_case_id": 94,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\npppppppp\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 748,
        "task_id": 27,
        "test_case_id": 95,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "11\nabcdeabcdfg\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 749,
        "task_id": 27,
        "test_case_id": 96,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\nabcab\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 750,
        "task_id": 27,
        "test_case_id": 97,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\nabbbb\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 751,
        "task_id": 27,
        "test_case_id": 98,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\naabcdaa\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 752,
        "task_id": 27,
        "test_case_id": 99,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "6\nababbb\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 753,
        "task_id": 27,
        "test_case_id": 100,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\naaabcabc\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 754,
        "task_id": 27,
        "test_case_id": 101,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "81\naaaaaababaabaaaabaaaaaaaabbabbbbbabaabaabbaaaababaabaababbbabbaababababbbbbabbaaa\n",
        "output": "79\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 755,
        "task_id": 27,
        "test_case_id": 102,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\naaaacaaaac\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 756,
        "task_id": 27,
        "test_case_id": 103,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "12\nabaabaabaaba\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 757,
        "task_id": 27,
        "test_case_id": 104,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "92\nbbbbbabbbaaaabaaababbbaabbaabaaabbaabababaabbaabaabbbaabbaaabaabbbbaabbbabaaabbbabaaaaabaaaa\n",
        "output": "91\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 758,
        "task_id": 27,
        "test_case_id": 105,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "9\nazxcvzxcv\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 759,
        "task_id": 27,
        "test_case_id": 106,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nabcabcde\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 760,
        "task_id": 27,
        "test_case_id": 107,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "70\nbabababbabababbbabaababbababaabaabbaaabbbbaababaabaabbbbbbaaabaabbbabb\n",
        "output": "64\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 761,
        "task_id": 27,
        "test_case_id": 108,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\nabcdabc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 762,
        "task_id": 27,
        "test_case_id": 109,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "36\nbbabbaabbbabbbbbabaaabbabbbabaabbbab\n",
        "output": "34\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 763,
        "task_id": 27,
        "test_case_id": 110,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "12\nababababbbbb\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 764,
        "task_id": 27,
        "test_case_id": 111,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nacacacac\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 765,
        "task_id": 27,
        "test_case_id": 112,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "66\nldldgjllllsdjgllkfljsgfgjkflakgfsklhdhhallggagdkgdgjggfshagjgkdfld\n",
        "output": "65\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 766,
        "task_id": 27,
        "test_case_id": 113,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "74\nghhhfaddfslafhhshjflkjdgksfashhllkggllllsljlfjsjhfggkgjfalgajaldgjfghlhdsh\n",
        "output": "74\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 767,
        "task_id": 27,
        "test_case_id": 114,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "29\nabbabbaabbbbaababbababbaabbaa\n",
        "output": "27\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 768,
        "task_id": 27,
        "test_case_id": 115,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\nxabab\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 769,
        "task_id": 27,
        "test_case_id": 116,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nbbbbbbbaaa\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 770,
        "task_id": 27,
        "test_case_id": 117,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "3\nlsl\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 771,
        "task_id": 27,
        "test_case_id": 118,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "32\nbbbbaaabbaabbaabbabaaabaabaabaab\n",
        "output": "31\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 772,
        "task_id": 27,
        "test_case_id": 119,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "16\nuuuuuuuuuuuuuuuu\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 773,
        "task_id": 27,
        "test_case_id": 120,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "37\nlglfddsjhhaagkakadffkllkaagdaagdfdahg\n",
        "output": "37\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 774,
        "task_id": 27,
        "test_case_id": 121,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "45\nbbbbbbbabababbbaabbbbbbbbbbbbabbbabbaabbbabab\n",
        "output": "43\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 775,
        "task_id": 27,
        "test_case_id": 122,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "12\nwwvwwvwwvwwv\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 776,
        "task_id": 27,
        "test_case_id": 123,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "14\naaabcabcabcabc\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 777,
        "task_id": 27,
        "test_case_id": 124,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "95\nbbaaaabaababbbabaaaabababaaaaaabbababbaabbaaabbbaaaabaaaaaaababababbabbbaaaabaabaababbbbbababaa\n",
        "output": "95\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 778,
        "task_id": 27,
        "test_case_id": 125,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "4\nttob\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 779,
        "task_id": 27,
        "test_case_id": 126,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\ncabab\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 780,
        "task_id": 27,
        "test_case_id": 127,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "79\nlsfgfhhhkhklfdffssgffaghjjfkjsssjakglkajdhfkasfdhjhlkhsgsjfgsjghglkdkalaajsfdka\n",
        "output": "79\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 781,
        "task_id": 27,
        "test_case_id": 128,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "11\njjlkalfhdhh\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 782,
        "task_id": 27,
        "test_case_id": 129,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "39\njflfashaglkahldafjasagasjghjkkjgkgffgkk\n",
        "output": "39\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 783,
        "task_id": 27,
        "test_case_id": 130,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "54\ndgafkhlgdhjflkdafgjldjhgkjllfallhsggaaahkaggkhgjgflsdg\n",
        "output": "54\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 784,
        "task_id": 27,
        "test_case_id": 131,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "41\nabbababbbbbabbbabaaaababaaabaabaaabbbbbbb\n",
        "output": "41\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 785,
        "task_id": 27,
        "test_case_id": 132,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nbaaaaaab\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 786,
        "task_id": 27,
        "test_case_id": 133,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "36\nbabbbbababaaabbabbbaabaabbbbbbbbbbba\n",
        "output": "36\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 787,
        "task_id": 27,
        "test_case_id": 134,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nwvwlwvwwvw\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 788,
        "task_id": 27,
        "test_case_id": 135,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "38\nasdsssdssjajghslfhjdfdhhdggdsdfsfajfas\n",
        "output": "38\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 789,
        "task_id": 27,
        "test_case_id": 136,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "77\nbabbaababaabbaaaabbaababbbabaaaabbabaaaaaaaabbbaaabbabbbabaababbabaabbbbaaabb\n",
        "output": "77\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 790,
        "task_id": 27,
        "test_case_id": 137,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\nmabcabc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 791,
        "task_id": 27,
        "test_case_id": 138,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "86\nssjskldajkkskhljfsfkjhskaffgjjkskgddfslgjadjjgdjsjfsdgdgfdaldffjkakhhdaggalglakhjghssg\n",
        "output": "86\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 792,
        "task_id": 27,
        "test_case_id": 139,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "20\nccbbcbaabcccbabcbcaa\n",
        "output": "20\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 793,
        "task_id": 27,
        "test_case_id": 140,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\nabababaa\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 794,
        "task_id": 27,
        "test_case_id": 141,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "5\naabaa\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 795,
        "task_id": 27,
        "test_case_id": 142,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "13\neabcdefabcdef\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 796,
        "task_id": 27,
        "test_case_id": 143,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "28\naaaaaaaaaaaaaaibfprdokxvipsq\n",
        "output": "22\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 797,
        "task_id": 27,
        "test_case_id": 144,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "10\nasdasdasda\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 798,
        "task_id": 27,
        "test_case_id": 145,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "8\naaaabcde\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 799,
        "task_id": 27,
        "test_case_id": 146,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "9\nabbbbabbb\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 800,
        "task_id": 27,
        "test_case_id": 147,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "12\nababababvvvv\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 801,
        "task_id": 27,
        "test_case_id": 148,
        "question": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.\n\nInitially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. \n\nBesides, at most once you may perform one additional operation: copy the string and append it to itself.\n\nFor example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.\n\nIf you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.\n\nPrint the minimum number of operations you need to type the given string.\n\n\n-----Input-----\n\nThe first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.\n\n\n-----Output-----\n\nPrint one integer number — the minimum number of operations you need to type the given string.\n\n\n-----Examples-----\nInput\n7\nabcabca\n\nOutput\n5\n\nInput\n8\nabcdefgh\n\nOutput\n8\n\n\n\n-----Note-----\n\nThe first test described in the problem statement.\n\nIn the second test you can only type all the characters one by one.",
        "solutions": "[\"n = int(input())\\nst = input()\\nans = n\\nnow = ''\\nma = 0\\nfor i in range(n // 2):\\n    now += st[i]\\n    t = ''\\n    for j in range(i + 1, 2 * i + 2):\\n        t += st[j]\\n    if t == now:\\n        ma = i\\nprint(ans - ma)\\n\", \"n = int(input())\\nstrng = input().strip()\\nres = len(strng)\\nst = len(strng)//2\\nwhile st>0:\\n    if strng[:st] == strng[st:st*2]:\\n        print(res - st +1)\\n        return\\n    st -= 1\\n\\nprint(res)\\n\\n\\n\\n\", \"import getpass\\nimport sys\\nimport math\\nimport random\\nimport itertools\\nimport bisect\\nimport time\\n\\nfiles = True\\ndebug = False\\n\\nif getpass.getuser() == 'frohenk' and files:\\n    debug = True\\n    sys.stdin = open(\\\"test.in\\\")\\n    # sys.stdout = open('test.out', 'w')\\nelif files:\\n    # fname = \\\"gift\\\"\\n    # sys.stdin = open(\\\"%s.in\\\" % fname)\\n    # sys.stdout = open('%s.out' % fname, 'w')\\n    pass\\n\\n\\ndef lcm(a, b):\\n    return a * b // math.gcd(a, b)\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\ndef range_sum(a, b):\\n    ass = (((b - a + 1) // 2) * (a + b))\\n    if (a - b) % 2 == 0:\\n        ass += (b - a + 2) // 2\\n    return ass\\n\\n\\ndef comba(n, x):\\n    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)\\n\\n\\nn = ria()[0]\\nsuma = n\\nst = input()\\nmx = 0\\nfor i in range(1, n + 1):\\n    if i + i <= n:\\n        if st[:i] == st[i:i + i]:\\n            mx = max(mx, len(st[:i]) - 1)\\nprint(n - mx)\\n\", \"input()\\ns=input()\\nans=len(s)\\nfor i in range(len(s)//2,0,-1):\\n\\tif s[:i]==s[i:2*i]:\\n\\t\\tans=len(s)-i+1\\n\\t\\tbreak\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nanw = n\\n\\ndef calc(pos):\\n  x = s[:pos] + s[:pos]\\n  if x == s[:pos*2]:\\n    return 1+n-pos\\n  return 1e9\\n\\nfor i in range(n):\\n  anw = min(anw, calc(i))\\n  \\nprint(anw)\", \"n = int(input())\\ns = input()\\nans = n\\nfor i in range(n):\\n    ss = s[:i]\\n    if 2*i <= n and s[:i] == s[i:2*i]:\\n        ans = min(ans, n - i +1)\\nprint(ans)\", \"n = int(input())\\ns = input()\\n\\nans = n\\nfor i in range(n // 2 + 1):\\n    if s[:i] == s[i:2 * i]:\\n        # print (s[:i])\\n        ans = min(ans, i + 1 + n - 2 * i)\\nprint(ans)\\n\", \"R = lambda : list(map(int, input().split()))\\nn = int(input())\\ns = input()\\n\\nfor i in reversed(list(range(n//2))):\\n    if s[0:i+1]==s[i+1:2*i+2]:\\n        print((n-i)); return;\\n\\nprint(n)\\n\", \"def test(k):\\n    if len(s) >= 2 * k:\\n        return s[:k] == s[k: 2 * k]\\n    return False\\n\\n\\nn = int(input())\\ns = input()\\nd = 0\\nfor i in range(len(s) + 1):\\n    if test(i):\\n        d = i\\nprint(min(len(s), len(s) - 2 * d + d + 1))\\n\", \"n=int(input())\\ns=input()\\nimp=0\\nfor i in range(n//2,0,-1):\\n    if(s[:i]==s[i:2*i]):\\n        imp=i\\n        break\\nprint(min(n,n-imp+1))\", \"n = int(input())\\ns = input()\\ncurrents = s\\nans = 0\\nwhile (len(currents)>0):\\n    if (len(currents)%2==0) and (currents[0:len(currents)//2]==currents[len(currents)//2:len(s)]):\\n            ans = ans+len(currents)//2\\n            ans+=1\\n            break\\n    else:\\n        currents = currents[0:len(currents)-1]\\n        ans = ans+1\\nprint(ans)            \\n    \\n        \\n    \\n\\n    \\n\", \"n = int(input())\\na = input()\\no = ''\\nm = 0\\nfor i in range(n//2):\\n    #print(a[:i+1],a[i+1:i+i+2])\\n    if a[:i+1] == a[i+1:i+i+2]:\\n     #   print(a[:i+1])\\n        m = i\\nprint(n-m)\\n\", \"N = int(input())\\nS = input()\\ncopied = 1\\nfor i in range(1,N//2+1):\\n    # print(i, \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[:i]), \\\"\\\\\\\"{}\\\\\\\"\\\".format(S[i:2*i]))\\n    if S[:i] == S[i:2*i]:\\n        copied = i\\nprint(N-copied+1)\\n\", \"n = int(input())\\ns = input()\\nans = 1e18\\nfor c in range(n // 2 + 1):\\n    curr = c + 1 + (n - 2 * c)\\n    if c == 0:\\n        curr -= 1\\n    s1 = s[:c] * 2\\n    b = True\\n    for i in range(len(s1)):\\n        if s1[i] != s[i]:\\n            b = False\\n            break\\n    #print(c, b, curr, s1)\\n    if b:\\n        ans = min(ans, curr)\\nprint(ans)\", \"n = int(input())\\ns = input()\\nres = n\\nfor i in range(1, n//2+1):\\n\\tif s[:i] == s[i:i * 2]:\\n\\t\\tres = n-i+1\\nprint(res)\\n\", \"n = int(input())\\n\\ns = input()\\n\\nss = \\\"\\\"\\n\\ni = 0\\nlongest  = 0\\n\\nfor i in range(int(n/2)):\\n\\t#print(s[0:i+1])\\n\\t#print(s[i+1:i+i+1+1])\\n\\tif s[0:i+1] == s[i+1:i+i+1+1]:\\n\\t\\tlongest = i\\n\\nans = n-longest\\n\\nprint(ans)\\n\", \"l = int(input())\\nk = input()\\nans = 0\\nfor i in range(1, (l//2) + 1):\\n    flag = 1\\n    for j in range(0, i):\\n        if k[j] != k[i + j]:\\n            flag = 0\\n            break\\n    if flag == 1:\\n        ans = max(ans, i)\\nsu = l - (ans)\\nif ans > 0:\\n    su += 1\\nprint(su)\\n\", \"n = int(input())\\ns = str(input())\\nans = len(s)\\nfor i in range(1, n+1):\\n    if s[:i] + s[:i] == s[:2*i] and 2*i <= n:\\n        ans = min(ans, n-i+1)\\nprint(ans)\\n\", \"n = int(input())\\ns = input()\\n\\ncnt = 0\\nfor i in range(2,n//2+1):\\n\\tif s[:i] == s[i:i+i]:\\n\\t\\tcnt = i\\n\\nif cnt == 0:\\n\\tprint(n)\\nelse:\\n\\tprint(n - (cnt - 1))\\n\\n\", \"n = int(input())\\ns = input()\\nc = 0\\n\\nfor i in range(1, 1 + len(s) // 2):\\n    if s[:i] == s[i:2 * i]:\\n        c = i\\n\\nif c != 0:\\n    print(n - c + 1)\\n\\nelse:\\n    print(n)\\n\", \"n = int(input())\\nseq = input()\\ncount = n\\nfor i in range(1,n//2+1):\\n    if seq[0:i] == seq[i:min(2*i,n)]:\\n        count = n + 1 - i\\nprint(count)\", \"n=input()\\ns=input()\\nbest = 0\\nfor i in range(len(s)//2+1):\\n\\tt = s[:i]*2\\n\\t# print(t)\\n\\ttry:\\n\\t\\tif s.index(t) == 0:\\n\\t\\t\\tbest = i\\n\\texcept:\\n\\t\\tpass\\nif best > 0:\\n\\tprint(len(s) - best + 1)\\nelse:\\n\\tprint(len(s))\\t \", \"n=int(input())\\ns=input()\\ni=0\\nd=\\\"\\\"\\nls=[]\\nmx=-1\\nwhile i<n:\\n    temp=s[0:i+1]\\n    for j in range(i+1,n+1):\\n        if temp==s[i+1:j]:\\n            mx=max(mx,len(temp))\\n    i+=1\\nif mx>0:\\n    print(len(temp)-mx+1)\\nelse:\\n    print(len(temp))\", \"n = int(input())\\ns = input()\\nx = 1\\nfor i in range(1, (n >> 1) + 1):\\n    if s[:i] == s[i:2 * i]:\\n        x = i\\nprint(n - x + 1)\\n\"]",
        "difficulty": "interview",
        "input": "7\naabcabc\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/954/B"
    },
    {
        "id": 802,
        "task_id": 38,
        "test_case_id": 1,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 8\n2 4 6\n1 5 7\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 803,
        "task_id": 38,
        "test_case_id": 2,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4 9\n2 3 5 8\n0 1 3 6\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 804,
        "task_id": 38,
        "test_case_id": 4,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 9\n0 2 5 6 7\n1 3 6 7 8\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 805,
        "task_id": 38,
        "test_case_id": 5,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 60\n7 26 27 40 59\n14 22 41 42 55\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 806,
        "task_id": 38,
        "test_case_id": 6,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "20 29\n0 1 2 4 5 8 9 12 14 15 17 19 20 21 22 23 25 26 27 28\n0 2 4 5 6 7 8 10 11 12 13 14 15 16 18 19 22 23 26 28\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 807,
        "task_id": 38,
        "test_case_id": 7,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "35 41\n0 1 2 3 4 5 6 7 9 10 11 12 13 14 18 19 20 21 22 23 24 25 26 28 30 31 32 33 34 35 36 37 38 39 40\n0 1 2 3 4 5 7 8 9 10 11 12 16 17 18 19 20 21 22 23 24 26 28 29 30 31 32 33 34 35 36 37 38 39 40\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 808,
        "task_id": 38,
        "test_case_id": 10,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "50 100\n0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 809,
        "task_id": 38,
        "test_case_id": 12,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 2\n0\n1\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 810,
        "task_id": 38,
        "test_case_id": 13,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 2\n1\n0\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 811,
        "task_id": 38,
        "test_case_id": 17,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 18\n3\n10\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 812,
        "task_id": 38,
        "test_case_id": 18,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 75\n65\n8\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 813,
        "task_id": 38,
        "test_case_id": 19,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 16\n4 13\n2 11\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 814,
        "task_id": 38,
        "test_case_id": 20,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 95\n45 59\n3 84\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 815,
        "task_id": 38,
        "test_case_id": 22,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 60\n39 46 51\n43 50 55\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 816,
        "task_id": 38,
        "test_case_id": 24,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4 93\n45 48 50 90\n20 68 71 73\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 817,
        "task_id": 38,
        "test_case_id": 25,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "6 18\n0 3 8 11 15 16\n2 7 10 14 15 17\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 818,
        "task_id": 38,
        "test_case_id": 26,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "6 87\n0 1 21 31 34 66\n11 12 32 42 45 77\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 819,
        "task_id": 38,
        "test_case_id": 27,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "7 26\n0 3 9 13 14 19 20\n4 7 13 17 18 23 24\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 820,
        "task_id": 38,
        "test_case_id": 28,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "7 81\n0 12 19 24 25 35 59\n1 8 13 14 24 48 70\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 821,
        "task_id": 38,
        "test_case_id": 29,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "8 20\n0 1 2 3 5 6 14 15\n1 2 10 11 16 17 18 19\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 822,
        "task_id": 38,
        "test_case_id": 30,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "8 94\n0 8 11 27 38 54 57 89\n1 33 38 46 49 65 76 92\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 823,
        "task_id": 38,
        "test_case_id": 31,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "9 18\n1 3 6 8 11 12 13 16 17\n0 2 5 6 7 10 11 13 15\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 824,
        "task_id": 38,
        "test_case_id": 32,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "9 90\n10 11 27 33 34 55 63 84 87\n9 12 25 26 42 48 49 70 78\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 825,
        "task_id": 38,
        "test_case_id": 33,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "10 42\n4 9 10 14 15 16 19 33 36 40\n0 14 17 21 27 32 33 37 38 39\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 826,
        "task_id": 38,
        "test_case_id": 34,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "10 73\n4 5 15 19 20 25 28 42 57 58\n3 4 9 12 26 41 42 61 62 72\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 827,
        "task_id": 38,
        "test_case_id": 36,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "11 57\n1 4 27 30 31 35 37 41 50 52 56\n22 25 26 30 32 36 45 47 51 53 56\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 828,
        "task_id": 38,
        "test_case_id": 37,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "12 73\n5 9 11 20 25 36 40 41 44 48 56 60\n12 16 18 27 32 43 47 48 51 55 63 67\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 829,
        "task_id": 38,
        "test_case_id": 38,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "12 95\n1 37 42 46 56 58 59 62 64 71 76 80\n2 18 54 59 63 73 75 76 79 81 88 93\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 830,
        "task_id": 38,
        "test_case_id": 39,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "13 29\n2 5 6 9 12 17 18 19 20 21 22 24 27\n0 3 6 11 12 13 14 15 16 18 21 25 28\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 831,
        "task_id": 38,
        "test_case_id": 40,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "13 90\n9 18 23 30 31 36 39 44 58 59 74 82 87\n1 6 18 27 32 39 40 45 48 53 67 68 83\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 832,
        "task_id": 38,
        "test_case_id": 41,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "14 29\n1 2 3 4 5 7 9 12 13 20 21 22 23 24\n0 3 4 11 12 13 14 15 21 22 23 24 25 27\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 833,
        "task_id": 38,
        "test_case_id": 42,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "14 94\n7 8 9 21 34 35 36 37 38 43 46 52 84 93\n2 3 4 16 29 30 31 32 33 38 41 47 79 88\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 834,
        "task_id": 38,
        "test_case_id": 43,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "15 19\n1 2 3 4 5 6 7 8 9 10 11 13 14 16 17\n0 1 2 3 4 5 6 7 8 9 10 12 13 15 16\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 835,
        "task_id": 38,
        "test_case_id": 45,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "16 28\n3 5 6 7 9 10 11 12 13 14 17 19 20 25 26 27\n0 5 6 7 11 13 14 15 17 18 19 20 21 22 25 27\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 836,
        "task_id": 38,
        "test_case_id": 46,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "16 93\n5 6 10 11 13 14 41 43 46 61 63 70 74 79 83 92\n0 9 15 16 20 21 23 24 51 53 56 71 73 80 84 89\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 837,
        "task_id": 38,
        "test_case_id": 47,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "17 49\n2 5 11 12 16 18 19 21 22 24 36 37 38 39 40 44 47\n1 7 8 12 14 15 17 18 20 32 33 34 35 36 40 43 47\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 838,
        "task_id": 38,
        "test_case_id": 48,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "17 86\n16 17 25 33 39 41 50 51 54 56 66 70 72 73 77 80 85\n3 9 11 20 21 24 26 36 40 42 43 47 50 55 72 73 81\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 839,
        "task_id": 38,
        "test_case_id": 49,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "18 20\n0 1 2 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\n0 1 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 840,
        "task_id": 38,
        "test_case_id": 50,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "18 82\n0 5 10 13 14 16 21 28 29 30 44 46 61 64 69 71 77 78\n0 5 8 9 11 16 23 24 25 39 41 56 59 64 66 72 73 77\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 841,
        "task_id": 38,
        "test_case_id": 51,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "19 25\n0 1 2 3 5 7 9 10 12 13 16 17 18 19 20 21 22 23 24\n0 3 4 5 6 7 8 9 10 11 12 13 14 15 17 19 21 22 24\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 842,
        "task_id": 38,
        "test_case_id": 52,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "19 91\n5 17 18 20 22 25 26 31 32 33 43 47 54 61 62 64 77 80 87\n4 5 6 16 20 27 34 35 37 50 53 60 69 81 82 84 86 89 90\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 843,
        "task_id": 38,
        "test_case_id": 53,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "20 53\n2 6 8 9 16 17 20 21 22 23 25 26 35 36 38 39 44 46 47 50\n4 5 8 9 10 11 13 14 23 24 26 27 32 34 35 38 43 47 49 50\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 844,
        "task_id": 38,
        "test_case_id": 54,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "21 44\n0 1 3 4 6 7 8 9 10 11 12 15 17 18 21 22 27 29 34 36 42\n1 7 9 10 12 13 15 16 17 18 19 20 21 24 26 27 30 31 36 38 43\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 845,
        "task_id": 38,
        "test_case_id": 55,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "21 94\n3 5 6 8 9 15 16 20 28 31 35 39 49 50 53 61 71 82 85 89 90\n6 17 20 24 25 32 34 35 37 38 44 45 49 57 60 64 68 78 79 82 90\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 846,
        "task_id": 38,
        "test_case_id": 56,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "22 24\n0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 21 22 23\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 847,
        "task_id": 38,
        "test_case_id": 57,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "22 85\n3 5 7 14 18 21 25 32 38 41 53 58 61 62 66 70 71 73 75 76 79 83\n3 6 18 23 26 27 31 35 36 38 40 41 44 48 53 55 57 64 68 71 75 82\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 848,
        "task_id": 38,
        "test_case_id": 58,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "23 38\n0 2 4 5 7 8 12 13 14 16 17 18 21 22 24 27 28 30 31 32 35 36 37\n0 1 2 3 5 7 8 10 11 15 16 17 19 20 21 24 25 27 30 31 33 34 35\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 849,
        "task_id": 38,
        "test_case_id": 59,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "23 93\n1 3 5 10 19 22 26 27 30 35 39 53 55 60 66 67 75 76 77 80 82 89 90\n9 11 16 22 23 31 32 33 36 38 45 46 50 52 54 59 68 71 75 76 79 84 88\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 850,
        "task_id": 38,
        "test_case_id": 60,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "24 37\n1 4 5 6 8 11 12 13 15 16 17 19 20 21 23 26 27 28 30 31 33 34 35 36\n0 3 4 5 7 8 10 11 12 13 15 18 19 20 22 25 26 27 29 30 31 33 34 35\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 851,
        "task_id": 38,
        "test_case_id": 61,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "24 94\n9 10 13 14 16 18 19 22 24 29 32 35 48 55 57 63 64 69 72 77 78 85 90 92\n1 7 8 13 16 21 22 29 34 36 47 48 51 52 54 56 57 60 62 67 70 73 86 93\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 852,
        "task_id": 38,
        "test_case_id": 62,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "25 45\n0 1 2 4 6 7 8 9 13 14 17 19 21 22 23 25 28 29 30 31 34 36 38 39 42\n1 3 4 5 7 10 11 12 13 16 18 20 21 24 27 28 29 31 33 34 35 36 40 41 44\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 853,
        "task_id": 38,
        "test_case_id": 63,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "25 72\n1 2 6 8 9 11 15 18 19 20 26 29 31 33 34 40 41 43 45 48 58 60 68 69 71\n0 6 9 11 13 14 20 21 23 25 28 38 40 48 49 51 53 54 58 60 61 63 67 70 71\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 854,
        "task_id": 38,
        "test_case_id": 64,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "26 47\n0 2 5 7 8 9 10 12 13 14 20 22 23 25 27 29 31 32 33 35 36 37 38 42 44 45\n0 2 4 6 8 9 10 12 13 14 15 19 21 22 24 26 29 31 32 33 34 36 37 38 44 46\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 855,
        "task_id": 38,
        "test_case_id": 65,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "26 99\n0 1 13 20 21 22 25 26 27 28 32 39 44 47 56 58 60 62 71 81 83 87 89 93 94 98\n6 8 12 14 18 19 23 24 25 37 44 45 46 49 50 51 52 56 63 68 71 80 82 84 86 95\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 856,
        "task_id": 38,
        "test_case_id": 66,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "27 35\n0 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 19 20 21 23 26 27 29 30 31 32 33\n0 1 2 3 5 7 8 9 10 11 12 13 15 16 17 18 19 20 21 22 24 25 26 28 31 32 34\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 857,
        "task_id": 38,
        "test_case_id": 67,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "27 51\n1 2 4 7 8 11 13 17 20 21 23 24 25 28 29 30 34 35 37 38 40 43 45 46 47 48 50\n0 1 2 4 6 7 9 12 13 16 18 22 25 26 28 29 30 33 34 35 39 40 42 43 45 48 50\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 858,
        "task_id": 38,
        "test_case_id": 68,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "28 38\n1 4 5 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 28 29 30 32 33 35 36 37\n0 1 2 3 4 5 6 9 10 11 13 14 16 17 18 20 23 24 26 27 28 29 30 31 33 34 35 37\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 859,
        "task_id": 38,
        "test_case_id": 69,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "28 67\n0 1 2 3 6 9 10 15 18 22 24 25 30 35 36 38 39 47 48 49 51 53 55 56 58 62 63 64\n4 7 11 13 14 19 24 25 27 28 36 37 38 40 42 44 45 47 51 52 53 56 57 58 59 62 65 66\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 860,
        "task_id": 38,
        "test_case_id": 71,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "29 93\n1 2 11 13 18 21 27 28 30 38 41 42 46 54 55 56 60 61 63 64 66 69 71 72 77 81 83 89 90\n2 10 11 12 16 17 19 20 22 25 27 28 33 37 39 45 46 50 51 60 62 67 70 76 77 79 87 90 91\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 861,
        "task_id": 38,
        "test_case_id": 73,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "30 91\n1 2 3 7 8 9 13 16 17 19 27 29 38 45 47 52 53 55 61 62 66 77 78 79 80 81 82 84 88 89\n3 4 5 9 12 13 15 23 25 34 41 43 48 49 51 57 58 62 73 74 75 76 77 78 80 84 85 88 89 90\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 862,
        "task_id": 38,
        "test_case_id": 74,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "31 39\n0 1 2 3 4 5 6 7 8 10 11 13 14 17 18 20 21 23 24 25 27 28 29 30 31 33 34 35 36 37 38\n0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 21 22 25 26 28 29 31 32 33 35 36 37 38\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 863,
        "task_id": 38,
        "test_case_id": 75,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "31 95\n9 12 14 15 21 23 26 28 30 36 37 42 47 51 54 56 59 62 64 65 66 70 72 74 75 79 82 85 87 91 93\n0 2 3 7 10 13 15 19 21 32 35 37 38 44 46 49 51 53 59 60 65 70 74 77 79 82 85 87 88 89 93\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 864,
        "task_id": 38,
        "test_case_id": 76,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "32 61\n0 2 3 5 7 10 13 14 15 18 19 20 21 22 23 24 26 32 33 34 36 38 43 46 47 51 54 55 56 57 58 59\n1 2 4 6 9 12 13 14 17 18 19 20 21 22 23 25 31 32 33 35 37 42 45 46 50 53 54 55 56 57 58 60\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 865,
        "task_id": 38,
        "test_case_id": 77,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "32 86\n5 7 9 10 13 17 18 19 25 26 28 32 33 37 38 43 45 47 50 53 57 58 60 69 73 74 75 77 80 82 83 85\n7 11 12 13 15 18 20 21 23 29 31 33 34 37 41 42 43 49 50 52 56 57 61 62 67 69 71 74 77 81 82 84\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 866,
        "task_id": 38,
        "test_case_id": 78,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "33 44\n0 1 2 3 5 9 10 11 12 13 14 15 17 18 20 21 22 23 24 25 26 27 28 30 31 32 35 36 38 39 41 42 43\n0 2 3 4 7 8 10 11 13 14 15 16 17 18 19 21 25 26 27 28 29 30 31 33 34 36 37 38 39 40 41 42 43\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 867,
        "task_id": 38,
        "test_case_id": 79,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "33 73\n3 6 7 8 9 10 11 13 14 15 17 19 22 23 26 27 28 31 33 34 35 37 42 44 48 52 54 57 62 63 64 67 68\n2 3 4 7 8 16 19 20 21 22 23 24 26 27 28 30 32 35 36 39 40 41 44 46 47 48 50 55 57 61 65 67 70\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 868,
        "task_id": 38,
        "test_case_id": 80,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "34 52\n1 2 3 4 5 6 8 9 10 12 13 14 15 16 17 19 21 24 26 27 28 29 31 33 35 36 37 39 40 45 46 49 50 51\n0 1 2 3 4 6 7 8 10 11 12 13 14 15 17 19 22 24 25 26 27 29 31 33 34 35 37 38 43 44 47 48 49 51\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 869,
        "task_id": 38,
        "test_case_id": 81,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "34 68\n0 7 9 10 11 14 15 16 20 21 22 24 26 32 34 35 37 38 40 41 42 43 44 45 47 50 53 55 57 58 59 62 64 65\n0 1 2 3 5 8 11 13 15 16 17 20 22 23 26 33 35 36 37 40 41 42 46 47 48 50 52 58 60 61 63 64 66 67\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 870,
        "task_id": 38,
        "test_case_id": 82,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "35 90\n4 5 7 8 10 11 12 13 14 22 27 29 31 33 34 38 46 49 52 53 54 55 56 57 60 61 64 69 77 81 83 86 87 88 89\n4 7 10 11 12 13 14 15 18 19 22 27 35 39 41 44 45 46 47 52 53 55 56 58 59 60 61 62 70 75 77 79 81 82 86\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 871,
        "task_id": 38,
        "test_case_id": 83,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "36 43\n1 2 3 4 6 7 8 9 10 11 14 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 42\n0 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 21 23 24 25 26 28 29 30 31 32 33 36 38 39 40 41 42\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 872,
        "task_id": 38,
        "test_case_id": 84,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "36 84\n1 3 6 13 15 16 17 18 19 21 23 26 29 33 38 40 42 45 49 50 53 54 57 58 60 61 64 65 67 70 73 76 78 79 81 83\n0 2 5 8 12 17 19 21 24 28 29 32 33 36 37 39 40 43 44 46 49 52 55 57 58 60 62 64 66 69 76 78 79 80 81 82\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 873,
        "task_id": 38,
        "test_case_id": 85,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "37 46\n0 1 3 6 7 8 9 10 12 13 14 16 17 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 35 36 37 39 40 41 42 43 44\n0 3 4 5 6 7 9 10 11 13 14 16 17 18 19 20 21 22 23 24 25 26 27 28 30 31 32 33 34 36 37 38 39 40 41 43 44\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 874,
        "task_id": 38,
        "test_case_id": 86,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "37 97\n0 5 10 11 12 15 16 18 19 25 28 29 34 35 36 37 38 40 46 47 48 49 55 58 60 61 62 64 65 70 76 77 80 82 88 94 96\n1 7 13 15 16 21 26 27 28 31 32 34 35 41 44 45 50 51 52 53 54 56 62 63 64 65 71 74 76 77 78 80 81 86 92 93 96\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 875,
        "task_id": 38,
        "test_case_id": 87,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "38 58\n1 2 3 4 5 8 9 11 12 13 15 16 17 22 23 24 25 26 27 29 30 31 32 33 34 36 37 40 41 43 46 47 48 52 53 55 56 57\n1 2 3 5 6 7 8 9 12 13 15 16 17 19 20 21 26 27 28 29 30 31 33 34 35 36 37 38 40 41 44 45 47 50 51 52 56 57\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 876,
        "task_id": 38,
        "test_case_id": 88,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "38 92\n1 2 3 5 6 7 12 14 15 16 17 18 20 22 29 31 33 34 38 41 43 49 54 55 57 58 61 63 66 67 69 73 75 76 82 85 88 90\n1 3 4 10 13 16 18 21 22 23 25 26 27 32 34 35 36 37 38 40 42 49 51 53 54 58 61 63 69 74 75 77 78 81 83 86 87 89\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 877,
        "task_id": 38,
        "test_case_id": 89,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "39 59\n0 1 2 3 5 6 7 8 9 10 11 12 13 15 16 17 19 24 25 28 29 31 32 33 35 37 38 40 41 42 43 45 46 47 49 50 53 55 56\n0 1 3 4 5 6 8 9 10 12 13 16 18 19 22 23 24 25 27 28 29 30 31 32 33 34 35 37 38 39 41 46 47 50 51 53 54 55 57\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 878,
        "task_id": 38,
        "test_case_id": 90,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "39 67\n1 3 5 7 8 16 18 20 21 23 24 25 27 28 29 31 32 34 36 38 40 43 44 46 47 48 49 50 52 53 54 55 58 59 61 62 63 64 66\n0 1 2 4 6 8 10 12 13 21 23 25 26 28 29 30 32 33 34 36 37 39 41 43 45 48 49 51 52 53 54 55 57 58 59 60 63 64 66\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 879,
        "task_id": 38,
        "test_case_id": 91,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "40 63\n0 2 3 4 5 6 9 10 12 15 18 19 23 25 26 27 28 29 30 31 33 34 36 37 38 39 40 43 45 49 50 52 53 54 55 57 58 60 61 62\n1 2 3 4 5 8 10 14 15 17 18 19 20 22 23 25 26 27 28 30 31 32 33 34 37 38 40 43 46 47 51 53 54 55 56 57 58 59 61 62\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 880,
        "task_id": 38,
        "test_case_id": 92,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "40 96\n5 11 12 13 14 16 17 18 19 24 30 31 32 33 37 42 46 50 53 54 55 58 60 61 64 67 68 69 70 72 75 76 77 81 84 85 89 91 92 93\n2 7 11 15 18 19 20 23 25 26 29 32 33 34 35 37 40 41 42 46 49 50 54 56 57 58 66 72 73 74 75 77 78 79 80 85 91 92 93 94\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 881,
        "task_id": 38,
        "test_case_id": 93,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "41 67\n0 2 3 5 8 10 11 12 13 14 15 19 20 21 22 26 29 30 31 32 34 35 37 38 40 41 44 45 46 47 49 51 52 53 54 56 57 58 59 63 66\n2 3 4 5 9 12 13 14 15 17 18 20 21 23 24 27 28 29 30 32 34 35 36 37 39 40 41 42 46 49 50 52 53 55 58 60 61 62 63 64 65\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 882,
        "task_id": 38,
        "test_case_id": 94,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "41 72\n0 3 4 6 7 8 9 12 13 14 16 21 23 24 25 26 27 29 31 32 33 34 35 38 40 41 45 47 49 50 51 52 56 57 58 59 61 62 65 66 69\n0 1 4 5 6 8 13 15 16 17 18 19 21 23 24 25 26 27 30 32 33 37 39 41 42 43 44 48 49 50 51 53 54 57 58 61 64 67 68 70 71\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 883,
        "task_id": 38,
        "test_case_id": 95,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "42 48\n0 1 2 3 4 7 8 9 10 11 12 13 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 32 33 34 35 36 37 38 40 41 42 43 44 45 46 47\n0 1 2 3 4 5 6 8 9 10 11 12 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 37 38 39 40 41 42 43 45 46 47\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 884,
        "task_id": 38,
        "test_case_id": 96,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "42 81\n0 1 3 6 7 8 11 13 17 18 19 21 22 24 29 30 31 32 34 35 38 44 46 48 49 50 51 52 53 55 59 61 62 63 65 66 67 69 70 72 77 80\n0 1 3 4 6 11 12 13 14 16 17 20 26 28 30 31 32 33 34 35 37 41 43 44 45 47 48 49 51 52 54 59 62 63 64 66 69 70 71 74 76 80\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 885,
        "task_id": 38,
        "test_case_id": 97,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "43 55\n0 1 2 3 4 5 6 7 8 12 14 15 17 18 19 20 21 22 23 26 27 28 29 31 32 33 35 36 37 38 40 42 43 44 45 46 47 48 49 50 51 53 54\n1 2 4 5 6 7 8 9 10 13 14 15 16 18 19 20 22 23 24 25 27 29 30 31 32 33 34 35 36 37 38 40 41 42 43 44 45 46 47 48 49 50 54\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 886,
        "task_id": 38,
        "test_case_id": 98,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "43 81\n2 3 4 5 6 7 9 10 12 13 18 19 20 21 23 26 27 29 30 32 34 38 39 43 46 47 48 50 51 52 54 55 58 62 64 67 69 70 71 72 73 75 80\n0 3 5 6 7 8 9 11 16 19 20 21 22 23 24 26 27 29 30 35 36 37 38 40 43 44 46 47 49 51 55 56 60 63 64 65 67 68 69 71 72 75 79\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 887,
        "task_id": 38,
        "test_case_id": 99,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "44 54\n0 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 31 33 34 35 36 37 39 40 41 43 44 47 49 50 52 53\n0 1 2 3 4 5 6 7 8 10 12 13 14 15 16 18 19 20 22 23 26 28 29 31 32 33 34 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 888,
        "task_id": 38,
        "test_case_id": 100,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "44 93\n1 5 6 7 8 10 14 17 19 21 25 26 27 30 33 34 35 36 38 41 45 48 49 51 53 55 57 60 66 67 69 70 73 76 78 79 80 81 82 83 85 87 88 90\n0 2 4 8 9 10 13 16 17 18 19 21 24 28 31 32 34 36 38 40 43 49 50 52 53 56 59 61 62 63 64 65 66 68 70 71 73 77 81 82 83 84 86 90\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 889,
        "task_id": 38,
        "test_case_id": 101,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "45 47\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 43 44 45 46\n0 1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 35 36 37 38 39 40 41 42 43 44 45 46\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 890,
        "task_id": 38,
        "test_case_id": 102,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "45 71\n0 2 3 7 8 11 12 13 14 15 16 17 20 21 22 23 24 26 28 30 32 37 39 41 42 43 44 45 47 48 50 52 54 55 56 57 58 59 60 61 62 64 66 68 70\n0 1 2 3 4 7 8 9 10 11 13 15 17 19 24 26 28 29 30 31 32 34 35 37 39 41 42 43 44 45 46 47 48 49 51 53 55 57 58 60 61 65 66 69 70\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 891,
        "task_id": 38,
        "test_case_id": 104,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "46 93\n0 1 2 6 13 16 17 18 19 21 27 29 32 34 37 38 39 40 41 44 45 49 50 52 54 56 57 61 64 65 66 67 69 71 73 75 77 78 79 83 85 87 88 90 91 92\n0 2 4 5 7 8 9 10 11 12 16 23 26 27 28 29 31 37 39 42 44 47 48 49 50 51 54 55 59 60 62 64 66 67 71 74 75 76 77 79 81 83 85 87 88 89\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 892,
        "task_id": 38,
        "test_case_id": 105,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "47 49\n0 1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48\n0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 893,
        "task_id": 38,
        "test_case_id": 106,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "47 94\n0 1 3 4 5 7 8 9 14 18 19 26 30 33 34 35 37 40 42 45 46 49 50 51 52 53 55 56 60 61 62 63 64 65 66 69 71 73 75 79 84 86 87 88 90 92 93\n1 2 3 4 6 7 8 10 11 12 17 21 22 29 33 36 37 38 40 43 45 48 49 52 53 54 55 56 58 59 63 64 65 66 67 68 69 72 74 76 78 82 87 89 90 91 93\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 894,
        "task_id": 38,
        "test_case_id": 107,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "48 65\n0 1 2 4 5 6 7 8 9 10 11 12 15 16 17 20 22 24 25 26 27 28 30 32 33 34 35 37 38 39 44 45 46 47 48 50 51 52 53 54 55 56 57 58 59 61 62 63\n0 1 4 6 8 9 10 11 12 14 16 17 18 19 21 22 23 28 29 30 31 32 34 35 36 37 38 39 40 41 42 43 45 46 47 49 50 51 53 54 55 56 57 58 59 60 61 64\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 895,
        "task_id": 38,
        "test_case_id": 108,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "48 90\n1 3 4 5 8 9 11 13 14 15 16 18 20 21 24 26 29 30 31 33 34 36 37 38 39 40 42 43 44 46 47 48 51 52 55 58 59 61 62 63 65 66 68 78 79 81 82 89\n0 3 4 6 8 9 10 11 13 15 16 19 21 24 25 26 28 29 31 32 33 34 35 37 38 39 41 42 43 46 47 50 53 54 56 57 58 60 61 63 73 74 76 77 84 86 88 89\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 896,
        "task_id": 38,
        "test_case_id": 109,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "49 60\n0 1 2 5 7 8 9 10 11 12 13 14 15 16 17 19 20 21 23 25 26 27 28 29 30 31 32 33 34 36 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 58 59\n0 1 2 3 4 5 6 7 8 10 11 12 14 16 17 18 19 20 21 22 23 24 25 27 29 30 31 32 33 34 35 37 38 39 40 41 42 43 44 45 46 49 50 51 52 53 56 58 59\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 897,
        "task_id": 38,
        "test_case_id": 110,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "49 97\n0 1 2 3 6 8 11 14 19 23 26 29 32 34 35 37 39 41 43 44 45 46 51 53 63 64 65 66 67 70 71 72 73 76 77 78 79 81 83 84 86 87 90 91 92 93 94 95 96\n0 3 4 5 6 7 8 9 10 11 12 13 16 18 21 24 29 33 36 39 42 44 45 47 49 51 53 54 55 56 61 63 73 74 75 76 77 80 81 82 83 86 87 88 89 91 93 94 96\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 898,
        "task_id": 38,
        "test_case_id": 111,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "50 58\n0 1 2 3 5 6 7 8 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 49 50 54 55 56 57\n0 1 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 31 32 36 37 38 39 40 41 42 43 45 46 47 48 50 51 52 53 54 55 56 57\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 899,
        "task_id": 38,
        "test_case_id": 112,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "50 97\n1 2 3 4 7 9 10 11 12 13 14 21 22 23 24 25 28 29 30 31 32 33 34 36 37 40 41 45 53 56 59 64 65 69 70 71 72 73 74 77 81 84 85 86 87 89 91 92 95 96\n0 1 2 3 6 10 13 14 15 16 18 20 21 24 25 27 28 29 30 33 35 36 37 38 39 40 47 48 49 50 51 54 55 56 57 58 59 60 62 63 66 67 71 79 82 85 90 91 95 96\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 900,
        "task_id": 38,
        "test_case_id": 122,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "45 47\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 45 46\n0 1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 35 36 37 38 39 40 41 42 43 44 45 46\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 901,
        "task_id": 38,
        "test_case_id": 126,
        "question": "Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:\n\nThe track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. \n\nHer friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. \n\nThere are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. \n\nWrite the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. \n\n\n-----Input-----\n\nThe first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. \n\nThe second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.\n\nThe second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n3 8\n2 4 6\n1 5 7\n\nOutput\nYES\n\nInput\n4 9\n2 3 5 8\n0 1 3 6\n\nOutput\nYES\n\nInput\n2 4\n1 3\n1 2\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first test is analyzed in the statement.",
        "solutions": "[\"def main():\\n\\tn, l = map(int, input().split())\\n\\n\\tx = list(map(int, input().split()))\\n\\ty = list(map(int, input().split()))\\n\\n\\tx.append(x[0] + l)\\n\\ty.append(y[0] + l)\\n\\n\\ta = [x[i + 1] - x[i] for i in range(n)]\\n\\tb = [y[i + 1] - y[i] for i in range(n)]\\n\\n\\tfor i in range(n):\\n\\t\\tif (a == b[i:] + b[:i]):\\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn\\n\\tprint(\\\"NO\\\")\\n\\n\\nmain()\", \"import math, re, itertools as it;prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0;gcd = lambda a, b: gcd(b, a % b) if b else a;fact = lambda x: x * fact(x - 1) if x else 1;bino = lambda n, k: fact(n) / fact(k) / fact(n - k);fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2);fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2);sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10\\n\\nn, l = map(int, input().split(' '))\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\nf = False\\nfor i in range(l):\\n\\tfor j in range(len(k)):\\n\\t\\tk[j] -= 1\\n\\t\\t\\n\\t\\tif k[j] < 0:\\n\\t\\t\\tk[j] = l - 1\\n\\tk.sort()\\n\\tif k == s:\\n\\t\\tf = True\\nprint('YES' if f else 'NO')\", \"def calc_distances(points):\\n    distances = [0] * n\\n    for i in range(n):\\n        dist = points[i] - points[i - 1]\\n        if dist < 0:\\n            dist += length\\n        distances[i] = dist\\n    return distances\\n\\n\\ndef rotate(lst, i):\\n    return lst[i:] + lst[:i]\\n\\n\\nn, length = list(map(int, input().split()))\\na, b = [calc_distances(list(map(int, input().split()))) for i in range(2)]\\nfor i in range(n):\\n    if b[i] == a[0] and rotate(b, i) == a:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = map(int, input().split())\\n\\nl1 = [int(x) for x in input().split()]\\nl2 = [int(x) for x in input().split()]\\n\\ns1 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts1 += '0' * (l1[i] - prev - 1) + '1'\\n\\tprev = l1[i]\\ns1 += '0' * (l - prev - 1)\\n\\ns2 = ''\\n\\nprev = -1\\nfor i in range(n):\\n\\ts2 += '0' * (l2[i] - prev - 1) + '1'\\n\\tprev = l2[i]\\ns2 += '0' * (l - prev - 1)\\n\\ns1 = s1 * 2\\n\\nif s1.find(s2) != -1:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"n,l = map(int,input().split())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nans1 = [0] * n\\nans2 = [0] * n\\nfor j in range(n):\\n    if j == 0:\\n        \\n        ans1[j] = A[j] + (l - A[-1-j])\\n        ans2[j] = B[j] + (l - B[-1-j])\\n    else:\\n        ans1[j] = A[j] - A[j-1]\\n        ans2[j] = B[j] - B[j-1]\\nper = 0\\nfor j in range(n):\\n    if ans1 == ans2:\\n        per = 1\\n        break\\n    else:\\n        s = ans1[0]\\n        ans1 = ans1[1:]\\n        ans1.append(s)\\nif per == 1:\\n    print('YES')\\nelse:\\n    print('NO')\", \"def track(tr):\\n    res = [l - tr[-1] + tr[0]]\\n    for i in range(1, n):\\n        res.append(tr[i] - tr[i - 1])\\n    return res\\n\\ndef equals(l1, l2):\\n    for i in range(n):\\n        res = True\\n        for k in range(n):\\n            res = res and l1[k] == l2[(k + i) % n]\\n        if res:\\n            return True\\n    return False\\n\\nn, l = list(map(int, input().split()))\\na = track(list(map(int, input().split())))\\nb = track(list(map(int, input().split())))\\nif equals(a, b):\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\na = [int(x) for x in input().split()]\\nb = [int(x) for x in input().split()]\\nc = [0] * n\\nd = [0] * n\\nfor i in range(n-1):\\n    c[i] = a[i+1] - a[i]\\nc[n-1] = l - sum(c)\\n\\nfor i in range(n-1):\\n    d[i] = b[i+1] - b[i]\\nd[n-1] = l - sum(d)\\n\\n\\n\\nf = False\\nfor i in range(0, n):\\n    if d == c[i:n] + c[:i]:\\n        f = True\\n        \\nif f:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"import sys\\nN, L = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nfor shift in range(N):\\n    coincide = True\\n    diff = b[shift] - a[0]\\n    for i in range(1, N):\\n        if (a[i] + diff) % L != b[(i + shift) % N]:\\n            coincide = False\\n            break\\n    if coincide:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\", \"n, L = map(int, input().split())\\n\\nif n == 1:\\n\\tprint('YES')\\n\\treturn\\n\\nfirst = list(map(int, input().split()))\\nsecond = list(map(int, input().split()))\\n\\ndef shift(lst, value):\\n\\tfor i in range(len(lst)):\\n\\t\\tlst[i] -= value\\n\\treturn lst\\n\\ndef equal(lst1, lst2):\\n\\tfor i in range(len(lst1)):\\n\\t\\tif lst1[i] != lst2[i]:\\n\\t\\t\\treturn False\\n\\treturn True\\n\\nfirst = shift(first, first[0])\\nsecond = shift(second, second[0])\\n\\nfor i in range(n):\\n\\tfirst = shift(first, first[1])\\n\\tfirst = first[1:] + [L + first[0]]\\n\\tif equal(first, second):\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\n\\nprint('NO')\", \"n, L = tuple(map(int,input().split()))\\nkefa = list(map(int,input().split()))\\nsasha = list(map(int,input().split()))\\n\\ndiffsk, diffss = [],[]\\n\\nfor k in range(n):\\n    diffsk.append(kefa[k%n]-kefa[(k-1)%n])\\n    diffss.append(sasha[k%n]-sasha[(k-1)%n])\\n\\nres = False\\nfor j in range(n):\\n    tmp = True\\n    diff = (diffsk[0]-diffss[j])%L\\n    for i in range(n):\\n        if (diffsk[i]-diffss[(i+j)%n])%L != diff:\\n            tmp = False\\n    if tmp:\\n        res = True\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\", \"def main():\\t\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tn = int(tmp[0])\\n\\tl = int(tmp[1])\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\ta = []\\n\\tfor i in tmp : a.append(int(i))\\n\\ttmp = input()\\n\\ttmp = tmp.split(\\\" \\\")\\n\\tb = []\\n\\tfor i in tmp : b.append(int(i))\\n\\ta1 = []\\n\\tfor i in range(1,len(a)) : a1.append(a[i]-a[i-1])\\n\\ta1.append(l-a[-1]+a[0])\\n\\tb1 = []\\n\\tfor i in range(1,len(b)) : b1.append(b[i]-b[i-1])\\n\\tb1.append(l-b[-1]+b[0])\\n\\ttmp = len(a1)\\n\\tfor i in range(tmp):\\n\\t\\tlol = a1[0]\\n\\t\\ta1.pop(0)\\n\\t\\ta1.append(lol)\\n\\t\\tif (a1 == b1) : \\n\\t\\t\\tprint(\\\"YES\\\")\\n\\t\\t\\treturn 0\\n\\tprint(\\\"NO\\\")\\nmain()\", \"n, l = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nb = [int(i) for i in input().split()]\\naa = [0] * n\\nbb = [0] * n\\naa[0] = l - a[-1] + a[0]\\nbb[0] = l - b[-1] + b[0]\\nfor i in range(1, n):\\n    aa[i] = a[i] - a[i - 1]\\n    bb[i] = b[i] - b[i - 1]\\nfor i in range(n):\\n    if aa == bb:\\n        print(\\\"YES\\\")\\n        break\\n    aa.append(aa[0])\\n    aa.pop(0)\\nelse:\\n    print(\\\"NO\\\")\\n\", \"\\n\\n\\nn, l = list(map(int, input().split()))\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\n\\nfirst_diff = A[0]\\nA = [x - first_diff for x in A]\\n\\nfirst_diff = B[0]\\nB = [x - first_diff for x in B]\\n\\nfound = False\\n\\nfor _ in range(n + 2):\\n    if A == B:\\n        found = True\\n\\n    B = B[1:] + [B[0] + l]\\n    first_diff = B[0]\\n    B = [x - first_diff for x in B]\\n\\n\\nif found:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"q,w=list(map(int,input().split()))\\na=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nz=[0]*q\\nfor i in range(1,q):\\n    z[i]=a[i]-a[i-1]\\nz[0]=w-a[q-1]+a[0]\\nz=z+z+z\\nx=[0]*q\\nfor i in range(1,q):\\n    x[i]=s[i]-s[i-1]\\nx[0]=w-s[q-1]+s[0]\\nb=False\\nfor i in range(0,q+1):\\n    if z[i:i+q]==x:\\n        b=True\\nif b:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, l = map(int, input().split())\\nans = False\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nfor i in range(l):\\n    c = 1\\n    p = b[:]\\n    for j in range(n):\\n        p[j] = (b[j] + i) % l\\n    p.sort()\\n    for j in range(n):\\n        if a[j] != p[j]:\\n            c = 0\\n            break\\n    if c:\\n        print('YES')\\n        break\\nelse:\\n    print('NO')\", \"import math, sys\\n\\ndef main():\\n\\tn,l = list(map(int,input().split()))\\n\\ta = list(map(int, input().split()))\\n\\tmask = []\\n\\tfor i in range(n-1):\\n\\t\\tmask.append(a[i+1]-a[i])\\n\\tmask.append(l-a[n-1]+a[0])\\n\\t\\n\\tb = list(map(int, input().split()))\\n\\tpath = []\\n\\tfor i in range(n-1):\\n\\t\\tpath.append(b[i+1]-b[i])\\n\\tpath.append(l-b[n-1]+b[0])\\n\\t\\n\\tfor offset in range(n):\\n\\t\\tflag = True\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif mask[(i+offset)%n] != path[i]:\\n\\t\\t\\t\\tflag = False\\n\\t\\t\\t\\tbreak\\n\\t\\tif flag:\\n\\t\\t\\tprint('YES')\\n\\t\\t\\treturn\\n\\tprint('NO')\\n\\t\\t\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t \\n\\t\\t\\t\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"n, L = [int(x) for x in input().split()]\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns1 = a[n - 1]\\ns2 = b[n - 1]\\nx1 = L - s1\\nx2 = L - s2\\nc = []\\nd = []\\nc.append(a[0] + x1)\\nd.append(b[0] + x2)\\nfor i in range(n - 1):\\n    c.append(a[i + 1] - a[i])\\n    d.append(b[i + 1] - b[i])\\nfor i in range(n):\\n    k = True\\n    for j in range(n):\\n        if c[j] != d[(j + i) % n]:\\n            k = False\\n    if (k):\\n        print(\\\"YES\\\")\\n        return\\nprint(\\\"NO\\\")\\n\", \"n, l = list(map(int, input().split()))\\n\\nk = list(map(int, input().split()))\\ns = list(map(int, input().split()))\\n\\nki = [k[0]]\\nsi = [s[0]]\\n\\ntmp = 0\\nfor i in range(1, n):\\n    ki.append(k[i] - k[i - 1])\\n    si.append(s[i] - s[i - 1])\\nki[0] += l - k[-1]\\nsi[0] += l - s[-1]\\n\\nif ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n, L = map(int, input().split())\\n\\nKef = list(map(int, input().split()))\\nSas = list(map(int, input().split()))\\n\\ndKef = [Kef[i+1]-Kef[i] for i in range(n-1)]\\ndKef.append(L - Kef[n - 1] + Kef[0])\\n\\ndSas= [Sas[i+1]-Sas[i] for i in range(n-1)]\\ndSas.append(L - Sas[n - 1] + Sas[0])\\n\\nif ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"from collections import deque\\n\\nn, L = list(map(int, input().split()))\\nd1 = [int(i) for i in input().split()]\\nd2 = deque([int(i) for i in input().split()])\\nans = False\\nif n == 1:\\n    ans = True\\n\\nfor i in range(n):\\n    if ans:\\n        break\\n    diff = (d1[0]-d2[0])%L\\n    fl = True\\n    for j in range(n):\\n        if (d1[j]-d2[j])%L != diff:\\n            fl = False\\n    if fl:\\n        ans = True\\n    d2.rotate(1)\\n\\nprint([\\\"NO\\\",\\\"YES\\\"][ans])\\n\", \"k, n = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = []\\nd = []\\nfor i in range(k - 1):\\n    c += [a[i + 1] - a[i] + 1]\\n    d += [b[i + 1] - b[i] + 1]\\nc += [n - a[-1] + a[0] + 1]\\nd += [n - b[-1] + b[0] + 1]\\nfor i in range(k):\\n    if c == d[i:] + d[:i]:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n     print(\\\"NO\\\")\\n\", \"import sys\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef solve():\\n    n, L = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    for i in range(L):\\n        B_r = sorted([(b + i) % L for b in B])\\n        if A == B_r:\\n            print('YES')\\n            break\\n    else:\\n        print('NO')\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "47 49\n0 1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48\n0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/761/B"
    },
    {
        "id": 902,
        "task_id": 47,
        "test_case_id": 73,
        "question": "You are given an array $a$ consisting of $n$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.\n\nYou may choose at most one consecutive subarray of $a$ and multiply all values contained in this subarray by $x$. You want to maximize the beauty of array after applying at most one such operation.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $x$ ($1 \\le n \\le 3 \\cdot 10^5, -100 \\le x \\le 100$) — the length of array $a$ and the integer $x$ respectively.\n\nThe second line contains $n$ integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the array $a$.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible beauty of array $a$ after multiplying all values belonging to some consecutive subarray $x$.\n\n\n-----Examples-----\nInput\n5 -2\n-3 8 -2 1 -6\n\nOutput\n22\n\nInput\n12 -3\n1 3 3 7 1 3 3 7 1 3 3 7\n\nOutput\n42\n\nInput\n5 10\n-1 -2 -3 -4 -5\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first test case we need to multiply the subarray [-2, 1, -6], and the array becomes [-3, 8, 4, -2, 12] with beauty 22 ([-3, 8, 4, -2, 12]).\n\nIn the second test case we don't need to multiply any subarray at all.\n\nIn the third test case no matter which subarray we multiply, the beauty of array will be equal to 0.",
        "solutions": "[\"N, X = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\n\\ndp = [[0]*4 for _ in range(N+1)]\\n\\nfor i in range(1, N+1):\\n    dp[i][0] = max(dp[i-1][0] + A[i-1], 0)\\n    dp[i][1] = max(dp[i-1][1] + A[i-1] * X, dp[i][0])\\n    dp[i][2] = max(dp[i-1][2] + A[i-1], dp[i][1])\\n    dp[i][3] = max(dp[i-1][3], dp[i][2])\\n\\nprint(dp[N][3])\\n\", \"n, x = list(map(int, input().split()))\\ncur1 = cur2 = cur = res = 0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\\n\", \"n,x = map(int,input().split())\\nl = list(map(int,input().split()))\\nnot_used = [0 for k in range(n+1)]\\ncurrent = [0 for k in range(n+1)]\\nused =[0 for k in range(n+1)]\\nglobalMax = 0\\nfor k in range(n):\\n\\tnot_used[k+1]= max(not_used[k],0)+l[k]\\n\\tcurrent[k+1] = max(max(not_used[k],current[k]),0)+l[k]*x\\n\\tused[k+1] = max(max(current[k],used[k]),0)+l[k]\\n\\tglobalMax = max(max(globalMax,used[k+1]),max(current[k+1],not_used[k+1]))\\nprint(globalMax)\", \"n, x = map(int, input().split())\\ndp1 = [0]*n\\ndp2 = [0]*n\\ndp0 = [0]*n\\nans = 0\\nv = [int(i) for i in input().split()]\\ndp0[0] = max(0, v[0])\\ndp1[0] = v[0] * x\\ni = 0\\nans = max(ans, dp1[i], dp2[i], dp0[i])\\nfor i in range(1, n):\\n    dp0[i] = max(0, dp0[i - 1] + v[i])\\n    dp1[i] = max(dp1[i - 1] + v[i] * x, dp0[i-1] + v[i] * x)\\n    dp2[i] = max(dp1[i-1] + v[i], dp2[i - 1] + v[i])\\n    ans = max(ans, dp1[i], dp2[i], dp0[i])\\nprint(ans)\", \"n, x = map(int, input().split())\\ncur1=cur2=cur=res=0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\", \"N, X = list(map(int, input().split()))\\na_list = list(map(int, input().split()))\\n\\ndp = [[0] * 5 for _ in range(303030)]\\n\\nfor i in range(N):\\n    a = a_list[i]\\n    dp[i + 1][0] = 0\\n    dp[i + 1][1] = max(dp[i][1] + a, dp[i + 1][0])\\n    dp[i + 1][2] = max(dp[i][2] + a * X, dp[i + 1][1])\\n    dp[i + 1][3] = max(dp[i][3] + a, dp[i + 1][2])\\n    dp[i + 1][4] = max(dp[i][4], dp[i + 1][3])\\nprint(dp[N][4])\\n\", \"def main():\\n    n, x = map(int, input().split())\\n    arr = list(map(int, input().split()))\\n    dp = [[0] * 5 for _ in range(n)]\\n    dp[0] = [arr[0], arr[0] * x, 0]\\n    ans = max(dp[0])\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + arr[i], arr[i])\\n        dp[i][1] = max(dp[i - 1][0] + arr[i] * x, arr[i] * x, dp[i - 1][1] + arr[i] * x)\\n        dp[i][2] = max(dp[i - 1][2] + arr[i], dp[i - 1][1] + arr[i])\\n        ans = max(ans, max(dp[i]))\\n    print(ans)\\n    return 0\\n\\nmain()\", \"n, x = list(map(int, input().split()))\\narr = [int(x) for x in input().split()]\\ndp = [[0 for _ in range(n)] for _ in range(3)]\\ndp[0][0] = max(arr[0], 0)\\ndp[1][0] = max(arr[0] * x, 0)\\ndp[2][0] = max(arr[0], 0)\\nanswer = max(dp[0][0], dp[1][0], dp[2][0])\\nfor i in range(1, n):\\n    dp[0][i] = max(dp[0][i - 1] + arr[i], arr[i], 0)\\n    dp[1][i] = max(dp[0][i - 1] + arr[i] * x, dp[1][i - 1] + arr[i] * x, arr[i] * x, 0)\\n    dp[2][i] = max(dp[1][i - 1] + arr[i], dp[2][i - 1] + arr[i], arr[i], 0)\\n    answer = max(answer, dp[0][i], dp[1][i], dp[2][i])\\nprint(answer)\\n\", \"#  =========     /\\\\       /|    |====/|\\n#      |        /  \\\\       |    |   / |\\n#      |       /____\\\\      |    |  /  |\\n#      |      /      \\\\     |    | /   |\\n#  ========= /        \\\\  =====  |/====|  \\n#  code\\nfrom collections import Counter\\nfrom math import gcd\\n\\ndef __starting_point():\\n    n,x = map(int,input().split())\\n    a = list(map(int,input().split()))\\n    \\n    dp = [ [-1,-1,-1] for i in range(n)]\\n\\n    dp[0][0] = a[0]\\n    dp[0][1] = x*a[0]\\n    dp[0][2] = a[0]\\n    m = max(dp[0][0],dp[0][1],dp[0][2],0)\\n    for i in range(1,n):\\n        dp[i][0] = max(dp[i-1][0]+a[i],a[i])\\n        dp[i][1] = max(dp[i-1][1] + x*a[i],x*a[i],dp[i-1][0]+x*a[i])\\n        dp[i][2] = max(dp[i-1][1] + a[i],a[i],dp[i-1][2]+a[i])\\n        m = max(max(dp[i]),m)\\n    print(m)\\n__starting_point()\", \"n, x = list(map(int,input().split()))\\nl = list(map(int,input().split()))\\nb = [0] * n\\nf = [0] * n\\npref = [0] * n\\npref[0] = l[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + l[i]\\nb[0] = x * l[0]\\nmini = 0\\nfor i in range(1, n):\\n\\tmini = min(mini, pref[i - 1])\\n\\tb[i] = x * l[i] + max(b[i - 1], pref[i - 1] - mini)\\nf[n - 1] = l[n - 1] * x\\nmaksi = pref[n - 1]\\nfor i in range(1, n):\\n\\tj = n - i - 1\\n\\tmaksi = max(maksi, pref[j])\\n\\tf[j] = x * l[j] + max(f[j + 1], maksi - pref[j])\\nwyn = - 100000000000000000000000\\nfor i in range(n):\\n\\twyn = max(wyn, f[i] + b[i] - x * l[i])\\nmini = 0\\nwyn1 = -100000000000000000000000\\nfor i in range(n):\\n\\tmini = min(mini, pref[i])\\n\\twyn1 = max(wyn1, pref[i] - mini)\\nprint(max(wyn, wyn1))\", \"def main():\\n    n, x = list(map(int, input().split()))\\n    a = list(map(int, input().split()))\\n\\n    dp = [[0, 0, 0] for _ in range(n)]\\n    dp[0][0] = max(0, a[0])\\n    dp[0][1] = max(0, x * a[0])\\n    answer = max(dp[0])\\n\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + a[i], a[i])\\n        dp[i][1] = max(dp[i - 1][1] + x * a[i], x * a[i],\\n                       dp[i - 1][0] + x * a[i])\\n        dp[i][2] = max(dp[i - 1][2] + a[i], dp[i - 1][1] + a[i])\\n        answer = max(answer, *dp[i])\\n\\n    print(answer)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,x=list(map(int,input().split())) \\na=list(map(int,input().split())) \\ndp=[[0 for i in range(3)] for j in range(n+1)]\\na=[0]+a\\n#3 dps lagenge >:|)\\nres=0\\nfor i in range(1,n+1):\\n    dp[i][0]= max(0,dp[i-1][0]+a[i],a[i]) #current le ya na le\\n    dp[i][1]=max(0,dp[i-1][0]+a[i]*x,dp[i-1][1]+a[i]*x,a[i]*x) #check and see which gives the best ans\\n    dp[i][2]= max(0,a[i],dp[i-1][0]+a[i],dp[i-1][1]+a[i],dp[i-1][2]+a[i]) #main dp\\n    res=max(res,dp[i][0],dp[i][1],dp[i][2])\\n    #print(dp)\\nprint(res)\\n\\n\", \"n,x=map(int, input().split())\\nA=list(map(int,input().split()))\\nDP=[[0]*3 for _ in range(n+1)]\\nans=0\\nfor i in range(1,n+1):\\n    DP[i][0]=max(DP[i-1][0]+A[i-1],A[i-1])\\n    DP[i][1]=max(DP[i-1][0]+A[i-1]*x,DP[i-1][1]+A[i-1]*x,A[i-1]*x)\\n    DP[i][2]=max(DP[i-1][1]+A[i-1],DP[i-1][2]+A[i-1],A[i-1])\\n    ans=max(ans,max(DP[i]))\\nprint(ans)\", \"d1, d2, d3, d4 = 0, 0, 0, 0\\ne1, e2, e3, e4 = 0, 0, 0, 0\\nn, x = map(int, input().split())\\nA = list(map(int, input().split())) + [0]\\nfor a in A:\\n    e1 = max(a, d1 + a)\\n    e2 = max(x*a, d1 + x*a, d2 + x*a)\\n    e3 = max(e1, d2 + a, d3 + a)\\n    e4 = max(d1, d2, d3, d4, a)\\n    d1, d2, d3, d4 = e1, e2, e3, e4\\nprint(d4)\", \"def solve():\\n    N, X = map(int, input().split())\\n    A = [int(k) for k in input().split()]\\n    \\n    ans = 0\\n    cur_max1 = 0\\n    cur_max2 = 0\\n    cur_max3 = 0\\n    \\n    for a in A:\\n        #max sum subarray\\n        '''\\n        if A[i] > cur_max + A[i]:\\n            cur_max = A[i]\\n        else:\\n            cur_max += A[i]'''\\n        \\n        # normal max sum subarray\\n        cur_max1 = max(a, cur_max1 + a)\\n        # multiply by X\\n        cur_max2 = max(a*X, a*X + cur_max2, cur_max1)\\n        # max sum subarray with previous sum multiplied by X\\n        cur_max3 = max(a, cur_max3 + a, cur_max2)\\n            \\n        ans = max(ans, cur_max1, cur_max2, cur_max3, 0)\\n    \\n    print (ans)\\n    \\ndef __starting_point():  \\n    solve()\\n__starting_point()\", \"def printarr(dp):\\n    for i in dp:\\n        print(*i)\\n\\nn,m=list(map(int,input().split()))\\na=[0] + list(map(int,input().split()))\\ndp=[[0 ,0 ,0] for i in range(n+1)]\\nma=-1\\nfor i in range(1,n+1):\\n    dp[i][0]=max(dp[i-1][0] + a[i],0)\\n    dp[i][1]=max(dp[i-1][1] + a[i]*m, dp[i-1][0] + a[i]*m)\\n    dp[i][2]=max(dp[i-1][2] + a[i] ,a[i] + dp[i-1][1])\\n    ma=max(dp[i][0],dp[i][1],dp[i][2],ma)\\n# printarr(dp)    \\nprint(ma)    \\n\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c1 = max([c1 + A[i], 0])\\n        c2 = max([c1, c2 + A[i] * x])\\n        c3 = max([c2, c3 + A[i]])\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c11 = max([c1, 0]) + A[i]\\n        c22 = max([c1, c2, 0]) + A[i] * x\\n        c33 = max([c2, c3, 0]) + A[i]\\n        c1, c2, c3 = c11, c22, c33\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def solve():\\n    n, x = list(map(int, input().split()))\\n    a = [0] + list(map(int, input().split()))\\n    max_val = 0\\n    dp1 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp1[i] = max(dp1[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp1[i])\\n\\n    dp2 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp2[i] = max(dp1[i-1] + a[i] * x, dp2[i-1] + a[i] * x, a[i] * x)\\n        max_val = max(max_val, dp2[i])\\n\\n    dp3 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp3[i] = max(dp2[i-1] + a[i], dp3[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp3[i])\\n\\n    print(max_val)\\n\\nsolve()\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nSUM=[0]\\n\\nfor a in A:\\n    SUM.append(SUM[-1]+a)\\n\\nMAXLIST=[SUM[0]]\\nMINLIST=[SUM[0]]\\n\\nfor i in range(1,n+1):\\n    MAXLIST.append(max(MAXLIST[-1],SUM[i]))\\n    MINLIST.append(min(MINLIST[-1],SUM[i]))\\n\\nMAXLIST_INV=[SUM[-1]]\\nMINLIST_INV=[SUM[-1]]\\n\\nfor i in range(n-1,-1,-1):\\n    MAXLIST_INV.append(max(MAXLIST_INV[-1],SUM[i]))\\n    MINLIST_INV.append(min(MINLIST_INV[-1],SUM[i]))\\n\\nMAXLIST_INV=MAXLIST_INV[::-1]\\nMINLIST_INV=MINLIST_INV[::-1]\\n\\n\\nif x>0:\\n    \\n    ANS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        MINUS=MINLIST[i]\\n\\n        ANS=max(ANS,(base-MINUS)*x)\\n\\n    print(ANS)\\n\\nelse:\\n\\n    ANS=0\\n    MAX=0\\n    MIN=0\\n    MINUS=0\\n    NOWMINUS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        PLUS=MAXLIST_INV[i]#getvalues(i,n+2,0,0,seg_el)\\n\\n        ANS=max(ANS,NOWMINUS+PLUS-base+base*x)\\n\\n        MIN=min(MIN,SUM[i])\\n        \\n        if NOWMINUS<=SUM[i]-MIN+SUM[i]*(-x):\\n            NOWMINUS=SUM[i]-MIN+SUM[i]*(-x)\\n            MAX=SUM[i]\\n\\n\\n    print(ANS)  \\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP0=[0]*(n+1)\\nDP1=[0]*(n+1)\\nDP2=[0]*(n+1)\\n\\nfor i in range(n):\\n    DP0[i]=max(DP0[i-1]+A[i],A[i],0)\\n    DP1[i]=max(DP0[i-1]+A[i]*x,DP1[i-1]+A[i]*x,DP0[i])\\n    DP2[i]=max(DP2[i-1]+A[i],DP1[i-1]+A[i],DP1[i])\\n\\nprint(max(DP2))\\n\", \"\\nn,m = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ndef factiry(arr,mul):\\n    curMax,mulMax,gloMax,cur = 0,0,0,0\\n    for i in range(n):\\n        curMax=max(arr[i]+curMax,0)\\n        mulMax = max(mulMax+(arr[i]*mul),curMax)\\n        cur = max(cur+arr[i],mulMax)\\n        gloMax = max(gloMax,cur)\\n    return (gloMax)\\ntotal = factiry(a,m)\\nprint(total)\\n\\n\\n\", \"n, x = [int(i) for i in input().split()]\\nA = [int(i) for i in input().split()]\\ndp = [[-10**18 for i in range(5)] for j in range(len(A))]\\n\\nfor i in range(n-1, -1, -1):\\n    if 1:\\n        nxt = [0, 0, 0, 0, 0]\\n        if i!=n-1:\\n            nxt = dp[i+1]\\n        coeff = [0, 1, x, 1, 0]\\n        for j in range(5):\\n            for xx in range(j, len(coeff)):\\n                dp[i][j] = max(dp[i][j], coeff[xx]*A[i] + nxt[xx])\\n        \\n        \\n\\nprint(max(dp[0]))\\n\", \"# AC\\nimport sys\\nfrom math import gcd\\n\\n\\nclass Main:\\n    def __init__(self):\\n        self.buff = None\\n        self.index = 0\\n\\n    def __next__(self):\\n        if self.buff is None or self.index == len(self.buff):\\n            self.buff = sys.stdin.readline().split()\\n            self.index = 0\\n        val = self.buff[self.index]\\n        self.index += 1\\n        return val\\n\\n    def next_int(self):\\n        return int(next(self))\\n\\n    def solve(self):\\n        n = self.next_int()\\n        k = self.next_int()\\n        x = [self.next_int() for _ in range(0, n)]\\n        ans = 0\\n        dp = (0, 0, 0)\\n        for xx in x:\\n            d0 = max(0, dp[0]) + xx\\n            d1 = max(0, dp[0], dp[1]) + xx * k\\n            d2 = max(0, dp[0], dp[1], dp[2]) + xx\\n            ans = max(ans, d0, d1, d2)\\n            dp = (d0, d1, d2)\\n        print(ans)\\n\\n\\ndef __starting_point():\\n    Main().solve()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "8 1\n-7 9 -3 0 5 8 -4 3\n",
        "output": "19\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1155/D"
    },
    {
        "id": 903,
        "task_id": 47,
        "test_case_id": 86,
        "question": "You are given an array $a$ consisting of $n$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.\n\nYou may choose at most one consecutive subarray of $a$ and multiply all values contained in this subarray by $x$. You want to maximize the beauty of array after applying at most one such operation.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $x$ ($1 \\le n \\le 3 \\cdot 10^5, -100 \\le x \\le 100$) — the length of array $a$ and the integer $x$ respectively.\n\nThe second line contains $n$ integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the array $a$.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible beauty of array $a$ after multiplying all values belonging to some consecutive subarray $x$.\n\n\n-----Examples-----\nInput\n5 -2\n-3 8 -2 1 -6\n\nOutput\n22\n\nInput\n12 -3\n1 3 3 7 1 3 3 7 1 3 3 7\n\nOutput\n42\n\nInput\n5 10\n-1 -2 -3 -4 -5\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first test case we need to multiply the subarray [-2, 1, -6], and the array becomes [-3, 8, 4, -2, 12] with beauty 22 ([-3, 8, 4, -2, 12]).\n\nIn the second test case we don't need to multiply any subarray at all.\n\nIn the third test case no matter which subarray we multiply, the beauty of array will be equal to 0.",
        "solutions": "[\"N, X = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\n\\ndp = [[0]*4 for _ in range(N+1)]\\n\\nfor i in range(1, N+1):\\n    dp[i][0] = max(dp[i-1][0] + A[i-1], 0)\\n    dp[i][1] = max(dp[i-1][1] + A[i-1] * X, dp[i][0])\\n    dp[i][2] = max(dp[i-1][2] + A[i-1], dp[i][1])\\n    dp[i][3] = max(dp[i-1][3], dp[i][2])\\n\\nprint(dp[N][3])\\n\", \"n, x = list(map(int, input().split()))\\ncur1 = cur2 = cur = res = 0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\\n\", \"n,x = map(int,input().split())\\nl = list(map(int,input().split()))\\nnot_used = [0 for k in range(n+1)]\\ncurrent = [0 for k in range(n+1)]\\nused =[0 for k in range(n+1)]\\nglobalMax = 0\\nfor k in range(n):\\n\\tnot_used[k+1]= max(not_used[k],0)+l[k]\\n\\tcurrent[k+1] = max(max(not_used[k],current[k]),0)+l[k]*x\\n\\tused[k+1] = max(max(current[k],used[k]),0)+l[k]\\n\\tglobalMax = max(max(globalMax,used[k+1]),max(current[k+1],not_used[k+1]))\\nprint(globalMax)\", \"n, x = map(int, input().split())\\ndp1 = [0]*n\\ndp2 = [0]*n\\ndp0 = [0]*n\\nans = 0\\nv = [int(i) for i in input().split()]\\ndp0[0] = max(0, v[0])\\ndp1[0] = v[0] * x\\ni = 0\\nans = max(ans, dp1[i], dp2[i], dp0[i])\\nfor i in range(1, n):\\n    dp0[i] = max(0, dp0[i - 1] + v[i])\\n    dp1[i] = max(dp1[i - 1] + v[i] * x, dp0[i-1] + v[i] * x)\\n    dp2[i] = max(dp1[i-1] + v[i], dp2[i - 1] + v[i])\\n    ans = max(ans, dp1[i], dp2[i], dp0[i])\\nprint(ans)\", \"n, x = map(int, input().split())\\ncur1=cur2=cur=res=0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\", \"N, X = list(map(int, input().split()))\\na_list = list(map(int, input().split()))\\n\\ndp = [[0] * 5 for _ in range(303030)]\\n\\nfor i in range(N):\\n    a = a_list[i]\\n    dp[i + 1][0] = 0\\n    dp[i + 1][1] = max(dp[i][1] + a, dp[i + 1][0])\\n    dp[i + 1][2] = max(dp[i][2] + a * X, dp[i + 1][1])\\n    dp[i + 1][3] = max(dp[i][3] + a, dp[i + 1][2])\\n    dp[i + 1][4] = max(dp[i][4], dp[i + 1][3])\\nprint(dp[N][4])\\n\", \"def main():\\n    n, x = map(int, input().split())\\n    arr = list(map(int, input().split()))\\n    dp = [[0] * 5 for _ in range(n)]\\n    dp[0] = [arr[0], arr[0] * x, 0]\\n    ans = max(dp[0])\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + arr[i], arr[i])\\n        dp[i][1] = max(dp[i - 1][0] + arr[i] * x, arr[i] * x, dp[i - 1][1] + arr[i] * x)\\n        dp[i][2] = max(dp[i - 1][2] + arr[i], dp[i - 1][1] + arr[i])\\n        ans = max(ans, max(dp[i]))\\n    print(ans)\\n    return 0\\n\\nmain()\", \"n, x = list(map(int, input().split()))\\narr = [int(x) for x in input().split()]\\ndp = [[0 for _ in range(n)] for _ in range(3)]\\ndp[0][0] = max(arr[0], 0)\\ndp[1][0] = max(arr[0] * x, 0)\\ndp[2][0] = max(arr[0], 0)\\nanswer = max(dp[0][0], dp[1][0], dp[2][0])\\nfor i in range(1, n):\\n    dp[0][i] = max(dp[0][i - 1] + arr[i], arr[i], 0)\\n    dp[1][i] = max(dp[0][i - 1] + arr[i] * x, dp[1][i - 1] + arr[i] * x, arr[i] * x, 0)\\n    dp[2][i] = max(dp[1][i - 1] + arr[i], dp[2][i - 1] + arr[i], arr[i], 0)\\n    answer = max(answer, dp[0][i], dp[1][i], dp[2][i])\\nprint(answer)\\n\", \"#  =========     /\\\\       /|    |====/|\\n#      |        /  \\\\       |    |   / |\\n#      |       /____\\\\      |    |  /  |\\n#      |      /      \\\\     |    | /   |\\n#  ========= /        \\\\  =====  |/====|  \\n#  code\\nfrom collections import Counter\\nfrom math import gcd\\n\\ndef __starting_point():\\n    n,x = map(int,input().split())\\n    a = list(map(int,input().split()))\\n    \\n    dp = [ [-1,-1,-1] for i in range(n)]\\n\\n    dp[0][0] = a[0]\\n    dp[0][1] = x*a[0]\\n    dp[0][2] = a[0]\\n    m = max(dp[0][0],dp[0][1],dp[0][2],0)\\n    for i in range(1,n):\\n        dp[i][0] = max(dp[i-1][0]+a[i],a[i])\\n        dp[i][1] = max(dp[i-1][1] + x*a[i],x*a[i],dp[i-1][0]+x*a[i])\\n        dp[i][2] = max(dp[i-1][1] + a[i],a[i],dp[i-1][2]+a[i])\\n        m = max(max(dp[i]),m)\\n    print(m)\\n__starting_point()\", \"n, x = list(map(int,input().split()))\\nl = list(map(int,input().split()))\\nb = [0] * n\\nf = [0] * n\\npref = [0] * n\\npref[0] = l[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + l[i]\\nb[0] = x * l[0]\\nmini = 0\\nfor i in range(1, n):\\n\\tmini = min(mini, pref[i - 1])\\n\\tb[i] = x * l[i] + max(b[i - 1], pref[i - 1] - mini)\\nf[n - 1] = l[n - 1] * x\\nmaksi = pref[n - 1]\\nfor i in range(1, n):\\n\\tj = n - i - 1\\n\\tmaksi = max(maksi, pref[j])\\n\\tf[j] = x * l[j] + max(f[j + 1], maksi - pref[j])\\nwyn = - 100000000000000000000000\\nfor i in range(n):\\n\\twyn = max(wyn, f[i] + b[i] - x * l[i])\\nmini = 0\\nwyn1 = -100000000000000000000000\\nfor i in range(n):\\n\\tmini = min(mini, pref[i])\\n\\twyn1 = max(wyn1, pref[i] - mini)\\nprint(max(wyn, wyn1))\", \"def main():\\n    n, x = list(map(int, input().split()))\\n    a = list(map(int, input().split()))\\n\\n    dp = [[0, 0, 0] for _ in range(n)]\\n    dp[0][0] = max(0, a[0])\\n    dp[0][1] = max(0, x * a[0])\\n    answer = max(dp[0])\\n\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + a[i], a[i])\\n        dp[i][1] = max(dp[i - 1][1] + x * a[i], x * a[i],\\n                       dp[i - 1][0] + x * a[i])\\n        dp[i][2] = max(dp[i - 1][2] + a[i], dp[i - 1][1] + a[i])\\n        answer = max(answer, *dp[i])\\n\\n    print(answer)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,x=list(map(int,input().split())) \\na=list(map(int,input().split())) \\ndp=[[0 for i in range(3)] for j in range(n+1)]\\na=[0]+a\\n#3 dps lagenge >:|)\\nres=0\\nfor i in range(1,n+1):\\n    dp[i][0]= max(0,dp[i-1][0]+a[i],a[i]) #current le ya na le\\n    dp[i][1]=max(0,dp[i-1][0]+a[i]*x,dp[i-1][1]+a[i]*x,a[i]*x) #check and see which gives the best ans\\n    dp[i][2]= max(0,a[i],dp[i-1][0]+a[i],dp[i-1][1]+a[i],dp[i-1][2]+a[i]) #main dp\\n    res=max(res,dp[i][0],dp[i][1],dp[i][2])\\n    #print(dp)\\nprint(res)\\n\\n\", \"n,x=map(int, input().split())\\nA=list(map(int,input().split()))\\nDP=[[0]*3 for _ in range(n+1)]\\nans=0\\nfor i in range(1,n+1):\\n    DP[i][0]=max(DP[i-1][0]+A[i-1],A[i-1])\\n    DP[i][1]=max(DP[i-1][0]+A[i-1]*x,DP[i-1][1]+A[i-1]*x,A[i-1]*x)\\n    DP[i][2]=max(DP[i-1][1]+A[i-1],DP[i-1][2]+A[i-1],A[i-1])\\n    ans=max(ans,max(DP[i]))\\nprint(ans)\", \"d1, d2, d3, d4 = 0, 0, 0, 0\\ne1, e2, e3, e4 = 0, 0, 0, 0\\nn, x = map(int, input().split())\\nA = list(map(int, input().split())) + [0]\\nfor a in A:\\n    e1 = max(a, d1 + a)\\n    e2 = max(x*a, d1 + x*a, d2 + x*a)\\n    e3 = max(e1, d2 + a, d3 + a)\\n    e4 = max(d1, d2, d3, d4, a)\\n    d1, d2, d3, d4 = e1, e2, e3, e4\\nprint(d4)\", \"def solve():\\n    N, X = map(int, input().split())\\n    A = [int(k) for k in input().split()]\\n    \\n    ans = 0\\n    cur_max1 = 0\\n    cur_max2 = 0\\n    cur_max3 = 0\\n    \\n    for a in A:\\n        #max sum subarray\\n        '''\\n        if A[i] > cur_max + A[i]:\\n            cur_max = A[i]\\n        else:\\n            cur_max += A[i]'''\\n        \\n        # normal max sum subarray\\n        cur_max1 = max(a, cur_max1 + a)\\n        # multiply by X\\n        cur_max2 = max(a*X, a*X + cur_max2, cur_max1)\\n        # max sum subarray with previous sum multiplied by X\\n        cur_max3 = max(a, cur_max3 + a, cur_max2)\\n            \\n        ans = max(ans, cur_max1, cur_max2, cur_max3, 0)\\n    \\n    print (ans)\\n    \\ndef __starting_point():  \\n    solve()\\n__starting_point()\", \"def printarr(dp):\\n    for i in dp:\\n        print(*i)\\n\\nn,m=list(map(int,input().split()))\\na=[0] + list(map(int,input().split()))\\ndp=[[0 ,0 ,0] for i in range(n+1)]\\nma=-1\\nfor i in range(1,n+1):\\n    dp[i][0]=max(dp[i-1][0] + a[i],0)\\n    dp[i][1]=max(dp[i-1][1] + a[i]*m, dp[i-1][0] + a[i]*m)\\n    dp[i][2]=max(dp[i-1][2] + a[i] ,a[i] + dp[i-1][1])\\n    ma=max(dp[i][0],dp[i][1],dp[i][2],ma)\\n# printarr(dp)    \\nprint(ma)    \\n\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c1 = max([c1 + A[i], 0])\\n        c2 = max([c1, c2 + A[i] * x])\\n        c3 = max([c2, c3 + A[i]])\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c11 = max([c1, 0]) + A[i]\\n        c22 = max([c1, c2, 0]) + A[i] * x\\n        c33 = max([c2, c3, 0]) + A[i]\\n        c1, c2, c3 = c11, c22, c33\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def solve():\\n    n, x = list(map(int, input().split()))\\n    a = [0] + list(map(int, input().split()))\\n    max_val = 0\\n    dp1 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp1[i] = max(dp1[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp1[i])\\n\\n    dp2 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp2[i] = max(dp1[i-1] + a[i] * x, dp2[i-1] + a[i] * x, a[i] * x)\\n        max_val = max(max_val, dp2[i])\\n\\n    dp3 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp3[i] = max(dp2[i-1] + a[i], dp3[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp3[i])\\n\\n    print(max_val)\\n\\nsolve()\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nSUM=[0]\\n\\nfor a in A:\\n    SUM.append(SUM[-1]+a)\\n\\nMAXLIST=[SUM[0]]\\nMINLIST=[SUM[0]]\\n\\nfor i in range(1,n+1):\\n    MAXLIST.append(max(MAXLIST[-1],SUM[i]))\\n    MINLIST.append(min(MINLIST[-1],SUM[i]))\\n\\nMAXLIST_INV=[SUM[-1]]\\nMINLIST_INV=[SUM[-1]]\\n\\nfor i in range(n-1,-1,-1):\\n    MAXLIST_INV.append(max(MAXLIST_INV[-1],SUM[i]))\\n    MINLIST_INV.append(min(MINLIST_INV[-1],SUM[i]))\\n\\nMAXLIST_INV=MAXLIST_INV[::-1]\\nMINLIST_INV=MINLIST_INV[::-1]\\n\\n\\nif x>0:\\n    \\n    ANS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        MINUS=MINLIST[i]\\n\\n        ANS=max(ANS,(base-MINUS)*x)\\n\\n    print(ANS)\\n\\nelse:\\n\\n    ANS=0\\n    MAX=0\\n    MIN=0\\n    MINUS=0\\n    NOWMINUS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        PLUS=MAXLIST_INV[i]#getvalues(i,n+2,0,0,seg_el)\\n\\n        ANS=max(ANS,NOWMINUS+PLUS-base+base*x)\\n\\n        MIN=min(MIN,SUM[i])\\n        \\n        if NOWMINUS<=SUM[i]-MIN+SUM[i]*(-x):\\n            NOWMINUS=SUM[i]-MIN+SUM[i]*(-x)\\n            MAX=SUM[i]\\n\\n\\n    print(ANS)  \\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP0=[0]*(n+1)\\nDP1=[0]*(n+1)\\nDP2=[0]*(n+1)\\n\\nfor i in range(n):\\n    DP0[i]=max(DP0[i-1]+A[i],A[i],0)\\n    DP1[i]=max(DP0[i-1]+A[i]*x,DP1[i-1]+A[i]*x,DP0[i])\\n    DP2[i]=max(DP2[i-1]+A[i],DP1[i-1]+A[i],DP1[i])\\n\\nprint(max(DP2))\\n\", \"\\nn,m = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ndef factiry(arr,mul):\\n    curMax,mulMax,gloMax,cur = 0,0,0,0\\n    for i in range(n):\\n        curMax=max(arr[i]+curMax,0)\\n        mulMax = max(mulMax+(arr[i]*mul),curMax)\\n        cur = max(cur+arr[i],mulMax)\\n        gloMax = max(gloMax,cur)\\n    return (gloMax)\\ntotal = factiry(a,m)\\nprint(total)\\n\\n\\n\", \"n, x = [int(i) for i in input().split()]\\nA = [int(i) for i in input().split()]\\ndp = [[-10**18 for i in range(5)] for j in range(len(A))]\\n\\nfor i in range(n-1, -1, -1):\\n    if 1:\\n        nxt = [0, 0, 0, 0, 0]\\n        if i!=n-1:\\n            nxt = dp[i+1]\\n        coeff = [0, 1, x, 1, 0]\\n        for j in range(5):\\n            for xx in range(j, len(coeff)):\\n                dp[i][j] = max(dp[i][j], coeff[xx]*A[i] + nxt[xx])\\n        \\n        \\n\\nprint(max(dp[0]))\\n\", \"# AC\\nimport sys\\nfrom math import gcd\\n\\n\\nclass Main:\\n    def __init__(self):\\n        self.buff = None\\n        self.index = 0\\n\\n    def __next__(self):\\n        if self.buff is None or self.index == len(self.buff):\\n            self.buff = sys.stdin.readline().split()\\n            self.index = 0\\n        val = self.buff[self.index]\\n        self.index += 1\\n        return val\\n\\n    def next_int(self):\\n        return int(next(self))\\n\\n    def solve(self):\\n        n = self.next_int()\\n        k = self.next_int()\\n        x = [self.next_int() for _ in range(0, n)]\\n        ans = 0\\n        dp = (0, 0, 0)\\n        for xx in x:\\n            d0 = max(0, dp[0]) + xx\\n            d1 = max(0, dp[0], dp[1]) + xx * k\\n            d2 = max(0, dp[0], dp[1], dp[2]) + xx\\n            ans = max(ans, d0, d1, d2)\\n            dp = (d0, d1, d2)\\n        print(ans)\\n\\n\\ndef __starting_point():\\n    Main().solve()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 2\n-8 8 -1\n",
        "output": "16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1155/D"
    },
    {
        "id": 904,
        "task_id": 47,
        "test_case_id": 100,
        "question": "You are given an array $a$ consisting of $n$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.\n\nYou may choose at most one consecutive subarray of $a$ and multiply all values contained in this subarray by $x$. You want to maximize the beauty of array after applying at most one such operation.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $x$ ($1 \\le n \\le 3 \\cdot 10^5, -100 \\le x \\le 100$) — the length of array $a$ and the integer $x$ respectively.\n\nThe second line contains $n$ integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the array $a$.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible beauty of array $a$ after multiplying all values belonging to some consecutive subarray $x$.\n\n\n-----Examples-----\nInput\n5 -2\n-3 8 -2 1 -6\n\nOutput\n22\n\nInput\n12 -3\n1 3 3 7 1 3 3 7 1 3 3 7\n\nOutput\n42\n\nInput\n5 10\n-1 -2 -3 -4 -5\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first test case we need to multiply the subarray [-2, 1, -6], and the array becomes [-3, 8, 4, -2, 12] with beauty 22 ([-3, 8, 4, -2, 12]).\n\nIn the second test case we don't need to multiply any subarray at all.\n\nIn the third test case no matter which subarray we multiply, the beauty of array will be equal to 0.",
        "solutions": "[\"N, X = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\n\\ndp = [[0]*4 for _ in range(N+1)]\\n\\nfor i in range(1, N+1):\\n    dp[i][0] = max(dp[i-1][0] + A[i-1], 0)\\n    dp[i][1] = max(dp[i-1][1] + A[i-1] * X, dp[i][0])\\n    dp[i][2] = max(dp[i-1][2] + A[i-1], dp[i][1])\\n    dp[i][3] = max(dp[i-1][3], dp[i][2])\\n\\nprint(dp[N][3])\\n\", \"n, x = list(map(int, input().split()))\\ncur1 = cur2 = cur = res = 0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\\n\", \"n,x = map(int,input().split())\\nl = list(map(int,input().split()))\\nnot_used = [0 for k in range(n+1)]\\ncurrent = [0 for k in range(n+1)]\\nused =[0 for k in range(n+1)]\\nglobalMax = 0\\nfor k in range(n):\\n\\tnot_used[k+1]= max(not_used[k],0)+l[k]\\n\\tcurrent[k+1] = max(max(not_used[k],current[k]),0)+l[k]*x\\n\\tused[k+1] = max(max(current[k],used[k]),0)+l[k]\\n\\tglobalMax = max(max(globalMax,used[k+1]),max(current[k+1],not_used[k+1]))\\nprint(globalMax)\", \"n, x = map(int, input().split())\\ndp1 = [0]*n\\ndp2 = [0]*n\\ndp0 = [0]*n\\nans = 0\\nv = [int(i) for i in input().split()]\\ndp0[0] = max(0, v[0])\\ndp1[0] = v[0] * x\\ni = 0\\nans = max(ans, dp1[i], dp2[i], dp0[i])\\nfor i in range(1, n):\\n    dp0[i] = max(0, dp0[i - 1] + v[i])\\n    dp1[i] = max(dp1[i - 1] + v[i] * x, dp0[i-1] + v[i] * x)\\n    dp2[i] = max(dp1[i-1] + v[i], dp2[i - 1] + v[i])\\n    ans = max(ans, dp1[i], dp2[i], dp0[i])\\nprint(ans)\", \"n, x = map(int, input().split())\\ncur1=cur2=cur=res=0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\", \"N, X = list(map(int, input().split()))\\na_list = list(map(int, input().split()))\\n\\ndp = [[0] * 5 for _ in range(303030)]\\n\\nfor i in range(N):\\n    a = a_list[i]\\n    dp[i + 1][0] = 0\\n    dp[i + 1][1] = max(dp[i][1] + a, dp[i + 1][0])\\n    dp[i + 1][2] = max(dp[i][2] + a * X, dp[i + 1][1])\\n    dp[i + 1][3] = max(dp[i][3] + a, dp[i + 1][2])\\n    dp[i + 1][4] = max(dp[i][4], dp[i + 1][3])\\nprint(dp[N][4])\\n\", \"def main():\\n    n, x = map(int, input().split())\\n    arr = list(map(int, input().split()))\\n    dp = [[0] * 5 for _ in range(n)]\\n    dp[0] = [arr[0], arr[0] * x, 0]\\n    ans = max(dp[0])\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + arr[i], arr[i])\\n        dp[i][1] = max(dp[i - 1][0] + arr[i] * x, arr[i] * x, dp[i - 1][1] + arr[i] * x)\\n        dp[i][2] = max(dp[i - 1][2] + arr[i], dp[i - 1][1] + arr[i])\\n        ans = max(ans, max(dp[i]))\\n    print(ans)\\n    return 0\\n\\nmain()\", \"n, x = list(map(int, input().split()))\\narr = [int(x) for x in input().split()]\\ndp = [[0 for _ in range(n)] for _ in range(3)]\\ndp[0][0] = max(arr[0], 0)\\ndp[1][0] = max(arr[0] * x, 0)\\ndp[2][0] = max(arr[0], 0)\\nanswer = max(dp[0][0], dp[1][0], dp[2][0])\\nfor i in range(1, n):\\n    dp[0][i] = max(dp[0][i - 1] + arr[i], arr[i], 0)\\n    dp[1][i] = max(dp[0][i - 1] + arr[i] * x, dp[1][i - 1] + arr[i] * x, arr[i] * x, 0)\\n    dp[2][i] = max(dp[1][i - 1] + arr[i], dp[2][i - 1] + arr[i], arr[i], 0)\\n    answer = max(answer, dp[0][i], dp[1][i], dp[2][i])\\nprint(answer)\\n\", \"#  =========     /\\\\       /|    |====/|\\n#      |        /  \\\\       |    |   / |\\n#      |       /____\\\\      |    |  /  |\\n#      |      /      \\\\     |    | /   |\\n#  ========= /        \\\\  =====  |/====|  \\n#  code\\nfrom collections import Counter\\nfrom math import gcd\\n\\ndef __starting_point():\\n    n,x = map(int,input().split())\\n    a = list(map(int,input().split()))\\n    \\n    dp = [ [-1,-1,-1] for i in range(n)]\\n\\n    dp[0][0] = a[0]\\n    dp[0][1] = x*a[0]\\n    dp[0][2] = a[0]\\n    m = max(dp[0][0],dp[0][1],dp[0][2],0)\\n    for i in range(1,n):\\n        dp[i][0] = max(dp[i-1][0]+a[i],a[i])\\n        dp[i][1] = max(dp[i-1][1] + x*a[i],x*a[i],dp[i-1][0]+x*a[i])\\n        dp[i][2] = max(dp[i-1][1] + a[i],a[i],dp[i-1][2]+a[i])\\n        m = max(max(dp[i]),m)\\n    print(m)\\n__starting_point()\", \"n, x = list(map(int,input().split()))\\nl = list(map(int,input().split()))\\nb = [0] * n\\nf = [0] * n\\npref = [0] * n\\npref[0] = l[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + l[i]\\nb[0] = x * l[0]\\nmini = 0\\nfor i in range(1, n):\\n\\tmini = min(mini, pref[i - 1])\\n\\tb[i] = x * l[i] + max(b[i - 1], pref[i - 1] - mini)\\nf[n - 1] = l[n - 1] * x\\nmaksi = pref[n - 1]\\nfor i in range(1, n):\\n\\tj = n - i - 1\\n\\tmaksi = max(maksi, pref[j])\\n\\tf[j] = x * l[j] + max(f[j + 1], maksi - pref[j])\\nwyn = - 100000000000000000000000\\nfor i in range(n):\\n\\twyn = max(wyn, f[i] + b[i] - x * l[i])\\nmini = 0\\nwyn1 = -100000000000000000000000\\nfor i in range(n):\\n\\tmini = min(mini, pref[i])\\n\\twyn1 = max(wyn1, pref[i] - mini)\\nprint(max(wyn, wyn1))\", \"def main():\\n    n, x = list(map(int, input().split()))\\n    a = list(map(int, input().split()))\\n\\n    dp = [[0, 0, 0] for _ in range(n)]\\n    dp[0][0] = max(0, a[0])\\n    dp[0][1] = max(0, x * a[0])\\n    answer = max(dp[0])\\n\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + a[i], a[i])\\n        dp[i][1] = max(dp[i - 1][1] + x * a[i], x * a[i],\\n                       dp[i - 1][0] + x * a[i])\\n        dp[i][2] = max(dp[i - 1][2] + a[i], dp[i - 1][1] + a[i])\\n        answer = max(answer, *dp[i])\\n\\n    print(answer)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,x=list(map(int,input().split())) \\na=list(map(int,input().split())) \\ndp=[[0 for i in range(3)] for j in range(n+1)]\\na=[0]+a\\n#3 dps lagenge >:|)\\nres=0\\nfor i in range(1,n+1):\\n    dp[i][0]= max(0,dp[i-1][0]+a[i],a[i]) #current le ya na le\\n    dp[i][1]=max(0,dp[i-1][0]+a[i]*x,dp[i-1][1]+a[i]*x,a[i]*x) #check and see which gives the best ans\\n    dp[i][2]= max(0,a[i],dp[i-1][0]+a[i],dp[i-1][1]+a[i],dp[i-1][2]+a[i]) #main dp\\n    res=max(res,dp[i][0],dp[i][1],dp[i][2])\\n    #print(dp)\\nprint(res)\\n\\n\", \"n,x=map(int, input().split())\\nA=list(map(int,input().split()))\\nDP=[[0]*3 for _ in range(n+1)]\\nans=0\\nfor i in range(1,n+1):\\n    DP[i][0]=max(DP[i-1][0]+A[i-1],A[i-1])\\n    DP[i][1]=max(DP[i-1][0]+A[i-1]*x,DP[i-1][1]+A[i-1]*x,A[i-1]*x)\\n    DP[i][2]=max(DP[i-1][1]+A[i-1],DP[i-1][2]+A[i-1],A[i-1])\\n    ans=max(ans,max(DP[i]))\\nprint(ans)\", \"d1, d2, d3, d4 = 0, 0, 0, 0\\ne1, e2, e3, e4 = 0, 0, 0, 0\\nn, x = map(int, input().split())\\nA = list(map(int, input().split())) + [0]\\nfor a in A:\\n    e1 = max(a, d1 + a)\\n    e2 = max(x*a, d1 + x*a, d2 + x*a)\\n    e3 = max(e1, d2 + a, d3 + a)\\n    e4 = max(d1, d2, d3, d4, a)\\n    d1, d2, d3, d4 = e1, e2, e3, e4\\nprint(d4)\", \"def solve():\\n    N, X = map(int, input().split())\\n    A = [int(k) for k in input().split()]\\n    \\n    ans = 0\\n    cur_max1 = 0\\n    cur_max2 = 0\\n    cur_max3 = 0\\n    \\n    for a in A:\\n        #max sum subarray\\n        '''\\n        if A[i] > cur_max + A[i]:\\n            cur_max = A[i]\\n        else:\\n            cur_max += A[i]'''\\n        \\n        # normal max sum subarray\\n        cur_max1 = max(a, cur_max1 + a)\\n        # multiply by X\\n        cur_max2 = max(a*X, a*X + cur_max2, cur_max1)\\n        # max sum subarray with previous sum multiplied by X\\n        cur_max3 = max(a, cur_max3 + a, cur_max2)\\n            \\n        ans = max(ans, cur_max1, cur_max2, cur_max3, 0)\\n    \\n    print (ans)\\n    \\ndef __starting_point():  \\n    solve()\\n__starting_point()\", \"def printarr(dp):\\n    for i in dp:\\n        print(*i)\\n\\nn,m=list(map(int,input().split()))\\na=[0] + list(map(int,input().split()))\\ndp=[[0 ,0 ,0] for i in range(n+1)]\\nma=-1\\nfor i in range(1,n+1):\\n    dp[i][0]=max(dp[i-1][0] + a[i],0)\\n    dp[i][1]=max(dp[i-1][1] + a[i]*m, dp[i-1][0] + a[i]*m)\\n    dp[i][2]=max(dp[i-1][2] + a[i] ,a[i] + dp[i-1][1])\\n    ma=max(dp[i][0],dp[i][1],dp[i][2],ma)\\n# printarr(dp)    \\nprint(ma)    \\n\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c1 = max([c1 + A[i], 0])\\n        c2 = max([c1, c2 + A[i] * x])\\n        c3 = max([c2, c3 + A[i]])\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c11 = max([c1, 0]) + A[i]\\n        c22 = max([c1, c2, 0]) + A[i] * x\\n        c33 = max([c2, c3, 0]) + A[i]\\n        c1, c2, c3 = c11, c22, c33\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def solve():\\n    n, x = list(map(int, input().split()))\\n    a = [0] + list(map(int, input().split()))\\n    max_val = 0\\n    dp1 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp1[i] = max(dp1[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp1[i])\\n\\n    dp2 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp2[i] = max(dp1[i-1] + a[i] * x, dp2[i-1] + a[i] * x, a[i] * x)\\n        max_val = max(max_val, dp2[i])\\n\\n    dp3 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp3[i] = max(dp2[i-1] + a[i], dp3[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp3[i])\\n\\n    print(max_val)\\n\\nsolve()\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nSUM=[0]\\n\\nfor a in A:\\n    SUM.append(SUM[-1]+a)\\n\\nMAXLIST=[SUM[0]]\\nMINLIST=[SUM[0]]\\n\\nfor i in range(1,n+1):\\n    MAXLIST.append(max(MAXLIST[-1],SUM[i]))\\n    MINLIST.append(min(MINLIST[-1],SUM[i]))\\n\\nMAXLIST_INV=[SUM[-1]]\\nMINLIST_INV=[SUM[-1]]\\n\\nfor i in range(n-1,-1,-1):\\n    MAXLIST_INV.append(max(MAXLIST_INV[-1],SUM[i]))\\n    MINLIST_INV.append(min(MINLIST_INV[-1],SUM[i]))\\n\\nMAXLIST_INV=MAXLIST_INV[::-1]\\nMINLIST_INV=MINLIST_INV[::-1]\\n\\n\\nif x>0:\\n    \\n    ANS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        MINUS=MINLIST[i]\\n\\n        ANS=max(ANS,(base-MINUS)*x)\\n\\n    print(ANS)\\n\\nelse:\\n\\n    ANS=0\\n    MAX=0\\n    MIN=0\\n    MINUS=0\\n    NOWMINUS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        PLUS=MAXLIST_INV[i]#getvalues(i,n+2,0,0,seg_el)\\n\\n        ANS=max(ANS,NOWMINUS+PLUS-base+base*x)\\n\\n        MIN=min(MIN,SUM[i])\\n        \\n        if NOWMINUS<=SUM[i]-MIN+SUM[i]*(-x):\\n            NOWMINUS=SUM[i]-MIN+SUM[i]*(-x)\\n            MAX=SUM[i]\\n\\n\\n    print(ANS)  \\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP0=[0]*(n+1)\\nDP1=[0]*(n+1)\\nDP2=[0]*(n+1)\\n\\nfor i in range(n):\\n    DP0[i]=max(DP0[i-1]+A[i],A[i],0)\\n    DP1[i]=max(DP0[i-1]+A[i]*x,DP1[i-1]+A[i]*x,DP0[i])\\n    DP2[i]=max(DP2[i-1]+A[i],DP1[i-1]+A[i],DP1[i])\\n\\nprint(max(DP2))\\n\", \"\\nn,m = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ndef factiry(arr,mul):\\n    curMax,mulMax,gloMax,cur = 0,0,0,0\\n    for i in range(n):\\n        curMax=max(arr[i]+curMax,0)\\n        mulMax = max(mulMax+(arr[i]*mul),curMax)\\n        cur = max(cur+arr[i],mulMax)\\n        gloMax = max(gloMax,cur)\\n    return (gloMax)\\ntotal = factiry(a,m)\\nprint(total)\\n\\n\\n\", \"n, x = [int(i) for i in input().split()]\\nA = [int(i) for i in input().split()]\\ndp = [[-10**18 for i in range(5)] for j in range(len(A))]\\n\\nfor i in range(n-1, -1, -1):\\n    if 1:\\n        nxt = [0, 0, 0, 0, 0]\\n        if i!=n-1:\\n            nxt = dp[i+1]\\n        coeff = [0, 1, x, 1, 0]\\n        for j in range(5):\\n            for xx in range(j, len(coeff)):\\n                dp[i][j] = max(dp[i][j], coeff[xx]*A[i] + nxt[xx])\\n        \\n        \\n\\nprint(max(dp[0]))\\n\", \"# AC\\nimport sys\\nfrom math import gcd\\n\\n\\nclass Main:\\n    def __init__(self):\\n        self.buff = None\\n        self.index = 0\\n\\n    def __next__(self):\\n        if self.buff is None or self.index == len(self.buff):\\n            self.buff = sys.stdin.readline().split()\\n            self.index = 0\\n        val = self.buff[self.index]\\n        self.index += 1\\n        return val\\n\\n    def next_int(self):\\n        return int(next(self))\\n\\n    def solve(self):\\n        n = self.next_int()\\n        k = self.next_int()\\n        x = [self.next_int() for _ in range(0, n)]\\n        ans = 0\\n        dp = (0, 0, 0)\\n        for xx in x:\\n            d0 = max(0, dp[0]) + xx\\n            d1 = max(0, dp[0], dp[1]) + xx * k\\n            d2 = max(0, dp[0], dp[1], dp[2]) + xx\\n            ans = max(ans, d0, d1, d2)\\n            dp = (d0, d1, d2)\\n        print(ans)\\n\\n\\ndef __starting_point():\\n    Main().solve()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "6 5\n-100 -100 -100 -100 -100 1000\n",
        "output": "5000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1155/D"
    },
    {
        "id": 905,
        "task_id": 47,
        "test_case_id": 103,
        "question": "You are given an array $a$ consisting of $n$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.\n\nYou may choose at most one consecutive subarray of $a$ and multiply all values contained in this subarray by $x$. You want to maximize the beauty of array after applying at most one such operation.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $x$ ($1 \\le n \\le 3 \\cdot 10^5, -100 \\le x \\le 100$) — the length of array $a$ and the integer $x$ respectively.\n\nThe second line contains $n$ integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the array $a$.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible beauty of array $a$ after multiplying all values belonging to some consecutive subarray $x$.\n\n\n-----Examples-----\nInput\n5 -2\n-3 8 -2 1 -6\n\nOutput\n22\n\nInput\n12 -3\n1 3 3 7 1 3 3 7 1 3 3 7\n\nOutput\n42\n\nInput\n5 10\n-1 -2 -3 -4 -5\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first test case we need to multiply the subarray [-2, 1, -6], and the array becomes [-3, 8, 4, -2, 12] with beauty 22 ([-3, 8, 4, -2, 12]).\n\nIn the second test case we don't need to multiply any subarray at all.\n\nIn the third test case no matter which subarray we multiply, the beauty of array will be equal to 0.",
        "solutions": "[\"N, X = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\n\\ndp = [[0]*4 for _ in range(N+1)]\\n\\nfor i in range(1, N+1):\\n    dp[i][0] = max(dp[i-1][0] + A[i-1], 0)\\n    dp[i][1] = max(dp[i-1][1] + A[i-1] * X, dp[i][0])\\n    dp[i][2] = max(dp[i-1][2] + A[i-1], dp[i][1])\\n    dp[i][3] = max(dp[i-1][3], dp[i][2])\\n\\nprint(dp[N][3])\\n\", \"n, x = list(map(int, input().split()))\\ncur1 = cur2 = cur = res = 0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\\n\", \"n,x = map(int,input().split())\\nl = list(map(int,input().split()))\\nnot_used = [0 for k in range(n+1)]\\ncurrent = [0 for k in range(n+1)]\\nused =[0 for k in range(n+1)]\\nglobalMax = 0\\nfor k in range(n):\\n\\tnot_used[k+1]= max(not_used[k],0)+l[k]\\n\\tcurrent[k+1] = max(max(not_used[k],current[k]),0)+l[k]*x\\n\\tused[k+1] = max(max(current[k],used[k]),0)+l[k]\\n\\tglobalMax = max(max(globalMax,used[k+1]),max(current[k+1],not_used[k+1]))\\nprint(globalMax)\", \"n, x = map(int, input().split())\\ndp1 = [0]*n\\ndp2 = [0]*n\\ndp0 = [0]*n\\nans = 0\\nv = [int(i) for i in input().split()]\\ndp0[0] = max(0, v[0])\\ndp1[0] = v[0] * x\\ni = 0\\nans = max(ans, dp1[i], dp2[i], dp0[i])\\nfor i in range(1, n):\\n    dp0[i] = max(0, dp0[i - 1] + v[i])\\n    dp1[i] = max(dp1[i - 1] + v[i] * x, dp0[i-1] + v[i] * x)\\n    dp2[i] = max(dp1[i-1] + v[i], dp2[i - 1] + v[i])\\n    ans = max(ans, dp1[i], dp2[i], dp0[i])\\nprint(ans)\", \"n, x = map(int, input().split())\\ncur1=cur2=cur=res=0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\", \"N, X = list(map(int, input().split()))\\na_list = list(map(int, input().split()))\\n\\ndp = [[0] * 5 for _ in range(303030)]\\n\\nfor i in range(N):\\n    a = a_list[i]\\n    dp[i + 1][0] = 0\\n    dp[i + 1][1] = max(dp[i][1] + a, dp[i + 1][0])\\n    dp[i + 1][2] = max(dp[i][2] + a * X, dp[i + 1][1])\\n    dp[i + 1][3] = max(dp[i][3] + a, dp[i + 1][2])\\n    dp[i + 1][4] = max(dp[i][4], dp[i + 1][3])\\nprint(dp[N][4])\\n\", \"def main():\\n    n, x = map(int, input().split())\\n    arr = list(map(int, input().split()))\\n    dp = [[0] * 5 for _ in range(n)]\\n    dp[0] = [arr[0], arr[0] * x, 0]\\n    ans = max(dp[0])\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + arr[i], arr[i])\\n        dp[i][1] = max(dp[i - 1][0] + arr[i] * x, arr[i] * x, dp[i - 1][1] + arr[i] * x)\\n        dp[i][2] = max(dp[i - 1][2] + arr[i], dp[i - 1][1] + arr[i])\\n        ans = max(ans, max(dp[i]))\\n    print(ans)\\n    return 0\\n\\nmain()\", \"n, x = list(map(int, input().split()))\\narr = [int(x) for x in input().split()]\\ndp = [[0 for _ in range(n)] for _ in range(3)]\\ndp[0][0] = max(arr[0], 0)\\ndp[1][0] = max(arr[0] * x, 0)\\ndp[2][0] = max(arr[0], 0)\\nanswer = max(dp[0][0], dp[1][0], dp[2][0])\\nfor i in range(1, n):\\n    dp[0][i] = max(dp[0][i - 1] + arr[i], arr[i], 0)\\n    dp[1][i] = max(dp[0][i - 1] + arr[i] * x, dp[1][i - 1] + arr[i] * x, arr[i] * x, 0)\\n    dp[2][i] = max(dp[1][i - 1] + arr[i], dp[2][i - 1] + arr[i], arr[i], 0)\\n    answer = max(answer, dp[0][i], dp[1][i], dp[2][i])\\nprint(answer)\\n\", \"#  =========     /\\\\       /|    |====/|\\n#      |        /  \\\\       |    |   / |\\n#      |       /____\\\\      |    |  /  |\\n#      |      /      \\\\     |    | /   |\\n#  ========= /        \\\\  =====  |/====|  \\n#  code\\nfrom collections import Counter\\nfrom math import gcd\\n\\ndef __starting_point():\\n    n,x = map(int,input().split())\\n    a = list(map(int,input().split()))\\n    \\n    dp = [ [-1,-1,-1] for i in range(n)]\\n\\n    dp[0][0] = a[0]\\n    dp[0][1] = x*a[0]\\n    dp[0][2] = a[0]\\n    m = max(dp[0][0],dp[0][1],dp[0][2],0)\\n    for i in range(1,n):\\n        dp[i][0] = max(dp[i-1][0]+a[i],a[i])\\n        dp[i][1] = max(dp[i-1][1] + x*a[i],x*a[i],dp[i-1][0]+x*a[i])\\n        dp[i][2] = max(dp[i-1][1] + a[i],a[i],dp[i-1][2]+a[i])\\n        m = max(max(dp[i]),m)\\n    print(m)\\n__starting_point()\", \"n, x = list(map(int,input().split()))\\nl = list(map(int,input().split()))\\nb = [0] * n\\nf = [0] * n\\npref = [0] * n\\npref[0] = l[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + l[i]\\nb[0] = x * l[0]\\nmini = 0\\nfor i in range(1, n):\\n\\tmini = min(mini, pref[i - 1])\\n\\tb[i] = x * l[i] + max(b[i - 1], pref[i - 1] - mini)\\nf[n - 1] = l[n - 1] * x\\nmaksi = pref[n - 1]\\nfor i in range(1, n):\\n\\tj = n - i - 1\\n\\tmaksi = max(maksi, pref[j])\\n\\tf[j] = x * l[j] + max(f[j + 1], maksi - pref[j])\\nwyn = - 100000000000000000000000\\nfor i in range(n):\\n\\twyn = max(wyn, f[i] + b[i] - x * l[i])\\nmini = 0\\nwyn1 = -100000000000000000000000\\nfor i in range(n):\\n\\tmini = min(mini, pref[i])\\n\\twyn1 = max(wyn1, pref[i] - mini)\\nprint(max(wyn, wyn1))\", \"def main():\\n    n, x = list(map(int, input().split()))\\n    a = list(map(int, input().split()))\\n\\n    dp = [[0, 0, 0] for _ in range(n)]\\n    dp[0][0] = max(0, a[0])\\n    dp[0][1] = max(0, x * a[0])\\n    answer = max(dp[0])\\n\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + a[i], a[i])\\n        dp[i][1] = max(dp[i - 1][1] + x * a[i], x * a[i],\\n                       dp[i - 1][0] + x * a[i])\\n        dp[i][2] = max(dp[i - 1][2] + a[i], dp[i - 1][1] + a[i])\\n        answer = max(answer, *dp[i])\\n\\n    print(answer)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,x=list(map(int,input().split())) \\na=list(map(int,input().split())) \\ndp=[[0 for i in range(3)] for j in range(n+1)]\\na=[0]+a\\n#3 dps lagenge >:|)\\nres=0\\nfor i in range(1,n+1):\\n    dp[i][0]= max(0,dp[i-1][0]+a[i],a[i]) #current le ya na le\\n    dp[i][1]=max(0,dp[i-1][0]+a[i]*x,dp[i-1][1]+a[i]*x,a[i]*x) #check and see which gives the best ans\\n    dp[i][2]= max(0,a[i],dp[i-1][0]+a[i],dp[i-1][1]+a[i],dp[i-1][2]+a[i]) #main dp\\n    res=max(res,dp[i][0],dp[i][1],dp[i][2])\\n    #print(dp)\\nprint(res)\\n\\n\", \"n,x=map(int, input().split())\\nA=list(map(int,input().split()))\\nDP=[[0]*3 for _ in range(n+1)]\\nans=0\\nfor i in range(1,n+1):\\n    DP[i][0]=max(DP[i-1][0]+A[i-1],A[i-1])\\n    DP[i][1]=max(DP[i-1][0]+A[i-1]*x,DP[i-1][1]+A[i-1]*x,A[i-1]*x)\\n    DP[i][2]=max(DP[i-1][1]+A[i-1],DP[i-1][2]+A[i-1],A[i-1])\\n    ans=max(ans,max(DP[i]))\\nprint(ans)\", \"d1, d2, d3, d4 = 0, 0, 0, 0\\ne1, e2, e3, e4 = 0, 0, 0, 0\\nn, x = map(int, input().split())\\nA = list(map(int, input().split())) + [0]\\nfor a in A:\\n    e1 = max(a, d1 + a)\\n    e2 = max(x*a, d1 + x*a, d2 + x*a)\\n    e3 = max(e1, d2 + a, d3 + a)\\n    e4 = max(d1, d2, d3, d4, a)\\n    d1, d2, d3, d4 = e1, e2, e3, e4\\nprint(d4)\", \"def solve():\\n    N, X = map(int, input().split())\\n    A = [int(k) for k in input().split()]\\n    \\n    ans = 0\\n    cur_max1 = 0\\n    cur_max2 = 0\\n    cur_max3 = 0\\n    \\n    for a in A:\\n        #max sum subarray\\n        '''\\n        if A[i] > cur_max + A[i]:\\n            cur_max = A[i]\\n        else:\\n            cur_max += A[i]'''\\n        \\n        # normal max sum subarray\\n        cur_max1 = max(a, cur_max1 + a)\\n        # multiply by X\\n        cur_max2 = max(a*X, a*X + cur_max2, cur_max1)\\n        # max sum subarray with previous sum multiplied by X\\n        cur_max3 = max(a, cur_max3 + a, cur_max2)\\n            \\n        ans = max(ans, cur_max1, cur_max2, cur_max3, 0)\\n    \\n    print (ans)\\n    \\ndef __starting_point():  \\n    solve()\\n__starting_point()\", \"def printarr(dp):\\n    for i in dp:\\n        print(*i)\\n\\nn,m=list(map(int,input().split()))\\na=[0] + list(map(int,input().split()))\\ndp=[[0 ,0 ,0] for i in range(n+1)]\\nma=-1\\nfor i in range(1,n+1):\\n    dp[i][0]=max(dp[i-1][0] + a[i],0)\\n    dp[i][1]=max(dp[i-1][1] + a[i]*m, dp[i-1][0] + a[i]*m)\\n    dp[i][2]=max(dp[i-1][2] + a[i] ,a[i] + dp[i-1][1])\\n    ma=max(dp[i][0],dp[i][1],dp[i][2],ma)\\n# printarr(dp)    \\nprint(ma)    \\n\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c1 = max([c1 + A[i], 0])\\n        c2 = max([c1, c2 + A[i] * x])\\n        c3 = max([c2, c3 + A[i]])\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c11 = max([c1, 0]) + A[i]\\n        c22 = max([c1, c2, 0]) + A[i] * x\\n        c33 = max([c2, c3, 0]) + A[i]\\n        c1, c2, c3 = c11, c22, c33\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def solve():\\n    n, x = list(map(int, input().split()))\\n    a = [0] + list(map(int, input().split()))\\n    max_val = 0\\n    dp1 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp1[i] = max(dp1[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp1[i])\\n\\n    dp2 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp2[i] = max(dp1[i-1] + a[i] * x, dp2[i-1] + a[i] * x, a[i] * x)\\n        max_val = max(max_val, dp2[i])\\n\\n    dp3 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp3[i] = max(dp2[i-1] + a[i], dp3[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp3[i])\\n\\n    print(max_val)\\n\\nsolve()\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nSUM=[0]\\n\\nfor a in A:\\n    SUM.append(SUM[-1]+a)\\n\\nMAXLIST=[SUM[0]]\\nMINLIST=[SUM[0]]\\n\\nfor i in range(1,n+1):\\n    MAXLIST.append(max(MAXLIST[-1],SUM[i]))\\n    MINLIST.append(min(MINLIST[-1],SUM[i]))\\n\\nMAXLIST_INV=[SUM[-1]]\\nMINLIST_INV=[SUM[-1]]\\n\\nfor i in range(n-1,-1,-1):\\n    MAXLIST_INV.append(max(MAXLIST_INV[-1],SUM[i]))\\n    MINLIST_INV.append(min(MINLIST_INV[-1],SUM[i]))\\n\\nMAXLIST_INV=MAXLIST_INV[::-1]\\nMINLIST_INV=MINLIST_INV[::-1]\\n\\n\\nif x>0:\\n    \\n    ANS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        MINUS=MINLIST[i]\\n\\n        ANS=max(ANS,(base-MINUS)*x)\\n\\n    print(ANS)\\n\\nelse:\\n\\n    ANS=0\\n    MAX=0\\n    MIN=0\\n    MINUS=0\\n    NOWMINUS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        PLUS=MAXLIST_INV[i]#getvalues(i,n+2,0,0,seg_el)\\n\\n        ANS=max(ANS,NOWMINUS+PLUS-base+base*x)\\n\\n        MIN=min(MIN,SUM[i])\\n        \\n        if NOWMINUS<=SUM[i]-MIN+SUM[i]*(-x):\\n            NOWMINUS=SUM[i]-MIN+SUM[i]*(-x)\\n            MAX=SUM[i]\\n\\n\\n    print(ANS)  \\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP0=[0]*(n+1)\\nDP1=[0]*(n+1)\\nDP2=[0]*(n+1)\\n\\nfor i in range(n):\\n    DP0[i]=max(DP0[i-1]+A[i],A[i],0)\\n    DP1[i]=max(DP0[i-1]+A[i]*x,DP1[i-1]+A[i]*x,DP0[i])\\n    DP2[i]=max(DP2[i-1]+A[i],DP1[i-1]+A[i],DP1[i])\\n\\nprint(max(DP2))\\n\", \"\\nn,m = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ndef factiry(arr,mul):\\n    curMax,mulMax,gloMax,cur = 0,0,0,0\\n    for i in range(n):\\n        curMax=max(arr[i]+curMax,0)\\n        mulMax = max(mulMax+(arr[i]*mul),curMax)\\n        cur = max(cur+arr[i],mulMax)\\n        gloMax = max(gloMax,cur)\\n    return (gloMax)\\ntotal = factiry(a,m)\\nprint(total)\\n\\n\\n\", \"n, x = [int(i) for i in input().split()]\\nA = [int(i) for i in input().split()]\\ndp = [[-10**18 for i in range(5)] for j in range(len(A))]\\n\\nfor i in range(n-1, -1, -1):\\n    if 1:\\n        nxt = [0, 0, 0, 0, 0]\\n        if i!=n-1:\\n            nxt = dp[i+1]\\n        coeff = [0, 1, x, 1, 0]\\n        for j in range(5):\\n            for xx in range(j, len(coeff)):\\n                dp[i][j] = max(dp[i][j], coeff[xx]*A[i] + nxt[xx])\\n        \\n        \\n\\nprint(max(dp[0]))\\n\", \"# AC\\nimport sys\\nfrom math import gcd\\n\\n\\nclass Main:\\n    def __init__(self):\\n        self.buff = None\\n        self.index = 0\\n\\n    def __next__(self):\\n        if self.buff is None or self.index == len(self.buff):\\n            self.buff = sys.stdin.readline().split()\\n            self.index = 0\\n        val = self.buff[self.index]\\n        self.index += 1\\n        return val\\n\\n    def next_int(self):\\n        return int(next(self))\\n\\n    def solve(self):\\n        n = self.next_int()\\n        k = self.next_int()\\n        x = [self.next_int() for _ in range(0, n)]\\n        ans = 0\\n        dp = (0, 0, 0)\\n        for xx in x:\\n            d0 = max(0, dp[0]) + xx\\n            d1 = max(0, dp[0], dp[1]) + xx * k\\n            d2 = max(0, dp[0], dp[1], dp[2]) + xx\\n            ans = max(ans, d0, d1, d2)\\n            dp = (d0, d1, d2)\\n        print(ans)\\n\\n\\ndef __starting_point():\\n    Main().solve()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5 65\n344 -333 -155 758 -845\n",
        "output": "49270\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1155/D"
    },
    {
        "id": 906,
        "task_id": 47,
        "test_case_id": 120,
        "question": "You are given an array $a$ consisting of $n$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.\n\nYou may choose at most one consecutive subarray of $a$ and multiply all values contained in this subarray by $x$. You want to maximize the beauty of array after applying at most one such operation.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $x$ ($1 \\le n \\le 3 \\cdot 10^5, -100 \\le x \\le 100$) — the length of array $a$ and the integer $x$ respectively.\n\nThe second line contains $n$ integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the array $a$.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible beauty of array $a$ after multiplying all values belonging to some consecutive subarray $x$.\n\n\n-----Examples-----\nInput\n5 -2\n-3 8 -2 1 -6\n\nOutput\n22\n\nInput\n12 -3\n1 3 3 7 1 3 3 7 1 3 3 7\n\nOutput\n42\n\nInput\n5 10\n-1 -2 -3 -4 -5\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first test case we need to multiply the subarray [-2, 1, -6], and the array becomes [-3, 8, 4, -2, 12] with beauty 22 ([-3, 8, 4, -2, 12]).\n\nIn the second test case we don't need to multiply any subarray at all.\n\nIn the third test case no matter which subarray we multiply, the beauty of array will be equal to 0.",
        "solutions": "[\"N, X = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\n\\ndp = [[0]*4 for _ in range(N+1)]\\n\\nfor i in range(1, N+1):\\n    dp[i][0] = max(dp[i-1][0] + A[i-1], 0)\\n    dp[i][1] = max(dp[i-1][1] + A[i-1] * X, dp[i][0])\\n    dp[i][2] = max(dp[i-1][2] + A[i-1], dp[i][1])\\n    dp[i][3] = max(dp[i-1][3], dp[i][2])\\n\\nprint(dp[N][3])\\n\", \"n, x = list(map(int, input().split()))\\ncur1 = cur2 = cur = res = 0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\\n\", \"n,x = map(int,input().split())\\nl = list(map(int,input().split()))\\nnot_used = [0 for k in range(n+1)]\\ncurrent = [0 for k in range(n+1)]\\nused =[0 for k in range(n+1)]\\nglobalMax = 0\\nfor k in range(n):\\n\\tnot_used[k+1]= max(not_used[k],0)+l[k]\\n\\tcurrent[k+1] = max(max(not_used[k],current[k]),0)+l[k]*x\\n\\tused[k+1] = max(max(current[k],used[k]),0)+l[k]\\n\\tglobalMax = max(max(globalMax,used[k+1]),max(current[k+1],not_used[k+1]))\\nprint(globalMax)\", \"n, x = map(int, input().split())\\ndp1 = [0]*n\\ndp2 = [0]*n\\ndp0 = [0]*n\\nans = 0\\nv = [int(i) for i in input().split()]\\ndp0[0] = max(0, v[0])\\ndp1[0] = v[0] * x\\ni = 0\\nans = max(ans, dp1[i], dp2[i], dp0[i])\\nfor i in range(1, n):\\n    dp0[i] = max(0, dp0[i - 1] + v[i])\\n    dp1[i] = max(dp1[i - 1] + v[i] * x, dp0[i-1] + v[i] * x)\\n    dp2[i] = max(dp1[i-1] + v[i], dp2[i - 1] + v[i])\\n    ans = max(ans, dp1[i], dp2[i], dp0[i])\\nprint(ans)\", \"n, x = map(int, input().split())\\ncur1=cur2=cur=res=0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\", \"N, X = list(map(int, input().split()))\\na_list = list(map(int, input().split()))\\n\\ndp = [[0] * 5 for _ in range(303030)]\\n\\nfor i in range(N):\\n    a = a_list[i]\\n    dp[i + 1][0] = 0\\n    dp[i + 1][1] = max(dp[i][1] + a, dp[i + 1][0])\\n    dp[i + 1][2] = max(dp[i][2] + a * X, dp[i + 1][1])\\n    dp[i + 1][3] = max(dp[i][3] + a, dp[i + 1][2])\\n    dp[i + 1][4] = max(dp[i][4], dp[i + 1][3])\\nprint(dp[N][4])\\n\", \"def main():\\n    n, x = map(int, input().split())\\n    arr = list(map(int, input().split()))\\n    dp = [[0] * 5 for _ in range(n)]\\n    dp[0] = [arr[0], arr[0] * x, 0]\\n    ans = max(dp[0])\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + arr[i], arr[i])\\n        dp[i][1] = max(dp[i - 1][0] + arr[i] * x, arr[i] * x, dp[i - 1][1] + arr[i] * x)\\n        dp[i][2] = max(dp[i - 1][2] + arr[i], dp[i - 1][1] + arr[i])\\n        ans = max(ans, max(dp[i]))\\n    print(ans)\\n    return 0\\n\\nmain()\", \"n, x = list(map(int, input().split()))\\narr = [int(x) for x in input().split()]\\ndp = [[0 for _ in range(n)] for _ in range(3)]\\ndp[0][0] = max(arr[0], 0)\\ndp[1][0] = max(arr[0] * x, 0)\\ndp[2][0] = max(arr[0], 0)\\nanswer = max(dp[0][0], dp[1][0], dp[2][0])\\nfor i in range(1, n):\\n    dp[0][i] = max(dp[0][i - 1] + arr[i], arr[i], 0)\\n    dp[1][i] = max(dp[0][i - 1] + arr[i] * x, dp[1][i - 1] + arr[i] * x, arr[i] * x, 0)\\n    dp[2][i] = max(dp[1][i - 1] + arr[i], dp[2][i - 1] + arr[i], arr[i], 0)\\n    answer = max(answer, dp[0][i], dp[1][i], dp[2][i])\\nprint(answer)\\n\", \"#  =========     /\\\\       /|    |====/|\\n#      |        /  \\\\       |    |   / |\\n#      |       /____\\\\      |    |  /  |\\n#      |      /      \\\\     |    | /   |\\n#  ========= /        \\\\  =====  |/====|  \\n#  code\\nfrom collections import Counter\\nfrom math import gcd\\n\\ndef __starting_point():\\n    n,x = map(int,input().split())\\n    a = list(map(int,input().split()))\\n    \\n    dp = [ [-1,-1,-1] for i in range(n)]\\n\\n    dp[0][0] = a[0]\\n    dp[0][1] = x*a[0]\\n    dp[0][2] = a[0]\\n    m = max(dp[0][0],dp[0][1],dp[0][2],0)\\n    for i in range(1,n):\\n        dp[i][0] = max(dp[i-1][0]+a[i],a[i])\\n        dp[i][1] = max(dp[i-1][1] + x*a[i],x*a[i],dp[i-1][0]+x*a[i])\\n        dp[i][2] = max(dp[i-1][1] + a[i],a[i],dp[i-1][2]+a[i])\\n        m = max(max(dp[i]),m)\\n    print(m)\\n__starting_point()\", \"n, x = list(map(int,input().split()))\\nl = list(map(int,input().split()))\\nb = [0] * n\\nf = [0] * n\\npref = [0] * n\\npref[0] = l[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + l[i]\\nb[0] = x * l[0]\\nmini = 0\\nfor i in range(1, n):\\n\\tmini = min(mini, pref[i - 1])\\n\\tb[i] = x * l[i] + max(b[i - 1], pref[i - 1] - mini)\\nf[n - 1] = l[n - 1] * x\\nmaksi = pref[n - 1]\\nfor i in range(1, n):\\n\\tj = n - i - 1\\n\\tmaksi = max(maksi, pref[j])\\n\\tf[j] = x * l[j] + max(f[j + 1], maksi - pref[j])\\nwyn = - 100000000000000000000000\\nfor i in range(n):\\n\\twyn = max(wyn, f[i] + b[i] - x * l[i])\\nmini = 0\\nwyn1 = -100000000000000000000000\\nfor i in range(n):\\n\\tmini = min(mini, pref[i])\\n\\twyn1 = max(wyn1, pref[i] - mini)\\nprint(max(wyn, wyn1))\", \"def main():\\n    n, x = list(map(int, input().split()))\\n    a = list(map(int, input().split()))\\n\\n    dp = [[0, 0, 0] for _ in range(n)]\\n    dp[0][0] = max(0, a[0])\\n    dp[0][1] = max(0, x * a[0])\\n    answer = max(dp[0])\\n\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + a[i], a[i])\\n        dp[i][1] = max(dp[i - 1][1] + x * a[i], x * a[i],\\n                       dp[i - 1][0] + x * a[i])\\n        dp[i][2] = max(dp[i - 1][2] + a[i], dp[i - 1][1] + a[i])\\n        answer = max(answer, *dp[i])\\n\\n    print(answer)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,x=list(map(int,input().split())) \\na=list(map(int,input().split())) \\ndp=[[0 for i in range(3)] for j in range(n+1)]\\na=[0]+a\\n#3 dps lagenge >:|)\\nres=0\\nfor i in range(1,n+1):\\n    dp[i][0]= max(0,dp[i-1][0]+a[i],a[i]) #current le ya na le\\n    dp[i][1]=max(0,dp[i-1][0]+a[i]*x,dp[i-1][1]+a[i]*x,a[i]*x) #check and see which gives the best ans\\n    dp[i][2]= max(0,a[i],dp[i-1][0]+a[i],dp[i-1][1]+a[i],dp[i-1][2]+a[i]) #main dp\\n    res=max(res,dp[i][0],dp[i][1],dp[i][2])\\n    #print(dp)\\nprint(res)\\n\\n\", \"n,x=map(int, input().split())\\nA=list(map(int,input().split()))\\nDP=[[0]*3 for _ in range(n+1)]\\nans=0\\nfor i in range(1,n+1):\\n    DP[i][0]=max(DP[i-1][0]+A[i-1],A[i-1])\\n    DP[i][1]=max(DP[i-1][0]+A[i-1]*x,DP[i-1][1]+A[i-1]*x,A[i-1]*x)\\n    DP[i][2]=max(DP[i-1][1]+A[i-1],DP[i-1][2]+A[i-1],A[i-1])\\n    ans=max(ans,max(DP[i]))\\nprint(ans)\", \"d1, d2, d3, d4 = 0, 0, 0, 0\\ne1, e2, e3, e4 = 0, 0, 0, 0\\nn, x = map(int, input().split())\\nA = list(map(int, input().split())) + [0]\\nfor a in A:\\n    e1 = max(a, d1 + a)\\n    e2 = max(x*a, d1 + x*a, d2 + x*a)\\n    e3 = max(e1, d2 + a, d3 + a)\\n    e4 = max(d1, d2, d3, d4, a)\\n    d1, d2, d3, d4 = e1, e2, e3, e4\\nprint(d4)\", \"def solve():\\n    N, X = map(int, input().split())\\n    A = [int(k) for k in input().split()]\\n    \\n    ans = 0\\n    cur_max1 = 0\\n    cur_max2 = 0\\n    cur_max3 = 0\\n    \\n    for a in A:\\n        #max sum subarray\\n        '''\\n        if A[i] > cur_max + A[i]:\\n            cur_max = A[i]\\n        else:\\n            cur_max += A[i]'''\\n        \\n        # normal max sum subarray\\n        cur_max1 = max(a, cur_max1 + a)\\n        # multiply by X\\n        cur_max2 = max(a*X, a*X + cur_max2, cur_max1)\\n        # max sum subarray with previous sum multiplied by X\\n        cur_max3 = max(a, cur_max3 + a, cur_max2)\\n            \\n        ans = max(ans, cur_max1, cur_max2, cur_max3, 0)\\n    \\n    print (ans)\\n    \\ndef __starting_point():  \\n    solve()\\n__starting_point()\", \"def printarr(dp):\\n    for i in dp:\\n        print(*i)\\n\\nn,m=list(map(int,input().split()))\\na=[0] + list(map(int,input().split()))\\ndp=[[0 ,0 ,0] for i in range(n+1)]\\nma=-1\\nfor i in range(1,n+1):\\n    dp[i][0]=max(dp[i-1][0] + a[i],0)\\n    dp[i][1]=max(dp[i-1][1] + a[i]*m, dp[i-1][0] + a[i]*m)\\n    dp[i][2]=max(dp[i-1][2] + a[i] ,a[i] + dp[i-1][1])\\n    ma=max(dp[i][0],dp[i][1],dp[i][2],ma)\\n# printarr(dp)    \\nprint(ma)    \\n\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c1 = max([c1 + A[i], 0])\\n        c2 = max([c1, c2 + A[i] * x])\\n        c3 = max([c2, c3 + A[i]])\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c11 = max([c1, 0]) + A[i]\\n        c22 = max([c1, c2, 0]) + A[i] * x\\n        c33 = max([c2, c3, 0]) + A[i]\\n        c1, c2, c3 = c11, c22, c33\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def solve():\\n    n, x = list(map(int, input().split()))\\n    a = [0] + list(map(int, input().split()))\\n    max_val = 0\\n    dp1 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp1[i] = max(dp1[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp1[i])\\n\\n    dp2 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp2[i] = max(dp1[i-1] + a[i] * x, dp2[i-1] + a[i] * x, a[i] * x)\\n        max_val = max(max_val, dp2[i])\\n\\n    dp3 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp3[i] = max(dp2[i-1] + a[i], dp3[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp3[i])\\n\\n    print(max_val)\\n\\nsolve()\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nSUM=[0]\\n\\nfor a in A:\\n    SUM.append(SUM[-1]+a)\\n\\nMAXLIST=[SUM[0]]\\nMINLIST=[SUM[0]]\\n\\nfor i in range(1,n+1):\\n    MAXLIST.append(max(MAXLIST[-1],SUM[i]))\\n    MINLIST.append(min(MINLIST[-1],SUM[i]))\\n\\nMAXLIST_INV=[SUM[-1]]\\nMINLIST_INV=[SUM[-1]]\\n\\nfor i in range(n-1,-1,-1):\\n    MAXLIST_INV.append(max(MAXLIST_INV[-1],SUM[i]))\\n    MINLIST_INV.append(min(MINLIST_INV[-1],SUM[i]))\\n\\nMAXLIST_INV=MAXLIST_INV[::-1]\\nMINLIST_INV=MINLIST_INV[::-1]\\n\\n\\nif x>0:\\n    \\n    ANS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        MINUS=MINLIST[i]\\n\\n        ANS=max(ANS,(base-MINUS)*x)\\n\\n    print(ANS)\\n\\nelse:\\n\\n    ANS=0\\n    MAX=0\\n    MIN=0\\n    MINUS=0\\n    NOWMINUS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        PLUS=MAXLIST_INV[i]#getvalues(i,n+2,0,0,seg_el)\\n\\n        ANS=max(ANS,NOWMINUS+PLUS-base+base*x)\\n\\n        MIN=min(MIN,SUM[i])\\n        \\n        if NOWMINUS<=SUM[i]-MIN+SUM[i]*(-x):\\n            NOWMINUS=SUM[i]-MIN+SUM[i]*(-x)\\n            MAX=SUM[i]\\n\\n\\n    print(ANS)  \\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP0=[0]*(n+1)\\nDP1=[0]*(n+1)\\nDP2=[0]*(n+1)\\n\\nfor i in range(n):\\n    DP0[i]=max(DP0[i-1]+A[i],A[i],0)\\n    DP1[i]=max(DP0[i-1]+A[i]*x,DP1[i-1]+A[i]*x,DP0[i])\\n    DP2[i]=max(DP2[i-1]+A[i],DP1[i-1]+A[i],DP1[i])\\n\\nprint(max(DP2))\\n\", \"\\nn,m = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ndef factiry(arr,mul):\\n    curMax,mulMax,gloMax,cur = 0,0,0,0\\n    for i in range(n):\\n        curMax=max(arr[i]+curMax,0)\\n        mulMax = max(mulMax+(arr[i]*mul),curMax)\\n        cur = max(cur+arr[i],mulMax)\\n        gloMax = max(gloMax,cur)\\n    return (gloMax)\\ntotal = factiry(a,m)\\nprint(total)\\n\\n\\n\", \"n, x = [int(i) for i in input().split()]\\nA = [int(i) for i in input().split()]\\ndp = [[-10**18 for i in range(5)] for j in range(len(A))]\\n\\nfor i in range(n-1, -1, -1):\\n    if 1:\\n        nxt = [0, 0, 0, 0, 0]\\n        if i!=n-1:\\n            nxt = dp[i+1]\\n        coeff = [0, 1, x, 1, 0]\\n        for j in range(5):\\n            for xx in range(j, len(coeff)):\\n                dp[i][j] = max(dp[i][j], coeff[xx]*A[i] + nxt[xx])\\n        \\n        \\n\\nprint(max(dp[0]))\\n\", \"# AC\\nimport sys\\nfrom math import gcd\\n\\n\\nclass Main:\\n    def __init__(self):\\n        self.buff = None\\n        self.index = 0\\n\\n    def __next__(self):\\n        if self.buff is None or self.index == len(self.buff):\\n            self.buff = sys.stdin.readline().split()\\n            self.index = 0\\n        val = self.buff[self.index]\\n        self.index += 1\\n        return val\\n\\n    def next_int(self):\\n        return int(next(self))\\n\\n    def solve(self):\\n        n = self.next_int()\\n        k = self.next_int()\\n        x = [self.next_int() for _ in range(0, n)]\\n        ans = 0\\n        dp = (0, 0, 0)\\n        for xx in x:\\n            d0 = max(0, dp[0]) + xx\\n            d1 = max(0, dp[0], dp[1]) + xx * k\\n            d2 = max(0, dp[0], dp[1], dp[2]) + xx\\n            ans = max(ans, d0, d1, d2)\\n            dp = (d0, d1, d2)\\n        print(ans)\\n\\n\\ndef __starting_point():\\n    Main().solve()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3 -2\n-3 3 1\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1155/D"
    },
    {
        "id": 907,
        "task_id": 47,
        "test_case_id": 125,
        "question": "You are given an array $a$ consisting of $n$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0.\n\nYou may choose at most one consecutive subarray of $a$ and multiply all values contained in this subarray by $x$. You want to maximize the beauty of array after applying at most one such operation.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $x$ ($1 \\le n \\le 3 \\cdot 10^5, -100 \\le x \\le 100$) — the length of array $a$ and the integer $x$ respectively.\n\nThe second line contains $n$ integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the array $a$.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible beauty of array $a$ after multiplying all values belonging to some consecutive subarray $x$.\n\n\n-----Examples-----\nInput\n5 -2\n-3 8 -2 1 -6\n\nOutput\n22\n\nInput\n12 -3\n1 3 3 7 1 3 3 7 1 3 3 7\n\nOutput\n42\n\nInput\n5 10\n-1 -2 -3 -4 -5\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first test case we need to multiply the subarray [-2, 1, -6], and the array becomes [-3, 8, 4, -2, 12] with beauty 22 ([-3, 8, 4, -2, 12]).\n\nIn the second test case we don't need to multiply any subarray at all.\n\nIn the third test case no matter which subarray we multiply, the beauty of array will be equal to 0.",
        "solutions": "[\"N, X = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\n\\ndp = [[0]*4 for _ in range(N+1)]\\n\\nfor i in range(1, N+1):\\n    dp[i][0] = max(dp[i-1][0] + A[i-1], 0)\\n    dp[i][1] = max(dp[i-1][1] + A[i-1] * X, dp[i][0])\\n    dp[i][2] = max(dp[i-1][2] + A[i-1], dp[i][1])\\n    dp[i][3] = max(dp[i-1][3], dp[i][2])\\n\\nprint(dp[N][3])\\n\", \"n, x = list(map(int, input().split()))\\ncur1 = cur2 = cur = res = 0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\\n\", \"n,x = map(int,input().split())\\nl = list(map(int,input().split()))\\nnot_used = [0 for k in range(n+1)]\\ncurrent = [0 for k in range(n+1)]\\nused =[0 for k in range(n+1)]\\nglobalMax = 0\\nfor k in range(n):\\n\\tnot_used[k+1]= max(not_used[k],0)+l[k]\\n\\tcurrent[k+1] = max(max(not_used[k],current[k]),0)+l[k]*x\\n\\tused[k+1] = max(max(current[k],used[k]),0)+l[k]\\n\\tglobalMax = max(max(globalMax,used[k+1]),max(current[k+1],not_used[k+1]))\\nprint(globalMax)\", \"n, x = map(int, input().split())\\ndp1 = [0]*n\\ndp2 = [0]*n\\ndp0 = [0]*n\\nans = 0\\nv = [int(i) for i in input().split()]\\ndp0[0] = max(0, v[0])\\ndp1[0] = v[0] * x\\ni = 0\\nans = max(ans, dp1[i], dp2[i], dp0[i])\\nfor i in range(1, n):\\n    dp0[i] = max(0, dp0[i - 1] + v[i])\\n    dp1[i] = max(dp1[i - 1] + v[i] * x, dp0[i-1] + v[i] * x)\\n    dp2[i] = max(dp1[i-1] + v[i], dp2[i - 1] + v[i])\\n    ans = max(ans, dp1[i], dp2[i], dp0[i])\\nprint(ans)\", \"n, x = map(int, input().split())\\ncur1=cur2=cur=res=0\\nfor a in map(int, input().split()):\\n    cur1 = max(cur1 + a, 0)\\n    cur2 = max(cur2 + a * x, cur1)\\n    cur = max(cur + a, cur2)\\n    res = max(res, cur)\\nprint(res)\", \"N, X = list(map(int, input().split()))\\na_list = list(map(int, input().split()))\\n\\ndp = [[0] * 5 for _ in range(303030)]\\n\\nfor i in range(N):\\n    a = a_list[i]\\n    dp[i + 1][0] = 0\\n    dp[i + 1][1] = max(dp[i][1] + a, dp[i + 1][0])\\n    dp[i + 1][2] = max(dp[i][2] + a * X, dp[i + 1][1])\\n    dp[i + 1][3] = max(dp[i][3] + a, dp[i + 1][2])\\n    dp[i + 1][4] = max(dp[i][4], dp[i + 1][3])\\nprint(dp[N][4])\\n\", \"def main():\\n    n, x = map(int, input().split())\\n    arr = list(map(int, input().split()))\\n    dp = [[0] * 5 for _ in range(n)]\\n    dp[0] = [arr[0], arr[0] * x, 0]\\n    ans = max(dp[0])\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + arr[i], arr[i])\\n        dp[i][1] = max(dp[i - 1][0] + arr[i] * x, arr[i] * x, dp[i - 1][1] + arr[i] * x)\\n        dp[i][2] = max(dp[i - 1][2] + arr[i], dp[i - 1][1] + arr[i])\\n        ans = max(ans, max(dp[i]))\\n    print(ans)\\n    return 0\\n\\nmain()\", \"n, x = list(map(int, input().split()))\\narr = [int(x) for x in input().split()]\\ndp = [[0 for _ in range(n)] for _ in range(3)]\\ndp[0][0] = max(arr[0], 0)\\ndp[1][0] = max(arr[0] * x, 0)\\ndp[2][0] = max(arr[0], 0)\\nanswer = max(dp[0][0], dp[1][0], dp[2][0])\\nfor i in range(1, n):\\n    dp[0][i] = max(dp[0][i - 1] + arr[i], arr[i], 0)\\n    dp[1][i] = max(dp[0][i - 1] + arr[i] * x, dp[1][i - 1] + arr[i] * x, arr[i] * x, 0)\\n    dp[2][i] = max(dp[1][i - 1] + arr[i], dp[2][i - 1] + arr[i], arr[i], 0)\\n    answer = max(answer, dp[0][i], dp[1][i], dp[2][i])\\nprint(answer)\\n\", \"#  =========     /\\\\       /|    |====/|\\n#      |        /  \\\\       |    |   / |\\n#      |       /____\\\\      |    |  /  |\\n#      |      /      \\\\     |    | /   |\\n#  ========= /        \\\\  =====  |/====|  \\n#  code\\nfrom collections import Counter\\nfrom math import gcd\\n\\ndef __starting_point():\\n    n,x = map(int,input().split())\\n    a = list(map(int,input().split()))\\n    \\n    dp = [ [-1,-1,-1] for i in range(n)]\\n\\n    dp[0][0] = a[0]\\n    dp[0][1] = x*a[0]\\n    dp[0][2] = a[0]\\n    m = max(dp[0][0],dp[0][1],dp[0][2],0)\\n    for i in range(1,n):\\n        dp[i][0] = max(dp[i-1][0]+a[i],a[i])\\n        dp[i][1] = max(dp[i-1][1] + x*a[i],x*a[i],dp[i-1][0]+x*a[i])\\n        dp[i][2] = max(dp[i-1][1] + a[i],a[i],dp[i-1][2]+a[i])\\n        m = max(max(dp[i]),m)\\n    print(m)\\n__starting_point()\", \"n, x = list(map(int,input().split()))\\nl = list(map(int,input().split()))\\nb = [0] * n\\nf = [0] * n\\npref = [0] * n\\npref[0] = l[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + l[i]\\nb[0] = x * l[0]\\nmini = 0\\nfor i in range(1, n):\\n\\tmini = min(mini, pref[i - 1])\\n\\tb[i] = x * l[i] + max(b[i - 1], pref[i - 1] - mini)\\nf[n - 1] = l[n - 1] * x\\nmaksi = pref[n - 1]\\nfor i in range(1, n):\\n\\tj = n - i - 1\\n\\tmaksi = max(maksi, pref[j])\\n\\tf[j] = x * l[j] + max(f[j + 1], maksi - pref[j])\\nwyn = - 100000000000000000000000\\nfor i in range(n):\\n\\twyn = max(wyn, f[i] + b[i] - x * l[i])\\nmini = 0\\nwyn1 = -100000000000000000000000\\nfor i in range(n):\\n\\tmini = min(mini, pref[i])\\n\\twyn1 = max(wyn1, pref[i] - mini)\\nprint(max(wyn, wyn1))\", \"def main():\\n    n, x = list(map(int, input().split()))\\n    a = list(map(int, input().split()))\\n\\n    dp = [[0, 0, 0] for _ in range(n)]\\n    dp[0][0] = max(0, a[0])\\n    dp[0][1] = max(0, x * a[0])\\n    answer = max(dp[0])\\n\\n    for i in range(1, n):\\n        dp[i][0] = max(dp[i - 1][0] + a[i], a[i])\\n        dp[i][1] = max(dp[i - 1][1] + x * a[i], x * a[i],\\n                       dp[i - 1][0] + x * a[i])\\n        dp[i][2] = max(dp[i - 1][2] + a[i], dp[i - 1][1] + a[i])\\n        answer = max(answer, *dp[i])\\n\\n    print(answer)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,x=list(map(int,input().split())) \\na=list(map(int,input().split())) \\ndp=[[0 for i in range(3)] for j in range(n+1)]\\na=[0]+a\\n#3 dps lagenge >:|)\\nres=0\\nfor i in range(1,n+1):\\n    dp[i][0]= max(0,dp[i-1][0]+a[i],a[i]) #current le ya na le\\n    dp[i][1]=max(0,dp[i-1][0]+a[i]*x,dp[i-1][1]+a[i]*x,a[i]*x) #check and see which gives the best ans\\n    dp[i][2]= max(0,a[i],dp[i-1][0]+a[i],dp[i-1][1]+a[i],dp[i-1][2]+a[i]) #main dp\\n    res=max(res,dp[i][0],dp[i][1],dp[i][2])\\n    #print(dp)\\nprint(res)\\n\\n\", \"n,x=map(int, input().split())\\nA=list(map(int,input().split()))\\nDP=[[0]*3 for _ in range(n+1)]\\nans=0\\nfor i in range(1,n+1):\\n    DP[i][0]=max(DP[i-1][0]+A[i-1],A[i-1])\\n    DP[i][1]=max(DP[i-1][0]+A[i-1]*x,DP[i-1][1]+A[i-1]*x,A[i-1]*x)\\n    DP[i][2]=max(DP[i-1][1]+A[i-1],DP[i-1][2]+A[i-1],A[i-1])\\n    ans=max(ans,max(DP[i]))\\nprint(ans)\", \"d1, d2, d3, d4 = 0, 0, 0, 0\\ne1, e2, e3, e4 = 0, 0, 0, 0\\nn, x = map(int, input().split())\\nA = list(map(int, input().split())) + [0]\\nfor a in A:\\n    e1 = max(a, d1 + a)\\n    e2 = max(x*a, d1 + x*a, d2 + x*a)\\n    e3 = max(e1, d2 + a, d3 + a)\\n    e4 = max(d1, d2, d3, d4, a)\\n    d1, d2, d3, d4 = e1, e2, e3, e4\\nprint(d4)\", \"def solve():\\n    N, X = map(int, input().split())\\n    A = [int(k) for k in input().split()]\\n    \\n    ans = 0\\n    cur_max1 = 0\\n    cur_max2 = 0\\n    cur_max3 = 0\\n    \\n    for a in A:\\n        #max sum subarray\\n        '''\\n        if A[i] > cur_max + A[i]:\\n            cur_max = A[i]\\n        else:\\n            cur_max += A[i]'''\\n        \\n        # normal max sum subarray\\n        cur_max1 = max(a, cur_max1 + a)\\n        # multiply by X\\n        cur_max2 = max(a*X, a*X + cur_max2, cur_max1)\\n        # max sum subarray with previous sum multiplied by X\\n        cur_max3 = max(a, cur_max3 + a, cur_max2)\\n            \\n        ans = max(ans, cur_max1, cur_max2, cur_max3, 0)\\n    \\n    print (ans)\\n    \\ndef __starting_point():  \\n    solve()\\n__starting_point()\", \"def printarr(dp):\\n    for i in dp:\\n        print(*i)\\n\\nn,m=list(map(int,input().split()))\\na=[0] + list(map(int,input().split()))\\ndp=[[0 ,0 ,0] for i in range(n+1)]\\nma=-1\\nfor i in range(1,n+1):\\n    dp[i][0]=max(dp[i-1][0] + a[i],0)\\n    dp[i][1]=max(dp[i-1][1] + a[i]*m, dp[i-1][0] + a[i]*m)\\n    dp[i][2]=max(dp[i-1][2] + a[i] ,a[i] + dp[i-1][1])\\n    ma=max(dp[i][0],dp[i][1],dp[i][2],ma)\\n# printarr(dp)    \\nprint(ma)    \\n\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c1 = max([c1 + A[i], 0])\\n        c2 = max([c1, c2 + A[i] * x])\\n        c3 = max([c2, c3 + A[i]])\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def find(A, x):\\n    maxi, c1, c2, c3 = 0, 0, 0, 0\\n    for i in range(0, len(A)):\\n        c11 = max([c1, 0]) + A[i]\\n        c22 = max([c1, c2, 0]) + A[i] * x\\n        c33 = max([c2, c3, 0]) + A[i]\\n        c1, c2, c3 = c11, c22, c33\\n        maxi = max([maxi, c1, c2, c3])\\n    return maxi\\n\\ninp = lambda cast=int: list(map(cast, input().split()))\\nn, x = inp()\\nA = [0] + inp()\\nprint(find(A, x))\", \"def solve():\\n    n, x = list(map(int, input().split()))\\n    a = [0] + list(map(int, input().split()))\\n    max_val = 0\\n    dp1 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp1[i] = max(dp1[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp1[i])\\n\\n    dp2 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp2[i] = max(dp1[i-1] + a[i] * x, dp2[i-1] + a[i] * x, a[i] * x)\\n        max_val = max(max_val, dp2[i])\\n\\n    dp3 = [0] * (n + 1)\\n    for i in range(1, n + 1):\\n        dp3[i] = max(dp2[i-1] + a[i], dp3[i-1] + a[i], a[i])\\n        max_val = max(max_val, dp3[i])\\n\\n    print(max_val)\\n\\nsolve()\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nSUM=[0]\\n\\nfor a in A:\\n    SUM.append(SUM[-1]+a)\\n\\nMAXLIST=[SUM[0]]\\nMINLIST=[SUM[0]]\\n\\nfor i in range(1,n+1):\\n    MAXLIST.append(max(MAXLIST[-1],SUM[i]))\\n    MINLIST.append(min(MINLIST[-1],SUM[i]))\\n\\nMAXLIST_INV=[SUM[-1]]\\nMINLIST_INV=[SUM[-1]]\\n\\nfor i in range(n-1,-1,-1):\\n    MAXLIST_INV.append(max(MAXLIST_INV[-1],SUM[i]))\\n    MINLIST_INV.append(min(MINLIST_INV[-1],SUM[i]))\\n\\nMAXLIST_INV=MAXLIST_INV[::-1]\\nMINLIST_INV=MINLIST_INV[::-1]\\n\\n\\nif x>0:\\n    \\n    ANS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        MINUS=MINLIST[i]\\n\\n        ANS=max(ANS,(base-MINUS)*x)\\n\\n    print(ANS)\\n\\nelse:\\n\\n    ANS=0\\n    MAX=0\\n    MIN=0\\n    MINUS=0\\n    NOWMINUS=0\\n   \\n    for i in range(n+1):\\n        base=SUM[i]\\n        PLUS=MAXLIST_INV[i]#getvalues(i,n+2,0,0,seg_el)\\n\\n        ANS=max(ANS,NOWMINUS+PLUS-base+base*x)\\n\\n        MIN=min(MIN,SUM[i])\\n        \\n        if NOWMINUS<=SUM[i]-MIN+SUM[i]*(-x):\\n            NOWMINUS=SUM[i]-MIN+SUM[i]*(-x)\\n            MAX=SUM[i]\\n\\n\\n    print(ANS)  \\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,x=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP0=[0]*(n+1)\\nDP1=[0]*(n+1)\\nDP2=[0]*(n+1)\\n\\nfor i in range(n):\\n    DP0[i]=max(DP0[i-1]+A[i],A[i],0)\\n    DP1[i]=max(DP0[i-1]+A[i]*x,DP1[i-1]+A[i]*x,DP0[i])\\n    DP2[i]=max(DP2[i-1]+A[i],DP1[i-1]+A[i],DP1[i])\\n\\nprint(max(DP2))\\n\", \"\\nn,m = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ndef factiry(arr,mul):\\n    curMax,mulMax,gloMax,cur = 0,0,0,0\\n    for i in range(n):\\n        curMax=max(arr[i]+curMax,0)\\n        mulMax = max(mulMax+(arr[i]*mul),curMax)\\n        cur = max(cur+arr[i],mulMax)\\n        gloMax = max(gloMax,cur)\\n    return (gloMax)\\ntotal = factiry(a,m)\\nprint(total)\\n\\n\\n\", \"n, x = [int(i) for i in input().split()]\\nA = [int(i) for i in input().split()]\\ndp = [[-10**18 for i in range(5)] for j in range(len(A))]\\n\\nfor i in range(n-1, -1, -1):\\n    if 1:\\n        nxt = [0, 0, 0, 0, 0]\\n        if i!=n-1:\\n            nxt = dp[i+1]\\n        coeff = [0, 1, x, 1, 0]\\n        for j in range(5):\\n            for xx in range(j, len(coeff)):\\n                dp[i][j] = max(dp[i][j], coeff[xx]*A[i] + nxt[xx])\\n        \\n        \\n\\nprint(max(dp[0]))\\n\", \"# AC\\nimport sys\\nfrom math import gcd\\n\\n\\nclass Main:\\n    def __init__(self):\\n        self.buff = None\\n        self.index = 0\\n\\n    def __next__(self):\\n        if self.buff is None or self.index == len(self.buff):\\n            self.buff = sys.stdin.readline().split()\\n            self.index = 0\\n        val = self.buff[self.index]\\n        self.index += 1\\n        return val\\n\\n    def next_int(self):\\n        return int(next(self))\\n\\n    def solve(self):\\n        n = self.next_int()\\n        k = self.next_int()\\n        x = [self.next_int() for _ in range(0, n)]\\n        ans = 0\\n        dp = (0, 0, 0)\\n        for xx in x:\\n            d0 = max(0, dp[0]) + xx\\n            d1 = max(0, dp[0], dp[1]) + xx * k\\n            d2 = max(0, dp[0], dp[1], dp[2]) + xx\\n            ans = max(ans, d0, d1, d2)\\n            dp = (d0, d1, d2)\\n        print(ans)\\n\\n\\ndef __starting_point():\\n    Main().solve()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 -2\n-2 2\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1155/D"
    },
    {
        "id": 908,
        "task_id": 82,
        "test_case_id": 1,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 10\n8 9\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 909,
        "task_id": 82,
        "test_case_id": 2,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 5\n4 4 4\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 910,
        "task_id": 82,
        "test_case_id": 3,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 10\n10 8 9\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 911,
        "task_id": 82,
        "test_case_id": 4,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 23\n21 23\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 912,
        "task_id": 82,
        "test_case_id": 5,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "5 10\n5 10 10 9 10\n",
        "output": "7",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 913,
        "task_id": 82,
        "test_case_id": 6,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "12 50\n18 10 26 22 22 23 14 21 27 18 25 12\n",
        "output": "712",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 914,
        "task_id": 82,
        "test_case_id": 7,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "38 12\n2 7 10 8 5 3 5 6 3 6 5 1 9 7 7 8 3 4 4 4 5 2 3 6 6 1 6 7 4 4 8 7 4 5 3 6 6 6\n",
        "output": "482",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 915,
        "task_id": 82,
        "test_case_id": 8,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "63 86\n32 31 36 29 36 26 28 38 39 32 29 26 33 38 36 38 36 28 43 48 28 33 25 39 39 27 34 25 37 28 40 26 30 31 42 32 36 44 29 36 30 35 48 40 26 34 30 33 33 46 42 24 36 38 33 51 33 41 38 29 29 32 28\n",
        "output": "6469",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 916,
        "task_id": 82,
        "test_case_id": 9,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 38\n30 24 38 31 31 33 32 32 29 34 29 22 27 23 34 25 32 30 30 26 16 27 38 33 38 38 37 34 32 27 33 23 33 32 24 24 30 36 29 30 33 30 29 30 36 33 33 35 28 24 30 32 38 29 30 36 31 30 27 38 31 36 15 37 32 27 29 24 38 33 28 29 34 21 37 35 32 31 27 25 27 28 31 31 36 38 35 35 36 29 35 22 38 31 38 28 31 27 34 31\n",
        "output": "1340",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 917,
        "task_id": 82,
        "test_case_id": 10,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "33 69\n60 69 68 69 69 60 64 60 62 59 54 47 60 62 69 69 69 58 67 69 62 69 68 53 69 69 66 66 57 58 65 69 61\n",
        "output": "329",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 918,
        "task_id": 82,
        "test_case_id": 11,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "39 92\n19 17 16 19 15 30 21 25 14 17 19 19 23 16 14 15 17 19 29 15 11 25 19 14 18 20 10 16 11 15 18 20 20 17 18 16 12 17 16\n",
        "output": "5753",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 919,
        "task_id": 82,
        "test_case_id": 12,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "68 29\n29 29 29 29 29 28 29 29 29 27 29 29 29 29 29 29 29 23 29 29 26 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 26 29 29 29 29 29 29 29 29 29 29 29 29 22 29 29 29 29 29 29 29 29 29 29 29 29 29 28 29 29 29 29\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 920,
        "task_id": 82,
        "test_case_id": 13,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "75 30\n22 18 21 26 23 18 28 30 24 24 19 25 28 30 23 29 18 23 23 30 26 30 17 30 18 19 25 26 26 15 27 23 30 21 19 26 25 30 25 28 20 22 22 21 26 17 23 23 24 15 25 19 18 22 30 30 29 21 30 28 28 30 27 25 24 15 22 19 30 21 20 30 18 20 25\n",
        "output": "851",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 921,
        "task_id": 82,
        "test_case_id": 14,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "78 43\n2 7 6 5 5 6 4 5 3 4 6 8 4 5 5 4 3 1 2 4 4 6 5 6 4 4 6 4 8 4 6 5 6 1 4 5 6 3 2 5 2 5 3 4 8 8 3 3 4 4 6 6 5 4 5 5 7 9 3 9 6 4 7 3 6 9 6 5 1 7 2 5 6 3 6 2 5 4\n",
        "output": "5884",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 922,
        "task_id": 82,
        "test_case_id": 15,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "82 88\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1\n",
        "output": "14170",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 923,
        "task_id": 82,
        "test_case_id": 16,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "84 77\n28 26 36 38 37 44 48 34 40 22 42 35 40 37 30 31 33 35 36 55 47 36 33 47 40 38 27 38 36 33 35 31 47 33 30 38 38 47 49 24 38 37 28 43 39 36 34 33 29 38 36 43 48 38 36 34 33 34 35 31 26 33 39 37 37 37 35 52 47 30 24 46 38 26 43 46 41 50 33 40 36 41 37 30\n",
        "output": "6650",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 924,
        "task_id": 82,
        "test_case_id": 17,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "94 80\n21 19 15 16 27 16 20 18 19 19 15 15 20 19 19 21 20 19 13 17 15 9 17 15 23 15 12 18 12 13 15 12 14 13 14 17 20 20 14 21 15 6 10 23 24 8 18 18 13 23 17 22 17 19 19 18 17 24 8 16 18 20 24 19 10 19 15 10 13 14 19 15 16 19 20 15 14 21 16 16 14 14 22 19 12 11 14 13 19 32 16 16 13 20\n",
        "output": "11786",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 925,
        "task_id": 82,
        "test_case_id": 18,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "96 41\n13 32 27 34 28 34 30 26 21 24 29 20 25 34 25 16 27 15 22 22 34 22 25 19 23 17 17 22 26 24 23 20 21 27 19 33 13 24 22 18 30 30 27 14 26 24 20 20 22 11 19 31 19 29 18 28 30 22 17 15 28 32 17 24 17 24 24 19 26 23 22 29 18 22 23 29 19 32 26 23 22 22 24 23 27 30 24 25 21 21 33 19 35 27 34 28\n",
        "output": "3182",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 926,
        "task_id": 82,
        "test_case_id": 19,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 26\n26\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 927,
        "task_id": 82,
        "test_case_id": 20,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "99 39\n25 28 30 28 32 34 31 28 29 28 29 30 33 19 33 31 27 33 29 24 27 30 25 38 28 34 35 31 34 37 30 22 21 24 34 27 34 33 34 33 26 26 36 19 30 22 35 30 21 28 23 35 33 29 21 22 36 31 34 32 34 32 30 32 27 33 38 25 35 26 39 27 29 29 19 33 28 29 34 38 26 30 36 26 29 30 26 34 22 32 29 38 25 27 24 17 25 28 26\n",
        "output": "1807",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 928,
        "task_id": 82,
        "test_case_id": 21,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 12\n7 6 6 3 5 5 9 8 7 7 4 7 12 6 9 5 6 3 4 7 9 10 7 7 5 3 9 6 9 9 6 7 4 10 4 8 8 6 9 8 6 5 7 4 10 7 5 6 8 9 3 4 8 5 4 8 6 10 5 8 7 5 9 8 5 8 5 6 9 11 4 9 5 5 11 4 6 6 7 3 8 9 6 7 10 4 7 6 9 4 8 11 5 4 10 8 5 10 11 4\n",
        "output": "946",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 929,
        "task_id": 82,
        "test_case_id": 22,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 18\n1 2 2 2 2 2 1 1 1 2 3 1 3 1 1 4 2 4 1 2 1 2 1 3 2 1 2 1 1 1 2 1 2 2 1 1 4 3 1 1 2 1 3 3 2 1 2 2 1 1 1 1 3 1 1 2 2 1 1 1 5 1 2 1 3 2 2 1 4 2 2 1 1 1 1 1 1 1 1 2 2 1 2 1 1 1 2 1 2 2 2 1 1 3 1 1 2 1 1 2\n",
        "output": "3164",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 930,
        "task_id": 82,
        "test_case_id": 23,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 27\n16 20 21 10 16 17 18 25 19 18 20 12 11 21 21 23 20 26 20 21 27 16 25 18 25 21 27 12 20 27 18 17 27 13 21 26 12 22 15 21 25 21 18 27 24 15 16 18 23 21 24 27 19 17 24 14 21 16 24 26 13 14 25 18 27 26 22 16 27 27 17 25 17 12 22 10 19 27 19 20 23 22 25 23 17 25 14 20 22 10 22 27 21 20 15 26 24 27 12 16\n",
        "output": "1262",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 931,
        "task_id": 82,
        "test_case_id": 24,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 29\n20 18 23 24 14 14 16 23 22 17 18 22 21 21 19 19 14 11 18 19 16 22 25 20 14 13 21 24 18 16 18 29 17 25 12 10 18 28 11 16 17 14 15 20 17 20 18 22 10 16 16 20 18 19 29 18 25 27 17 19 24 15 24 25 16 23 19 16 16 20 19 15 12 21 20 13 21 15 15 23 16 23 17 13 17 21 13 18 17 18 18 20 16 12 19 15 27 14 11 18\n",
        "output": "2024",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 932,
        "task_id": 82,
        "test_case_id": 25,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 30\n16 10 20 11 14 27 15 17 22 26 24 17 15 18 19 22 22 15 21 22 14 21 22 22 21 22 15 17 17 22 18 19 26 18 22 20 22 25 18 18 17 23 18 18 20 13 19 30 17 24 22 19 29 20 20 21 17 18 26 25 22 19 15 18 18 20 19 19 18 18 24 16 19 17 12 21 20 16 23 21 16 17 26 23 25 28 22 20 9 21 17 24 15 19 17 21 29 13 18 15\n",
        "output": "1984",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 933,
        "task_id": 82,
        "test_case_id": 26,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 59\n56 58 53 59 59 48 59 54 46 59 59 58 48 59 55 59 59 50 59 56 59 59 59 59 59 59 59 57 59 53 45 53 50 59 50 55 58 54 59 56 54 59 59 59 59 48 56 59 59 57 59 59 48 43 55 57 39 59 46 55 55 52 58 57 51 59 59 59 59 53 59 43 51 54 46 59 57 43 50 59 47 58 59 59 59 55 46 56 55 59 56 47 56 56 46 51 47 48 59 55\n",
        "output": "740",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 934,
        "task_id": 82,
        "test_case_id": 27,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 81\n6 7 6 6 7 6 6 6 3 9 4 5 4 3 4 6 6 6 1 3 9 5 2 3 8 5 6 9 6 6 6 5 4 4 7 7 3 6 11 7 6 4 8 7 12 6 4 10 2 4 9 11 7 4 7 7 8 8 6 7 9 8 4 5 8 13 6 6 6 8 6 2 5 6 7 5 4 4 4 4 2 6 4 8 3 4 7 7 6 7 7 10 5 10 6 7 4 11 8 4\n",
        "output": "14888",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 935,
        "task_id": 82,
        "test_case_id": 28,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 100\n30 35 23 43 28 49 31 32 30 44 32 37 33 34 38 28 43 32 33 32 50 32 41 38 33 20 40 36 29 21 42 25 23 34 43 32 37 31 30 27 36 32 45 37 33 29 38 34 35 33 28 19 37 33 28 41 31 29 41 27 32 39 30 34 37 40 33 38 35 32 32 34 35 34 28 39 28 34 40 45 31 25 42 28 29 31 33 21 36 33 34 37 40 42 39 30 36 34 34 40\n",
        "output": "13118",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 936,
        "task_id": 82,
        "test_case_id": 29,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 100\n71 87 100 85 89 98 90 90 71 65 76 75 85 100 81 100 91 80 73 89 86 78 82 89 77 92 78 90 100 81 85 89 73 100 66 60 72 88 91 73 93 76 88 81 86 78 83 77 74 93 97 94 85 78 82 78 91 91 100 78 89 76 78 82 81 78 83 88 87 83 78 98 85 97 98 89 88 75 76 86 74 81 70 76 86 84 99 100 89 94 72 84 82 88 83 89 78 99 87 76\n",
        "output": "3030",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 937,
        "task_id": 82,
        "test_case_id": 30,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "19700",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 938,
        "task_id": 82,
        "test_case_id": 31,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 939,
        "task_id": 82,
        "test_case_id": 32,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 100\n1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "19696",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 940,
        "task_id": 82,
        "test_case_id": 33,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 941,
        "task_id": 82,
        "test_case_id": 34,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 98 100 100 100 100 98 100 100 100 100 100 100 99 98 100 100 93 100 100 98 100 100 100 100 93 100 96 100 100 100 94 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 95 88 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 942,
        "task_id": 82,
        "test_case_id": 35,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 100\n95 100 100 100 100 100 100 100 100 100 100 100 100 100 87 100 100 100 94 100 100 100 100 100 100 100 100 100 100 100 100 99 100 100 100 100 100 100 100 100 100 100 90 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 97 100 100 100 96 100 98 100 100 100 100 100 96 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 97 100 100 100 100\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 943,
        "task_id": 82,
        "test_case_id": 36,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 944,
        "task_id": 82,
        "test_case_id": 37,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 2\n2 1 1 2 1 1 1 1 2 2 2 2 1 1 1 2 1 1 1 2 2 2 2 1 1 1 1 2 2 2 1 2 2 2 2 1 2 2 1 1 1 1 1 1 2 2 1 2 1 1 1 2 1 2 2 2 2 1 1 1 2 2 1 2 1 1 1 2 1 2 2 1 1 1 2 2 1 1 2 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 1 2 1 2 1 1\n",
        "output": "16",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 945,
        "task_id": 82,
        "test_case_id": 38,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 5\n5 5 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 946,
        "task_id": 82,
        "test_case_id": 39,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "7 7\n1 1 1 1 1 1 1\n",
        "output": "77",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 947,
        "task_id": 82,
        "test_case_id": 40,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 1\n1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 948,
        "task_id": 82,
        "test_case_id": 41,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "100 100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "19700",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 949,
        "task_id": 82,
        "test_case_id": 42,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "4 10\n10 10 10 10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 950,
        "task_id": 82,
        "test_case_id": 43,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 10\n10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 951,
        "task_id": 82,
        "test_case_id": 44,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "10 1\n1 1 1 1 1 1 1 1 1 1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 952,
        "task_id": 82,
        "test_case_id": 45,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 10\n10 10 10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 953,
        "task_id": 82,
        "test_case_id": 46,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 4\n3 4\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 954,
        "task_id": 82,
        "test_case_id": 47,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 2\n2\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 955,
        "task_id": 82,
        "test_case_id": 48,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 4\n4 4 4\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 956,
        "task_id": 82,
        "test_case_id": 49,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 2\n2 2 1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 957,
        "task_id": 82,
        "test_case_id": 50,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "5 5\n5 5 5 5 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 958,
        "task_id": 82,
        "test_case_id": 51,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 3\n3 3 3\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 959,
        "task_id": 82,
        "test_case_id": 52,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 9\n8 9\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 960,
        "task_id": 82,
        "test_case_id": 53,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 10\n9 10 10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 961,
        "task_id": 82,
        "test_case_id": 54,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 3\n3\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 962,
        "task_id": 82,
        "test_case_id": 55,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 2\n1 2\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 963,
        "task_id": 82,
        "test_case_id": 56,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 10\n10 10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 964,
        "task_id": 82,
        "test_case_id": 57,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "23 14\n7 11 13 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 965,
        "task_id": 82,
        "test_case_id": 58,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 10\n9 10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 966,
        "task_id": 82,
        "test_case_id": 59,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 2\n2 2\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 967,
        "task_id": 82,
        "test_case_id": 60,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "10 5\n5 5 5 5 5 5 5 5 5 4\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 968,
        "task_id": 82,
        "test_case_id": 61,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 5\n4 5 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 969,
        "task_id": 82,
        "test_case_id": 62,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "5 4\n4 4 4 4 4\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 970,
        "task_id": 82,
        "test_case_id": 63,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 10\n10 9\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 971,
        "task_id": 82,
        "test_case_id": 64,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "4 5\n3 5 5 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 972,
        "task_id": 82,
        "test_case_id": 65,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "10 5\n5 5 5 5 5 5 5 5 5 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 973,
        "task_id": 82,
        "test_case_id": 66,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 10\n10 10 9\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 974,
        "task_id": 82,
        "test_case_id": 67,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "5 1\n1 1 1 1 1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 975,
        "task_id": 82,
        "test_case_id": 68,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 1\n1 1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 976,
        "task_id": 82,
        "test_case_id": 69,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "4 10\n9 10 10 10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 977,
        "task_id": 82,
        "test_case_id": 70,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "5 2\n2 2 2 2 2\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 978,
        "task_id": 82,
        "test_case_id": 71,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 5\n4 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 979,
        "task_id": 82,
        "test_case_id": 72,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "5 10\n10 10 10 10 10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 980,
        "task_id": 82,
        "test_case_id": 73,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 6\n6 6\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 981,
        "task_id": 82,
        "test_case_id": 74,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 9\n9 9\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 982,
        "task_id": 82,
        "test_case_id": 75,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 10\n10 9 10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 983,
        "task_id": 82,
        "test_case_id": 76,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "4 40\n39 40 40 40\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 984,
        "task_id": 82,
        "test_case_id": 77,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 4\n3 4 4\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 985,
        "task_id": 82,
        "test_case_id": 78,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "9 9\n9 9 9 9 9 9 9 9 9\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 986,
        "task_id": 82,
        "test_case_id": 79,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 4\n4\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 987,
        "task_id": 82,
        "test_case_id": 80,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "4 7\n1 1 1 1\n",
        "output": "44",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 988,
        "task_id": 82,
        "test_case_id": 81,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 5\n5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 989,
        "task_id": 82,
        "test_case_id": 82,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 1\n1 1 1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 990,
        "task_id": 82,
        "test_case_id": 83,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 100\n100\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 991,
        "task_id": 82,
        "test_case_id": 84,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 7\n3 5\n",
        "output": "10",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 992,
        "task_id": 82,
        "test_case_id": 85,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 6\n6 6 6\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 993,
        "task_id": 82,
        "test_case_id": 86,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "4 2\n1 2 2 2\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 994,
        "task_id": 82,
        "test_case_id": 87,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "4 5\n4 5 5 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 995,
        "task_id": 82,
        "test_case_id": 88,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "5 5\n1 1 1 1 1\n",
        "output": "35",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 996,
        "task_id": 82,
        "test_case_id": 89,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "66 2\n1 2 2 2 2 1 1 2 1 2 2 2 2 2 2 1 2 1 2 1 2 1 2 1 2 1 1 1 1 2 2 1 2 2 1 1 2 1 2 2 1 1 1 2 1 2 1 2 1 2 1 2 2 2 2 1 2 2 1 2 1 1 1 2 2 1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 997,
        "task_id": 82,
        "test_case_id": 90,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 2\n2 1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 998,
        "task_id": 82,
        "test_case_id": 91,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "5 5\n5 5 5 4 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 999,
        "task_id": 82,
        "test_case_id": 92,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 7\n1 1 1\n",
        "output": "33",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1000,
        "task_id": 82,
        "test_case_id": 93,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 5\n5 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1001,
        "task_id": 82,
        "test_case_id": 94,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 7\n1\n",
        "output": "11",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1002,
        "task_id": 82,
        "test_case_id": 95,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "6 7\n1 1 1 1 1 1\n",
        "output": "66",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1003,
        "task_id": 82,
        "test_case_id": 96,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "99 97\n15 80 78 69 12 84 36 51 89 77 88 10 1 19 67 85 6 36 8 70 14 45 88 97 22 13 75 57 83 27 13 97 9 90 68 51 76 37 5 2 16 92 11 48 13 77 35 19 15 74 22 29 21 12 28 42 56 5 32 41 62 75 71 71 68 72 24 77 11 28 78 27 53 88 74 66 1 42 18 16 18 39 75 38 81 5 13 39 40 75 13 36 53 83 9 54 57 63 64\n",
        "output": "10077",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1004,
        "task_id": 82,
        "test_case_id": 97,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "8 7\n1 1 1 1 1 1 1 1\n",
        "output": "88",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1005,
        "task_id": 82,
        "test_case_id": 98,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "3 2\n2 2 2\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1006,
        "task_id": 82,
        "test_case_id": 99,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "6 5\n5 5 5 5 5 5\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1007,
        "task_id": 82,
        "test_case_id": 100,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "10 5\n5 5 5 5 5 5 5 4 1 1\n",
        "output": "8",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1008,
        "task_id": 82,
        "test_case_id": 101,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 5\n1\n",
        "output": "7",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1009,
        "task_id": 82,
        "test_case_id": 102,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "10 10\n10 10 10 10 10 10 10 10 10 10\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1010,
        "task_id": 82,
        "test_case_id": 103,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "2 3\n2 3\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1011,
        "task_id": 82,
        "test_case_id": 104,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "1 9\n9\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1012,
        "task_id": 82,
        "test_case_id": 105,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "74 2\n2 2 2 2 1 2 2 1 1 1 2 2 1 2 2 2 2 1 2 1 1 1 2 1 1 2 2 1 2 1 1 2 1 1 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 1 1 1 1 2 2 2 2 2 2 1 2\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1013,
        "task_id": 82,
        "test_case_id": 106,
        "question": "Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.\n\nIn school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8. \n\nFor instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.\n\nTo graduate with «A» certificate, Noora has to have mark k.\n\nNoora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ k) denoting marks received by Noora before Leha's hack.\n\n\n-----Output-----\n\nPrint a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.\n\n\n-----Examples-----\nInput\n2 10\n8 9\n\nOutput\n4\nInput\n3 5\n4 4 4\n\nOutput\n3\n\n\n-----Note-----\n\nConsider the first example testcase.\n\nMaximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to $\\frac{8 + 9 + 10 + 10 + 10 + 10}{6} = \\frac{57}{6} = 9.5$. Consequently, new final mark is 10. Less number of marks won't fix the situation.\n\nIn the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\ns = sum(a)\\nans = 0\\nc = k - 0.5\\nwhile s / n < c:\\n    s += k\\n    n += 1\\n    ans += 1\\nprint(ans)\\n\", \"n, k = list(map(int, input().split(' ')))\\nl = list(map(int, input().split(' ')))\\n\\ns = sum(l)\\ntotal = len(l)\\nres = 0\\nwhile s < total*k - total/2:\\n    s += k\\n    total += 1\\n    res += 1\\n\\nprint(res)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ni = 0\\ns = sum(a)\\nwhile (s + i * k) / (n + i) < k - 0.5:\\n    i += 1\\nprint(i)\", \"def check(m):\\n    return (s + k * m) * 2 >= (2 * k - 1) * (n + m)\\n\\n\\nn, k = map(int,input().split())\\na = list(map(int, input().split()))\\n\\ns = sum(a)\\nl = -1\\nr = 10 ** 6\\nwhile l < r - 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\n        \\nprint(r)\", \"from sys import stdin, stdout\\nimport math\\n\\nn, k = map(int, stdin.readline().split())\\nvalues = list(map(int, stdin.readline().split()))\\nans = sum(values)\\ncnt = 0\\n\\ndef round(v):\\n    if math.ceil(v) - v <= 1 / 2:\\n        return math.ceil(v)\\n    else:\\n        return math.floor(v)\\n    \\n\\nwhile round(ans / n) < k:\\n    ans += k\\n    n += 1\\n    cnt += 1\\n\\n\\nstdout.write(str(cnt))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nprint(max(0, 2 * n * k - n - 2 * sum(a)))\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport math\\n\\n\\ndef main():\\n    n, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    if sum(a) / n >= k - .5:\\n        print(0)\\n        return\\n\\n    m = math.ceil(((k - .5) * n * 2 - 2 * sum(a)) / (2 * k - 2 * (k - .5)))\\n    print(int(m))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nn, k = map(int,sys.stdin.readline().rstrip().split())\\nl = list(map(int, sys.stdin.readline().rstrip().split()))\\n\\ni = 0\\nwhile (sum(l)+k*i)/(i+n) < k-0.5:\\n    i += 1\\n\\nsys.stdout.write(str(i))\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = [int(i) for i in input().split()]\\n\\n    tot = sum(a)\\n    cnt = 0\\n\\n    while int(tot / n + 0.5) < k:\\n        tot += k\\n        n += 1\\n        cnt += 1\\n\\n    print(cnt)\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ns = sum(a)\\np = (k-0.5)*n\\nif s >= p:\\n  print(0)\\nelse:\\n  r = int(2*(p-s))\\n  print(r)\\n\", \"n,k = map(int, input().split())\\na = list(map(int, input().split()))\\nsm = sum(a)\\nl,r = -1, 10 ** 20\\ndef check(m):\\n    return round((sm + k * m) / (n + m) + 0.000001) >= k\\nwhile r - l > 1:\\n    m = (l + r) // 2\\n    if check(m):\\n        r = m\\n    else:\\n        l = m\\nprint(r)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nans = 0\\nwhile 2 * (sum(a) + ans * k) < (n + ans) * (2 * k - 1):\\n    ans += 1\\nprint(ans)\\n\", \"n,k=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nc=0\\nfor i in range(n):\\n    z=k-a[i]\\n    c+=2*z-1\\nif c<0:\\n    print(0)\\nelse:\\n    print(c)\\n    \\n    \\n\", \"n, k = map(int, input().split())\\nmarks = list(map(int, input().split()))\\nsumma = sum(marks)\\nnums = len(marks)\\nresult = summa / nums\\nhowmany = 0\\nwhile result < k - 0.5:\\n    summa += k\\n    nums += 1\\n    result = summa / nums\\n    howmany += 1\\nprint(howmany)\", \"import math\\nn, k = map(int, input().split())\\nsm = sum(list(map(int, input().split())))\\n\\na = 0\\nwhile int((sm + a*k) / (n + a) + 0.5) < k:\\n    a += 1\\nprint(a)\", \"n,k=[int(i)for i in input().split()]\\nl=[int(i)for i in input().split()]\\nans=0\\nif sum(l)/n<k-0.5:\\n\\tans = int(((k-0.5)*n-sum(l))/0.5)\\n\\nprint(ans)\\t\\n\\n\", \"n, k=map (int, input (). split ()) \\ngrades=list(map (int, input (). split ())) \\nans=(2*k-1)*n-2*sum(grades)\\nif ans<0:\\n    ans=0\\nprint (ans) \", \"x,y=list(map(int,input().split()))\\na=list(map(int,input().split()))\\nn=0\\nd=0\\nfor i in range(x):\\n\\tn=n+a[i]\\nwhile round((n+0.01)/x)!=y:\\n\\tn=n+y\\n\\tx=x+1\\n\\td+=1\\nprint(d)\\n\", \"n, k = list(map(int, input().split()))\\n\\ns = sum(map(int, input().split()))\\nleft = -1\\nright = 10 ** 100\\n\\nwhile right - left > 1:\\n    mid = (left + right) // 2\\n    whole = s + k * mid\\n    if whole * 2 // (mid + n) < 2 * k - 1:\\n        left = mid\\n    else:\\n        right = mid\\n\\nprint(right)\\n\", \"n,k = list(map(int, input().split()))\\ntot = sum(map(int,input().split()))\\n\\ni = 0\\nwhile(tot*2 < (k*2-1)*(n+i)):\\n    i+=1\\n    tot += k\\n\\nprint(i)\\n\", \"import math\\nimport re\\n\\ndef f(n):\\n    if n - math.floor(n) < 0.5:\\n        return n\\n    else :\\n        return math.ceil(n)\\n\\nn, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\n\\nn1 = n\\ns = sum(a)\\nsred = s/n\\nwhile f(sred) != k:\\n    s += k\\n    n += 1\\n    sred = s/n\\n\\nprint(n - n1)\\n\\n# n, m = map(int, input().split())\\n# w = []\\n# c = []\\n# for i in range(n):\\n#     x, y = map(int, input().split())\\n#     w.append(x)\\n#     c.append(y)\\n#\\n# A = [[0] * (m + 1) for i in range(n)]\\n#\\n#\\n# for k in range(n):\\n#       for s in range(1, m + 1):\\n#             if s >= w[k]:\\n#                 A[k][s] = max(A[k - 1][s], A[k - 1][s - w[k]] + c[k])\\n#             else:\\n#                 A[k][s] = A[k-1][s]\\n#\\n# print(A[n - 1][m])\\n\\n    # arr = list(map(int, input().split()))\\n# res = 0\\n# a = {math.pow(2, i) for i in range(35)}\\n# for i in range(n-1):\\n#     for j in range(i+1,n):\\n#         if arr[i] + arr[j] % 2 % 2 % 2 % 2 % 2 in a:\\n#             res += 1\\n#\\n# print(res)\\n\\n\\n# arr = list(map(int, input().split()))\\n# m = int(input())\\n# spis = list(map(int, input().split()))\\n#\\n# arr1 = sorted(arr, reverse=True)\\n# a = [n - arr1.index(arr[el - 1]) for el in spis]\\n# print(' '.join(map(str, a)))\\n\", \"n,k=list(map(int,input().split()))\\nl = list(map(int,input().split()))\\ns = sum(l)\\nreq = k-0.5\\nif(s>=n*req):\\n\\tprint(0)\\n\\treturn\\nfor i in range(1,100000):\\n\\tif((s+(k*i))>=(n+i)*req):\\n\\t\\tprint(i)\\n\\t\\treturn\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nl = len(a)\\ns = sum(a)\\ncur = round(s / l + 0.0000001)\\ncount = 0\\nwhile cur != k:\\n    s += k\\n    l += 1\\n    cur = round(s / l + 0.0000001)\\n    count += 1\\nprint(count)\", \"n, k = [int(x) for x in input().split()]\\na = [int(x) for x in input().split()]\\n\\ns = sum(a)\\ni = 0\\nl = len(a)\\nwhile round(s / l + 0.00001) != k:\\n    # print(s)\\n    i += 1\\n    s += k\\n    l += 1\\nprint(i)\", \"3.5\\nn,k=[int(x) for x in input().split()]\\nmas=[int(x) for x in input().split()]\\n\\np=0\\ns=sum(mas)\\nwhile True:\\n    if s/n>=k-0.5:\\n        print(p)\\n        quit()\\n    else:\\n        s+=k\\n        n+=1\\n        p+=1\"]",
        "difficulty": "interview",
        "input": "5 5\n5 5 5 5 4\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/810/A"
    },
    {
        "id": 1014,
        "task_id": 103,
        "test_case_id": 3,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 2 3 4 5\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1015,
        "task_id": 103,
        "test_case_id": 5,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "2\n1 2\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1016,
        "task_id": 103,
        "test_case_id": 6,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "2\n999 1000\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1017,
        "task_id": 103,
        "test_case_id": 8,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n",
        "output": "99",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1018,
        "task_id": 103,
        "test_case_id": 14,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "15\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n",
        "output": "14",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1019,
        "task_id": 103,
        "test_case_id": 15,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "63\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63\n",
        "output": "62",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1020,
        "task_id": 103,
        "test_case_id": 28,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "100\n901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000\n",
        "output": "99",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1021,
        "task_id": 103,
        "test_case_id": 29,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "10\n1 2 3 4 5 6 7 8 9 10\n",
        "output": "9",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1022,
        "task_id": 103,
        "test_case_id": 30,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "10\n991 992 993 994 995 996 997 998 999 1000\n",
        "output": "9",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1023,
        "task_id": 103,
        "test_case_id": 31,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "39\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39\n",
        "output": "38",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1024,
        "task_id": 103,
        "test_case_id": 32,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "42\n959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000\n",
        "output": "41",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1025,
        "task_id": 103,
        "test_case_id": 41,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "3\n9 10 11\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1026,
        "task_id": 103,
        "test_case_id": 42,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "6\n4 5 6 7 8 9\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1027,
        "task_id": 103,
        "test_case_id": 43,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "5\n5 6 7 8 9\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1028,
        "task_id": 103,
        "test_case_id": 52,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "5\n2 3 4 5 6\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1029,
        "task_id": 103,
        "test_case_id": 57,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "3\n3 4 5\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1030,
        "task_id": 103,
        "test_case_id": 59,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "3\n2 3 4\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1031,
        "task_id": 103,
        "test_case_id": 62,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "3\n997 998 999\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1032,
        "task_id": 103,
        "test_case_id": 67,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "3\n4 5 6\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1033,
        "task_id": 103,
        "test_case_id": 78,
        "question": "JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array $a_1$, $a_2$, ..., $a_n$ of integers, such that $1 \\le a_1 < a_2 < \\ldots < a_n \\le 10^3$, and then went to the bathroom.\n\nJATC decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the prank to go too far, he will only erase in a way, such that Giraffe can still restore the array using the information from the remaining elements. Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers in the range $[1, 10^3]$.\n\nJATC wonders what is the greatest number of elements he can erase?\n\n\n-----Input-----\n\nThe first line of the input contains a single integer $n$ ($1 \\le n \\le 100$) — the number of elements in the array.\n\nThe second line of the input contains $n$ integers $a_i$ ($1 \\le a_1<a_2<\\dots<a_n \\le 10^3$) — the array written by Giraffe.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of consecutive elements in the array that JATC can erase.\n\nIf it is impossible to erase even a single element, print $0$.\n\n\n-----Examples-----\nInput\n6\n1 3 4 5 6 9\n\nOutput\n2\nInput\n3\n998 999 1000\n\nOutput\n2\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, JATC can erase the third and fourth elements, leaving the array $[1, 3, \\_, \\_, 6, 9]$. As you can see, there is only one way to fill in the blanks.\n\nIn the second example, JATC can erase the second and the third elements. The array will become $[998, \\_, \\_]$. Because all the elements are less than or equal to $1000$, the array is still can be restored. Note, that he can't erase the first $2$ elements.\n\nIn the third example, JATC can erase the first $4$ elements. Since all the elements are greater than or equal to $1$, Giraffe can still restore the array. Note, that he can't erase the last $4$ elements.",
        "solutions": "[\"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmx = 1\\np = 1\\nfor i in range(1, n + 2):\\n    if a[i] == a[i - 1] + 1:\\n        p += 1\\n        mx = max(p, mx)\\n    else:\\n        p = 1\\nprint(max(0, mx - 2))\", \"n = int(input())\\narr = [0] + list(map(int, input().split()))\\narr.append(1001)\\nmax_ = 0\\nkek = 0\\nfor i in range(1, len(arr)):\\n    if arr[i] - 1 == arr[i - 1]:\\n        kek += 1\\n    else:\\n        max_ = max(max_, kek - 1)\\n        kek = 0\\nmax_ = max(max_, kek - 1)\\nprint(max_)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\na = [0] + a + [1001]\\nans = 0\\ni = 0\\nwhile i <= n:\\n    j = i + 1\\n    while j <= n + 1 and a[j] == a[j - 1] + 1:\\n        j += 1\\n    ans = max(ans, j - i - 2)\\n    i = j\\nprint(ans)\", \"#int(input())\\n#map(int,input().split())\\n#[list(map(int,input().split())) for i in range(q)]\\n#print(\\\"YES\\\" * ans + \\\"NO\\\" * (1-ans))\\nn = int(input())\\nai = [0] + list(map(int,input().split())) + [1001]\\nans = 0\\nnum = 1\\nfor i in range(1,n+2):\\n    if ai[i] == ai[i-1]+1:\\n        num += 1\\n    else:\\n        ans = max(ans,num - 2)\\n        num = 1\\nprint(max(ans,num - 2))\\n\", \"n = int(input())\\na = [0]\\na.extend(list(map(int, input().split())))\\na.append(1001)\\n\\nlongest = 0\\ni = 0\\n\\nwhile i < len(a):\\n    j = i + 1\\n    while j < len(a) and a[j-1] + 1 == a[j]:\\n        j += 1\\n    current = j - i - 2\\n    longest = max(longest, current)\\n    i = j\\n\\nprint(longest)\\n\", \"\\ndef main():\\n    buf = input()\\n    n = int(buf)\\n    buf = input()\\n    buflist = buf.split()\\n    a = list(map(int, buflist))\\n    a.insert(0, 0)\\n    a.append(1001)\\n    count = -1\\n    max_count = 0\\n    last_number = None\\n    for i, number in enumerate(a):\\n        if last_number == None:\\n            pass\\n        elif number == last_number + 1:\\n            count += 1\\n            if count > max_count:\\n                max_count = count\\n        else:\\n            count = -1\\n        last_number = number\\n    print(max_count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nn += 2\\na = list(map(int, input().split()))\\na = [0] + a\\na = a + [1001]\\nind = 0\\nans = 0\\nwhile ind != n:\\n    now = 0\\n    while ind + 1 != n and a[ind] + 1 == a[ind + 1]:\\n        ind += 1\\n        now += 1\\n    ind += 1\\n    ans = max(ans, now - 1)\\nprint(ans)\\n\", \"n=int(input())\\ns=input().split()\\nl=[0]+[int(s[i]) for i in range(n)]+[1001]\\nmaxlen=0\\nprev=0\\ncnt=1\\nfor i in range(1,n+2):\\n    if prev==l[i]-1:\\n        cnt+=1\\n    else:\\n        maxlen=max(maxlen,cnt-2)\\n        cnt=1\\n    prev=l[i]\\nmaxlen=max(maxlen,cnt-2)\\nprint(maxlen)\\n\", \"n = int(input())\\narr = [int(x) for x in input().split()]\\nma = 0\\ncnt = 0\\nif len(arr) == 1000:\\n    print(1000)\\nelse:\\n    for i in range(len(arr) - 1):\\n        if arr[i + 1] == arr[i] + 1:\\n            cnt += 1\\n            if arr[i] == 1 or arr[i + 1] == 1000:\\n                cnt += 1\\n        else:\\n            ma = max(ma, cnt)\\n            cnt = 0\\nma = max(ma, cnt)\\nprint(max(0, ma - 1))\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nfor i in range(n):\\n\\tfor j in range(i + 2, n):\\n\\t\\tif arr[j] - arr[i] == j - i:\\n\\t\\t\\tans = max(ans, j - i - 1)\\nfor i in range(n):\\n\\tif arr[i] == i + 1:\\n\\t\\tans = max(ans, i)\\nfor i in range(n):\\n\\tif n - i - 1 == 1000 - arr[i]:\\n\\t\\tans = max(ans, n - i - 1)\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = 0\\nfor i in range(n):\\n    if a[i] == 1:\\n        xm = 2\\n    else:\\n        xm = 1\\n    for j in range(i+1, n):\\n        if a[j]-a[j-1] == 1:\\n            xm += 1\\n            if a[j] == 1000:\\n                xm += 1\\n        else:\\n            break\\n    x = max(x, xm-2)\\nprint(x)\", \"n = int(input())\\narr = [0] + [int(x) for x in input().split()] + [1001]\\n\\narr2 = []\\nfor a, b in zip(arr, arr[1:]):\\n  arr2.append(b-a)\\n\\nlongest = 0\\ncurrent = 0\\nfor x in arr2:\\n  if x == 1:\\n    current += 1\\n  else:\\n    longest = max(longest, current)\\n    current = 0\\nlongest = max(longest, current)\\n\\nprint(max(longest - 1, 0))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nfor i in range(0, n):\\n    for j in range(i + 1, n):\\n        if a[j] - a[i] == j - i:\\n            if a[j] == 1000 or a[i] == 1 and not (a[j] == 1000 and a[i] == 1):\\n                ans = max(j - i, ans)\\n            if a[j] == 1000 and a[i] == 1:\\n                ans = 1000\\n            else:\\n                ans = max(j - i - 1, ans)\\nprint(ans)\\n\", \"#!/usr/bin/env python3\\nfrom typing import Dict, List, Tuple\\n\\n\\ndef input_lst() -> List[int]:\\n    return [int(x) for x in input().split()]\\n\\ndef print_out(res: List[int]):\\n    print(' '.join([str(x) for x in res]))\\n\\n\\ndef main():\\n    n,  = (int(x) for x in input().split())\\n    a = input_lst()\\n\\n    l = 0\\n    l_max = 0\\n    if a[0] == 1:\\n        l+=1\\n\\n    for i in range(n-1):\\n        if a[i+1] - a[i] == 1:\\n            l+=1\\n        else:\\n            if l>0:\\n                l_max = max(l, l_max)\\n                l = 0\\n\\n    if l > 0:\\n        if a[-1] == 1000:\\n            l+=1\\n        l_max = max(l, l_max)\\n\\n    print(max(l_max-1, 0))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = [0] + [int(i) for i in input().split()] + [1001]\\nans = 0\\nfor j in range(1, n + 1):\\n    i = j\\n    f = 0\\n    while i < n + 1 and a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        f += 1\\n        i += 1\\n    ans = max(ans, f)\\nprint(ans)\", \"import sys\\ninput_file = sys.stdin\\n\\nn = int(input_file.readline())\\nlst = [0] + list(int(i) for i in input_file.readline().split()) + [1001]\\n#print(n, lst)\\nmaxi = 1\\nans = 1\\nfor i in range(1, len(lst)):\\n    if lst[i] == lst[i-1] + 1:\\n        ans += 1\\n    else:\\n        #print(ans)\\n        maxi = max(maxi, ans)\\n        ans = 1\\nmaxi = max(maxi, ans)\\n        \\n\\nprint(max(maxi-2, 0))\\n    \\n\", \"n=int(input())\\nA=list(map(int,input().split()))\\nA=[0]+A+[1001]\\n\\nANS=0\\ncount=0\\nfor i in range(1,n+1):\\n    if A[i]==A[i-1]+1 and A[i]==A[i+1]-1:\\n        count+=1\\n    else:\\n        ANS=max(ANS,count)\\n        count=0\\n\\nANS=max(ANS,count)\\nprint(ANS)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\ns = [0] + s[:] + [1001]\\nc = 0\\nmaxc = 0\\nfor i in range(1, len(s)):\\n\\tif s[i] - s[i - 1] == 1:\\n\\t\\tc += 1\\n\\t\\tif c > maxc:\\n\\t\\t\\tmaxc = c-1\\n\\telse:\\n\\t\\tc = 0\\nprint(maxc)\", \"from sys import stdin, stdout\\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\\n\\nn = int(stdin.readline())\\nvl = list(map(int, stdin.readline().split()))\\nans = 0\\n\\nfor i in range(n):\\n    cnt = 0\\n    while i + cnt < n and vl[i + cnt] == vl[i] + cnt:\\n        cnt += 1\\n    \\n    ans = max(ans, cnt - 2)\\n        \\n\\ncnt1 = 0\\nwhile cnt1 < n and vl[cnt1] == cnt1 + 1:\\n    cnt1 += 1\\n\\ncnt2 = 0\\nwhile cnt2 < n and vl[n - 1 - cnt2] == 10 ** 3 - cnt2:\\n    cnt2 += 1\\n\\nans = max(ans, max(cnt1, cnt2) - 1)\\nstdout.write(str(ans))\", \"# use this as the main template for python problems\\nfrom collections import Counter\\n\\ndef solution(n, arr):\\n    arr = [0] + arr\\n    arr.append(1001)\\n    \\n    best = 0\\n    count = 0\\n    for ind, val in enumerate(arr[:-2]):\\n        if(val+1 == arr[ind+1] and (val+2 == arr[ind+2])):\\n            count += 1\\n        else:\\n            if(best < count):\\n                best = count\\n            count = 0\\n    print(max(best, count))\\n\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in input().split()][0]\\n\\n    # vectors\\n    arr = [int(val) for val in input().split()]\\n\\n    # solve it!\\n    solution(n, arr)\\n\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\na = [0] + a + [1001]\\n\\nans = 0\\nfor i in range(len(a)):\\n    for j in range(i + 3, len(a) + 1):\\n        if a[i : j] == list(range(a[i], a[i] + j - i)):\\n            ans = max(ans, j - i - 2)\\n\\nprint(ans)\", \"n = int(input())\\na = [0] + list(map(int, input().split())) + [1001]\\nmax_ans = 0\\nans = 0\\n\\nfor i in range(1, len(a) - 1):\\n    #print('cur' , a[i])\\n    if a[i] == a[i - 1] + 1 and a[i] == a[i + 1] - 1:\\n        ans += 1\\n        #print('+1')\\n    else:\\n        #print(a[i], ans, max_ans)\\n        #print(max(ans, max_ans))\\n        max_ans = max(ans, max_ans)\\n        ans = 0\\n\\nprint(max(max_ans, ans))\\n\", \"def user99():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = [[] for i in range(n)]\\n\\n    ptr = 0\\n    for i in range(n):\\n        if i >= 1 and a[i - 1] + 1 != a[i]:\\n            ptr += 1\\n        b[ptr].append(a[i])\\n\\n    ans = 0\\n    for i in b:\\n        if len(i) == 0:\\n            continue;\\n        x = len(i) - 2\\n        if i[0] == 1: x += 1\\n        if i[-1] == 10**3: x += 1\\n        ans = max(ans, x)\\n\\n    print(ans)\\n\\nuser99()\", \"n = int(input())\\nA = [0] + list(map(int,  input().split())) + [1001]\\n\\nc = 0\\nans = 0\\nfor i in range(1,n+1):\\n  if A[i]-1 == A[i-1] and A[i]+1 == A[i+1]:\\n    c += 1\\n  else:\\n    c = 0\\n\\n  ans = max(ans, c)\\n\\nprint(ans)\\n \\n\\n\", \"n = int(input())\\na  = [0] + list(map(int, input().split())) + [1001]\\nres = 1\\ncur = 1\\n\\nfor i in range(n+1):\\n    if a[i+1] - a[i] == 1:\\n        cur += 1\\n    else:\\n        cur = 1\\n    res  = max(res, cur)\\nprint(max(0, res - 2))\\n\"]",
        "difficulty": "interview",
        "input": "3\n10 11 12\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1062/A"
    },
    {
        "id": 1034,
        "task_id": 181,
        "test_case_id": 20,
        "question": "Vasya started working in a machine vision company of IT City. Vasya's team creates software and hardware for identification of people by their face.\n\nOne of the project's know-how is a camera rotating around its optical axis on shooting. People see an eye-catching gadget — a rotating camera — come up to it to see it better, look into it. And the camera takes their photo at that time. What could be better for high quality identification?\n\nBut not everything is so simple. The pictures from camera appear rotated too (on clockwise camera rotation frame the content becomes rotated counter-clockwise). But the identification algorithm can work only with faces that are just slightly deviated from vertical.\n\nVasya was entrusted to correct the situation — to rotate a captured image so that image would be minimally deviated from vertical. Requirements were severe. Firstly, the picture should be rotated only on angle divisible by 90 degrees to not lose a bit of information about the image. Secondly, the frames from the camera are so huge and FPS is so big that adequate rotation speed is provided by hardware FPGA solution only. And this solution can rotate only by 90 degrees clockwise. Of course, one can apply 90 degrees turn several times but for the sake of performance the number of turns should be minimized.\n\nHelp Vasya implement the program that by the given rotation angle of the camera can determine the minimum number of 90 degrees clockwise turns necessary to get a picture in which up direction deviation from vertical is minimum.\n\nThe next figure contains frames taken from an unrotated camera, then from rotated 90 degrees clockwise, then from rotated 90 degrees counter-clockwise. Arrows show direction to \"true up\". [Image] \n\nThe next figure shows 90 degrees clockwise turn by FPGA hardware. [Image] \n\n\n-----Input-----\n\nThe only line of the input contains one integer x ( - 10^18 ≤ x ≤ 10^18) — camera angle in degrees. Positive value denotes clockwise camera rotation, negative — counter-clockwise.\n\n\n-----Output-----\n\nOutput one integer — the minimum required number of 90 degrees clockwise turns.\n\n\n-----Examples-----\nInput\n60\n\nOutput\n1\n\nInput\n-60\n\nOutput\n3\n\n\n\n-----Note-----\n\nWhen the camera is rotated 60 degrees counter-clockwise (the second example), an image from it is rotated 60 degrees clockwise. One 90 degrees clockwise turn of the image result in 150 degrees clockwise total rotation and deviation from \"true up\" for one turn is 150 degrees. Two 90 degrees clockwise turns of the image result in 240 degrees clockwise total rotation and deviation from \"true up\" for two turns is 120 degrees because 240 degrees clockwise equal to 120 degrees counter-clockwise. Three 90 degrees clockwise turns of the image result in 330 degrees clockwise total rotation and deviation from \"true up\" for three turns is 30 degrees because 330 degrees clockwise equal to 30 degrees counter-clockwise.\n\nFrom 60, 150, 120 and 30 degrees deviations the smallest is 30, and it it achieved in three 90 degrees clockwise turns.",
        "solutions": "[\"n = (-int(input())) % 360\\n\\nret, opt = 4, 361\\nfor i in range(4):\\n    x = (n+90*i)%360\\n    x = min(x, 360-x)\\n    if (x, i) < (opt, ret):\\n        opt, ret = x, i\\n\\nprint(ret)\", \"from functools import reduce\\nfrom math import factorial\\nn = (int(input()) + 45) % 360\\nprint(n // 90 - (n > 0 and n%90 == 0))\\n\\n\", \"n=int(input())%360\\nif n<=45: print(0)\\nelif n<=90+45: print(1)\\nelif n<=180+45: print(2)\\nelif n<270+45: print(3)\\nelse: print(0)\\n\", \"def sign(x):\\n    return 1 if x > 0 else -1\\n\\ndef dis(x):\\n    if x >= 360:\\n        x %= 360\\n\\n    if x <= -180:\\n        return 360 + x\\n    elif x <= 0:\\n        return abs(x)\\n    elif x <= 180:\\n        return x\\n    else:\\n        return 360-x\\n\\ndef __starting_point():\\n\\n    x = int(input())\\n    x = (-sign(x))*(abs(x)%360)\\n    #print(x)\\n\\n    mindis = dis(x)\\n    res = 0\\n\\n    for i in range(1,4):\\n        newdis = dis(x+90*i)\\n        if newdis < mindis:\\n            mindis = newdis\\n            res = i\\n\\n    print(res)\\n\\n__starting_point()\", \"def f(x):\\n    assert(0 <= x <= 360)\\n    return min(x, 360 - x)\\n\\ndef main():\\n    x = int(input())\\n    a, b, c, d = -x, -x+90, -x+180, -x+270\\n    a, b, c, d = a%360, b%360, c%360, d%360\\n    a, b, c, d = f(a), f(b), f(c), f(d)\\n    L = [(a, 0), (b, 1), (c, 2), (d, 3)]\\n    L.sort()\\n    print(L[0][1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\nn %= 360\\n\\n_0 = min(360 - n, n)\\nn = (n - 90) % 360\\n_1 = min(360 - n, n)\\nn = (n - 90) % 360\\n_2 = min(360 - n, n)\\nn = (n - 90) % 360\\n_3 = min(360 - n, n)\\n\\nif (_0 <= min(_1, min(_2, _3))):\\n    print(0)\\n    return\\nif (_1 <= min(_0, min(_2, _3))):\\n    print(1)\\n    return\\nif (_2 <= min(_1, min(_0, _3))):\\n    print(2)\\n    return\\nif (_3 <= min(_1, min(_2, _0))):\\n    print(3)\\n    return\", \"x = -int(input()) % 360\\n\\nl = [x, x+90, x+180, x+270]\\nl = [min(x%360, (-x)%360) for x in l]\\nm = min(l)\\n#print(l)\\nprint(l.index(m))\\n\\n\", \"n = int(input())\\nn=(n*-1)%360\\n\\nminVueltas = -1\\nminValor = -1\\nfor i in range(4):\\n    temp = (n+90*i)%360\\n    if temp>180:\\n        temp = 360-temp\\n    if minValor==-1 or temp<minValor:\\n        minVueltas=i\\n        minValor=temp\\nprint(minVueltas)\\n\", \"n = int(input())\\nn += 3600000000000000000\\nn %= 360\\n\\nif n <= 45:\\n    print(0)\\nelif n <= 135:\\n    print(1)\\nelif n <= 225:\\n    print(2)\\nelif n < 315:\\n    print(3)\\nelse:\\n    print(0)\", \"x = int(input())\\nx = x % 360\\nif (x <= 45 or x >= 315):\\n    print(0)\\nelif (x >= 45 and x <= 135):\\n    print(1)\\nelif (x >= 135 and x <= 225):\\n    print(2)\\nelse:\\n    print(3)\\n\", \"n = (360 + int(input()) % 360) % 360\\n\\nans = 0\\nbres = n\\n\\nfor i in range(1, 5):\\n    d = (360 + (n - i * 90) % 360) % 360\\n    if min(d, 360 - d) < min(bres, 360 - bres):\\n        bres = d\\n        ans = i\\n\\nprint(ans)\", \"n = (int(input())+45)%360\\nif n%90==0 and n!=0:\\n    print(n//90-1)\\nelse:\\n    print(n//90)\\n\", \"n = int(input()) % 360\\nif 45 < n <= 135:\\n    print(1)\\nelif 135 < n <= 225:\\n    print(2)\\nelif 225 < n < 315:\\n    print(3)\\nelse:\\n    print(0)\\n\", \"import math, re, sys, string, operator, functools, fractions, collections\\nsys.setrecursionlimit(10**7)\\ndX= [-1, 1, 0, 0,-1, 1,-1, 1]\\ndY= [ 0, 0,-1, 1, 1,-1,-1, 1]\\nRI=lambda x=' ': list(map(int,input().split(x)))\\nRS=lambda x=' ': input().rstrip().split(x)\\nmod=int(1e9+7)\\neps=1e-6\\n#################################################\\nx=RI()[0]\\nx%=360\\nif x>180:\\n    x=x-360\\nans=0\\nval=abs(x)\\nfor i in range(1,4):\\n    x-=90\\n    if x<-180:\\n        x=360+x\\n    if abs(x)<val:\\n        val=abs(x)\\n        ans=i\\nprint(ans)\\n\\n\\n\\n\", \"n = int(input())\\nans = 0\\nn %= 360\\n\\nif n <= 45 or n >= 270:\\n    ans = 0\\nif n > 45 and n <= 135:\\n    ans = 1\\nif n > 135 and n <= 225:\\n    ans = 2\\nif n > 225 and n < 315:\\n    ans = 3\\nprint(ans)\\n\", \"n=int(input())\\nn+=3600000000000000000000\\nx=n%360\\nif (x<=45):\\n\\tprint(0)\\nelif (x<=135):\\n\\tprint(1)\\nelif (x<=225):\\n\\tprint(2)\\nelif (x<315):\\n\\tprint(3)\\nelif (x>=315):\\n\\tprint(0)\", \"import sys\\n\\n\\ndef chet(a, b):\\n    ans = (b - a) // 2\\n    if b % 2 == 0 or a % 2 == 0:\\n        ans += 1\\n    return ans\\n\\n\\ndef nechet(a, b):\\n    ans = (b - a) // 2\\n    if b % 2 == 1 or a % 2 == 1:\\n        ans += 1\\n    return ans\\n\\n\\ndef ans(a, b, c, d):\\n    return chet(a, c) * chet(b, d) + nechet(a, c) * nechet(b, d)\\n\\n\\nn = int(input())\\nras = n // 360\\nk = n - 360 * ras\\nost = (k + 45) % 90\\nd = (k + 45) // 90\\nans = d if (ost > 0 or d % 4 == 0) else d - 1\\nprint(ans % 4)\\n\\n\\n\\n\\n\\n\\n\", \"x = (int(input()) + 360 * 10 ** 18) % 360\\n\\nif x <= 45 or x >= 315:\\n    print(0)\\nelif x <= 135:\\n    print(1)\\nelif x <= 225:\\n    print(2)\\nelse:\\n    print(3)\", \"import math\\n\\nx=int(input())\\nx %= 360\\nx = 360-x\\ncurnum=x\\nfor i in range(4):\\n\\tif curnum <= 45:\\n\\t\\tprint(i)\\n\\t\\tquit()\\n\\tif 360-curnum <= 45:\\n\\t\\tprint(i)\\n\\t\\tquit()\\n\\tcurnum = (curnum+90) % 360\", \"angle = int(input())\\nangle = (angle % 360 + 360) % 360\\nangle = (angle + 44) % 360\\nanswer = (angle % 359) // 90\\nprint(answer)\", \"n = int(input())\\n\\nt = n - (n // 360) * 360\\ni = 0\\nwhile not (-45 <= t <= 45 or 315 <= t <= 360):\\n\\ti += 1\\n\\tt -= 90\\nprint(i)\\n\", \"import sys\\nimport math\\n# sys.stdin = open('input.txt')\\n# sys.stdout = open('output.txt', 'w')\\n\\ndef main():\\n    n = int(input())\\n    n = -n\\n    n %= 360\\n    a = n\\n    a1 = 360 - a\\n    b = (a + 90) % 360    \\n    b1 = 360 - b\\n    c = (b + 90) % 360\\n    c1 = 360 - c\\n    d = (c + 90) % 360\\n    d1 = 360 - d\\n    ans = min([a, a1, b, b1, c, c1, d, d1])\\n    if a == ans or a1 == ans:\\n        print(0)\\n    elif b == ans or b1 == ans:\\n        print(1)\\n    elif c == ans or c1 == ans:\\n        print(2)\\n    elif d == ans or d1 == ans:\\n        print(3)\\n\\nmain()\"]",
        "difficulty": "interview",
        "input": "360\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/630/M"
    },
    {
        "id": 1035,
        "task_id": 212,
        "test_case_id": 4,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "8996988892\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1036,
        "task_id": 212,
        "test_case_id": 7,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "8147522776919916277306861346922924221557534659480258977017038624458370459299847590937757625791239188\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1037,
        "task_id": 212,
        "test_case_id": 13,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "7674\n",
        "output": "YES\n64\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1038,
        "task_id": 212,
        "test_case_id": 17,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "3144\n",
        "output": "YES\n344\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1039,
        "task_id": 212,
        "test_case_id": 19,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "1000\n",
        "output": "YES\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1040,
        "task_id": 212,
        "test_case_id": 20,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "303\n",
        "output": "YES\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1041,
        "task_id": 212,
        "test_case_id": 21,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "111111111111111111111171111111111111111111111111111112\n",
        "output": "YES\n72\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1042,
        "task_id": 212,
        "test_case_id": 22,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "3111111111111111111111411111111111111111111141111111441\n",
        "output": "YES\n344\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1043,
        "task_id": 212,
        "test_case_id": 23,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "7486897358699809313898215064443112428113331907121460549315254356705507612143346801724124391167293733\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1044,
        "task_id": 212,
        "test_case_id": 24,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "1787075866\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1045,
        "task_id": 212,
        "test_case_id": 25,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "836501278190105055089734832290981\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1046,
        "task_id": 212,
        "test_case_id": 29,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n",
        "output": "YES\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1047,
        "task_id": 212,
        "test_case_id": 32,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "88888888888888888888888888888888888888888888888888888888888888888888888888888888\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1048,
        "task_id": 212,
        "test_case_id": 48,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "8353\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1049,
        "task_id": 212,
        "test_case_id": 50,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "4426155776626276881222352363321488266188669874572115686737742545442766138617391954346963915982759371\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1050,
        "task_id": 212,
        "test_case_id": 51,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "9592419524227735697379444145348135927975358347769514686865768941989693174565893724972575152874281772\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1051,
        "task_id": 212,
        "test_case_id": 52,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "94552498866729239313265973246288189853135485783461\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1052,
        "task_id": 212,
        "test_case_id": 53,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "647934465937812\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1053,
        "task_id": 212,
        "test_case_id": 54,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "1327917795375366484539554526312125336\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1054,
        "task_id": 212,
        "test_case_id": 55,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "295971811535848297878828225646878276486982655866912496735794542\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1055,
        "task_id": 212,
        "test_case_id": 56,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "7217495392264549817889283233368819844137671271383133997418139697797385729777632527678136\n",
        "output": "YES\n8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1056,
        "task_id": 212,
        "test_case_id": 57,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "11111111111111111111112111111111\n",
        "output": "YES\n112\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1057,
        "task_id": 212,
        "test_case_id": 59,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "1000000000000000000000000000000000000\n",
        "output": "YES\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1058,
        "task_id": 212,
        "test_case_id": 60,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "9969929446\n",
        "output": "YES\n96\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1059,
        "task_id": 212,
        "test_case_id": 61,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "43523522125549722432232256557771715456345544922144\n",
        "output": "YES\n32\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1060,
        "task_id": 212,
        "test_case_id": 62,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "9344661521956564755454992376342544254667536539463277572111263273131199437332443253296774957\n",
        "output": "YES\n96\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1061,
        "task_id": 212,
        "test_case_id": 63,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "1946374341357914632311595531429723377642197432217137651552992479954116463332543456759911377223599715\n",
        "output": "YES\n16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1062,
        "task_id": 212,
        "test_case_id": 65,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "461592\n",
        "output": "YES\n152\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1063,
        "task_id": 212,
        "test_case_id": 66,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "46159237\n",
        "output": "YES\n152\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1064,
        "task_id": 212,
        "test_case_id": 68,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "42376\n",
        "output": "YES\n376\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1065,
        "task_id": 212,
        "test_case_id": 69,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "42376159\n",
        "output": "YES\n376\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1066,
        "task_id": 212,
        "test_case_id": 72,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "33332\n",
        "output": "YES\n32\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1067,
        "task_id": 212,
        "test_case_id": 73,
        "question": "You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.\n\nYour task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.\n\nIf a solution exists, you should print it.\n\n\n-----Input-----\n\nThe single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits. \n\n\n-----Output-----\n\nPrint \"NO\" (without quotes), if there is no such way to remove some digits from number n. \n\nOtherwise, print \"YES\" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8.\n\nIf there are multiple possible answers, you may print any of them.\n\n\n-----Examples-----\nInput\n3454\n\nOutput\nYES\n344\n\nInput\n10\n\nOutput\nYES\n0\n\nInput\n111111\n\nOutput\nNO",
        "solutions": "[\"n1 = input()\\nn = []\\nfor i in n1:\\n    n.append(int(i))\\nk = len(n)\\n\\nfor i in range(k):\\n    if (n[i] % 8) == 0:\\n        print(\\\"YES\\\")\\n        print(n[i])\\n        return\\n\\nif k > 1:\\n    for i in range(k):\\n        t = n[i] * 10\\n        for j in range(i+1, k):\\n            if (t+n[j]) % 8 == 0:\\n                print(\\\"YES\\\")\\n                print(t+n[j])\\n                return\\nif k > 2:\\n    for i in range(k):\\n        t = n[i]*100\\n        for j in range(i+1, k):\\n            l = n[j]*10\\n            for e in range(j+1, k):\\n                #print(t, l, n[e])\\n                if (t+l+n[e]) % 8 == 0:\\n                    print(\\\"YES\\\")\\n                    print(t+l+n[e])\\n                    return\\nprint(\\\"NO\\\")\\n\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\nimport time\\n\\ns    = input()\\nflag = False\\nans  = \\\"\\\"\\n\\nstart = time.time()\\nfor i in s:\\n    if i == '8' or i =='0':\\n        ans = i\\n        break\\n\\nif len(s) >= 2 and ans == \\\"\\\":\\n    for i in range(len(s)-1):\\n        for j in range(i+1, len(s)):\\n            if divmod(int(s[i]+s[j]), 8)[1] == 0:\\n                ans = s[i]+s[j]\\n                break\\n\\n        if ans != \\\"\\\":\\n            break\\n\\nif len(s) >= 3 and ans ==\\\"\\\":\\n    for i in range(len(s)-2):\\n        for j in range(i+1, len(s)-1):\\n            for k in range(j+1, len(s)):\\n                if divmod(int(s[i]+s[j]+s[k]), 8)[1] == 0:\\n                    ans = s[i]+s[j]+s[k]\\n                    break\\n            if ans != \\\"\\\":\\n                break\\n        if ans != \\\"\\\":\\n            break\\n\\nif ans == \\\"\\\":\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\\n    print(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\"]",
        "difficulty": "interview",
        "input": "6499999999\n",
        "output": "YES\n64\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/550/C"
    },
    {
        "id": 1068,
        "task_id": 226,
        "test_case_id": 3,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "1\n100000\n",
        "output": "0 100000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 1069,
        "task_id": 226,
        "test_case_id": 9,
        "question": "You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob have many slices of pie, and rather than cutting the slices in half, each individual slice will be eaten by just one person.\n\nThe way Alice and Bob decide who eats each slice is as follows. First, the order in which the pies are to be handed out is decided. There is a special token called the \"decider\" token, initially held by Bob. Until all the pie is handed out, whoever has the decider token will give the next slice of pie to one of the participants, and the decider token to the other participant. They continue until no slices of pie are left.\n\nAll of the slices are of excellent quality, so each participant obviously wants to maximize the total amount of pie they get to eat. Assuming both players make their decisions optimally, how much pie will each participant receive?\n\n\n-----Input-----\n\nInput will begin with an integer N (1 ≤ N ≤ 50), the number of slices of pie. \n\nFollowing this is a line with N integers indicating the sizes of the slices (each between 1 and 100000, inclusive), in the order in which they must be handed out.\n\n\n-----Output-----\n\nPrint two integers. First, the sum of the sizes of slices eaten by Alice, then the sum of the sizes of the slices eaten by Bob, assuming both players make their decisions optimally.\n\n\n-----Examples-----\nInput\n3\n141 592 653\n\nOutput\n653 733\n\nInput\n5\n10 21 10 21 10\n\nOutput\n31 41\n\n\n\n-----Note-----\n\nIn the first example, Bob takes the size 141 slice for himself and gives the decider token to Alice. Then Alice gives the size 592 slice to Bob and keeps the decider token for herself, so that she can then give the size 653 slice to herself.",
        "solutions": "[\"n = int(input())\\na = list(map(int, input().split()))\\na = a[::-1]\\nd = 0\\nfor i in range(len(a)):\\n    d = max(0 + d, a[i] + (sum(a[:i]) - d))\\nprint(sum(a)-d, d)\\n\", \"n = int(input())\\nX = list(map(int, input().split()))\\n\\nali = [None]*(n+1)\\nbob = [None]*(n+1)\\n\\nali[n] = 0\\nbob[n] = 0\\n\\nfor i in range(n-1, -1, -1):\\n\\tbob[i] = max(bob[i+1], ali[i+1]+X[i])\\n\\tali[i] = sum(X[i:n]) - bob[i]\\n\\t\\n#print(ali)\\n#print(bob)\\n\\nprint(ali[0], bob[0], sep=' ')\\n\\t\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ns = [0]*(N+1)\\ndp = [0]*(N+1)\\nfor i in range(N-1, -1, -1):\\n\\tdp[i] = max(A[i] + s[i+1] - dp[i+1], dp[i+1])\\n\\ts[i] = s[i+1] + A[i]\\nprint(s[0] - dp[0], dp[0])\", \"n = int(input())\\nvs = list(map(int, input().split(' ')))\\n\\nrs = [0, 0]\\n\\nfor i in range(n-1, -1, -1):\\n    rs = [\\n        min(vs[i] + rs[0], rs[1]),\\n        max(vs[i] + rs[0], rs[1])\\n    ]\\n\\nprint(sum(vs) - rs[1], rs[1])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\n\\ndef max_revenue(i, a):\\n    if i == len(a)-1:\\n        return a[-1], 0\\n    before = max_revenue(i+1, a)\\n    take = a[i] + before[1], before[0]\\n    give = before[0], a[i] + before[1]\\n\\n    if take[0] > give[0]:\\n        return take\\n    else:\\n        return give\\n\\nr = max_revenue(0, a)\\nprint(r[1], r[0])\\n\", \"\\nimport sys\\n#sys.stdin=open(\\\"data.txt\\\")\\ninput=sys.stdin.readline\\n\\nn=int(input())\\n\\npie=list(map(int,input().split()))\\n\\ndef dp(i):\\n    # best result for this player\\n    if i>=len(pie): return (0,0)\\n    t1,t2=dp(i+1)\\n    return (max(pie[i]+t2-t1,t1),t2+pie[i])\\n\\nt1,t2=dp(0)\\n\\nprint(t2-t1,t1)\", \"import math\\nfrom random import random\\n\\ndef getInt():\\n    return(int(input()))\\n\\ndef getInts():\\n    line = input().split()\\n    return [int(l) for l in line]\\n\\ndef getFloat():\\n    return(float(input()))\\n\\ndef getFloats():\\n    line = input().split()\\n    return [float(l) for l in line]\\n\\ndef getStrings():\\n    line = input().split()\\n    return(line)\\n\\n\\nN = getInt()\\nvalues = getInts()\\n\\nnConsidered = 0\\n#                nC, nO\\nbestForChooserSoFar = [0, 0]\\n\\nfor i in range(len(values)):\\n    v = values[len(values) - i - 1]\\n    qsIfTaken = [v + bestForChooserSoFar[1], bestForChooserSoFar[0]]\\n    qsIfGiven = [bestForChooserSoFar[0], v + bestForChooserSoFar[1]]\\n\\n    if(qsIfTaken[0] >= qsIfGiven[0]):\\n        bestForChooserSoFar = qsIfTaken\\n    else:\\n        bestForChooserSoFar = qsIfGiven\\n\\nprint(str(bestForChooserSoFar[1]) + ' ' + str(bestForChooserSoFar[0]))\", \"N = int(input())\\na = [int(i) for i in input().split()]\\n\\nsuffix = [a[-1]]\\ntok = [a[-1]]\\ntol = [0]\\nbest = [a[-1]]\\n\\nfor x in reversed(a[:-1]):\\n\\t# keep\\n\\tkeep = x + suffix[-1] - best[-1]\\n\\tgive = best[-1]\\n\\tbest.append(max(keep,give))\\n\\ttok.append(keep)\\n\\ttol.append(give)\\n\\tsuffix.append(suffix[-1] + x)\\n\\n# print(best, tok, tol, suffix)\\nprint(suffix[-1] - best[-1], best[-1])\\n\\t\\n\\n\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\na1 = [[-1] * 50, [-1] * 50]\\ndef get(i, fl):\\n    if i >= n:\\n        return 0\\n    if (a1[fl][i] != -1):\\n        return a1[fl][i]\\n    if fl == 0:\\n        a1[fl][i] = max(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    else:\\n        a1[fl][i] = min(a[i] + get(i + 1, 1), get(i + 1, 0))\\n    return a1[fl][i]\\n\\nan = get(0, 0)\\nprint(sum(a) - an, an)\\n\", \"n = int(input())\\ncake = list(map(int, input().split()))\\ncake.reverse()\\npref = [0]\\nfor i in range(n):\\n    pref.append(cake[i] + pref[-1])\\ndp = [0] * n\\ndp[0] = cake[0]\\nfor i in range(1, n):\\n    dp[i] = max(dp[i - 1], cake[i] + pref[i] - dp[i - 1])\\nprint(pref[n] - dp[n - 1], dp[n - 1])\", \"import math\\n\\n\\ndef main():\\n    n = int(input())\\n    slices = [int(x) for x in input().split()]\\n    dp = [[[0,0], [0,0]] for i in range(n)]\\n    dp[-1][0] = [slices[-1], 0]\\n    dp[-1][1] = [0, slices[-1]]\\n    for i in range(n-2, -1, -1):\\n        for j in range(0, 2):\\n            take = slices[i] + dp[i+1][1-j][j]\\n            do_not_take = dp[i+1][j][j]\\n            if take > do_not_take:\\n                dp[i][j][j] = take\\n                dp[i][j][1-j] = dp[i+1][1-j][1-j]\\n            else:\\n                dp[i][j][j] = do_not_take\\n                dp[i][j][1-j] = slices[i] + dp[i+1][j][1-j]\\n    print(dp[0][1][0], dp[0][1][1])\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"a = int(input())\\nb = list(map(int, input().split()))\\nsumA = 0\\nsumB = 0\\nfor i in range( a ):\\n    if b[a-1-i] > abs(sumA - sumB):\\n        sumA += b[a-1-i]\\n        sumA, sumB = sumB, sumA\\n    else:\\n        sumA += b[a-1-i]\\nprint(min(sumA,sumB), max(sumA, sumB))\", \"def maximum_pie_consumption(pies):\\n    c = len(pies) - 1\\n    toke = wait = 0\\n    for p in reversed(pies):\\n        if toke < p + wait:\\n            toke, wait = wait + p, toke\\n        else:\\n            wait += p\\n    return wait, toke\\n\\ndef __starting_point():\\n    input()\\n    pies = list(map(int, input().strip().split()))\\n    print(\\\" \\\".join(map(str, maximum_pie_consumption(pies))))\\n\\n__starting_point()\", \"n = int(input())\\npies = [int(x) for x in input().split()]\\n\\nd = {}\\nd[0] = pies[-1]\\n\\nfor i in range(1, n):\\n    d[i] = max(sum(pies[-1-i:]) - d[i-1], d[i-1])\\n\\ns = sum(pies)\\n\\nres = d[n-1]\\n\\nprint(s - res, res)\\n\", \"def check(i, bob):\\n    if i >= n:\\n        return 0, 0\\n    if dp[bob][i] != (-1, -1):\\n        return dp[bob][i]\\n    if bob:\\n        x = check(i+1, False)\\n        y = check(i+1, True)\\n        if x[0]+arr[i] >= y[0]:\\n            ret = x[0]+arr[i], x[1]\\n        else:\\n            ret = y[0], y[1]+arr[i]\\n    else:\\n        x = check(i+1, True,)\\n        y = check(i+1, False,)\\n        if x[1]+arr[i] >= y[1]:\\n            ret = x[0], x[1]+arr[i]\\n        else:\\n            ret = y[0]+arr[i], y[1]\\n    dp[bob][i] = ret\\n    return ret\\n\\n\\nn = int(input())\\n\\ndp = [(-1, -1)]*n\\ndp = [dp, dp.copy()]\\n\\narr = list(map(int, input().split()))\\nans = check(0, True)\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\na.reverse()\\n\\nd = [0 for i in range(n)]\\nd[0] = [a[0], 0]\\n\\nfor i in range(1, n):\\n    d[i] = [max(d[i-1][0], d[i-1][1] + a[i]), min(d[i-1][0], d[i-1][1] + a[i])]\\n\\nprint(d[-1][1], d[-1][0])\", \"n = int(input())\\na = list(map(int, input().split()))\\nx = s = 0\\nfor ai in reversed(a):\\n    x = max(x, ai + s - x)\\n    s += ai\\n\\nprint(s - x, x)\\n\", \"\\ndef dp(a, i,control):\\n    if i >= len(a):\\n        return 0;\\n    if dp_list[control][i] != -1:\\n        return dp_list[control][i]\\n    else:\\n        if control:\\n            res = max(a[i] + dp(a, i+1, False), dp(a , i+1 , True))\\n        else:\\n            res = min(dp(a, i+1, True), a[i] + dp(a , i+1 , False))\\n        dp_list[control][i] = res\\n        return dp_list[control][i]\\n\\nn = int(input())\\ndp_list = [list(-1 for i in range(n)) , list(-1 for i in range(n)) ]\\na = list(map(int, input().split(\\\" \\\")))\\nres = dp(a , 0, True)\\nprint(\\\"%s %s\\\" %(sum(a) - res , res ))\", \"\\n\\nimport sys\\n\\ncache = {}\\n\\ndef max_possible(pie_slices, current_slice, pre_sums):\\n\\n    if current_slice in cache:\\n        return cache[current_slice]\\n\\n    if len(pie_slices) - 1 == current_slice:\\n        return pie_slices[current_slice]\\n\\n\\n    max_score = -1\\n    for cs in range(current_slice, len(pie_slices) - 1):\\n        score = pie_slices[cs] + pre_sums[cs + 1] - max_possible(pie_slices, cs + 1, pre_sums)\\n\\n        if score > max_score:\\n            max_score = score\\n\\n    # if the last element gives the highest score\\n    if max_score < pie_slices[-1]:\\n        max_score = pie_slices[-1]\\n\\n    cache[current_slice] = max_score\\n\\n    return max_score\\n\\ndef main():\\n    n = int(sys.stdin.readline().strip())\\n\\n    pie_slices = [int(tok) for tok in sys.stdin.readline().strip().split()]\\n\\n    pre_sums = [sum(pie_slices[i:]) for i in range(len(pie_slices))]\\n\\n    b = max_possible(pie_slices, 0, pre_sums)\\n    print(sum(pie_slices) - b, b)\\n\\n\\n\\n\\n\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"N = int(input())\\nn = list(map(int,input().split(\\\" \\\")))\\n\\nif N == 1:\\n    ans = [0, n[0]]\\nelif N == 2:\\n    ans = [min(n), max(n)]\\nelse:\\n    # print(n)\\n    n.reverse()\\n    f = max(n[0], n[1]) # f2\\n    s = n[0] + n[1] # s2\\n    for i in range(2, N):\\n        f = max(n[i] + s - f, f)\\n        s += n[i]\\n    # print(f)\\n    # print(s)\\n    ans = [s-f, f]\\n        \\nprint(\\\" \\\".join(map(str,ans)))\\n\\n# assume f(n) is the optimal strategy for the remaning n pies, x_n, x_n-1, ...., x_1\\n#\\n# s(n) = sum(x_1,..., x_n)\\n# f(1) = x1\\n# f(2) = max(x2, x1)\\n# f(3) = max(x3 + s(2) - f(2), f(2))\\n# f(4) = max(x4 + s(3) - f(3), f(3))\\n\", \"'''\\ncodeforces.com/problemset/problem/859/C\\nauthor: latesum\\n'''\\nn = int(input())\\nv = list(map(int,input().split()))\\nv.reverse()\\nans = [0, 0]\\nfor i in range(n):\\n    if ans[1] + v[i] > ans[0]:\\n        t = ans[1] + v[i]\\n        ans[1] = ans[0]\\n        ans[0] = t\\n    else:\\n        ans[1] += v[i]\\nprint(ans[1], ans[0])\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nscore = a[n - 1]\\ntotal = a[n - 1]\\n\\nfor i in range(n - 2, -1, -1):\\n    new_score = a[i] + total - score\\n    if new_score > score:\\n        score = new_score\\n    total += a[i]\\n\\nprint(total - score, score)\", \"n=int(input())\\na=list(map(int,input().split()))[::-1]\\nif n!=1:\\n    summax,summin=max(a[0],a[1]),min(a[0],a[1])\\nelse:\\n    summin=0;summax=a[0]\\nfor i in range(2,n):\\n    if summax<summin + a[i]:\\n        summax,summin=summin + a[i],summax\\n    else:\\n        summin=summin+a[i]\\nprint(summin,summax)\", \"n = int(input())\\npieces = list(map(int, input().split()))\\n\\nreversed_pieces = list(reversed(pieces))\\n\\nTOTAL = []\\n\\ncurrent_total = 0\\nfor piece in reversed_pieces:\\n    current_total += piece\\n    TOTAL.append(current_total)\\n\\nHAS_TOKEN = 0\\nNO_TOKEN = 1\\n\\ndp_alice = [[0] * n, [0] * n]\\ndp_bob = [[0] * n, [0] * n]\\n\\n\\ndp_alice[HAS_TOKEN][0] = dp_bob[HAS_TOKEN][0] = reversed_pieces[0]\\ndp_alice[NO_TOKEN][0] = dp_bob[NO_TOKEN][0] = 0\\n\\nfor i in range(1, n):\\n    dp_alice[HAS_TOKEN][i] = max(dp_alice[HAS_TOKEN][i-1], dp_alice[NO_TOKEN][i-1] + reversed_pieces[i])\\n    dp_bob[HAS_TOKEN][i] = max(dp_bob[HAS_TOKEN][i-1], dp_bob[NO_TOKEN][i-1] + reversed_pieces[i])\\n\\n    dp_alice[NO_TOKEN][i] = TOTAL[i] - dp_bob[HAS_TOKEN][i]\\n    dp_bob[NO_TOKEN][i] = TOTAL[i] - dp_alice[HAS_TOKEN][i]\\n\\nprint(dp_alice[NO_TOKEN][-1], dp_bob[HAS_TOKEN][-1])\\n\"]",
        "difficulty": "interview",
        "input": "1\n59139\n",
        "output": "0 59139\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/859/C"
    },
    {
        "id": 1070,
        "task_id": 250,
        "test_case_id": 9,
        "question": "As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake.\n\nSimple cake is a cylinder of some radius and height. The volume of the simple cake is equal to the volume of corresponding cylinder. Babaei has n simple cakes and he is going to make a special cake placing some cylinders on each other.\n\nHowever, there are some additional culinary restrictions. The cakes are numbered in such a way that the cake number i can be placed only on the table or on some cake number j where j < i. Moreover, in order to impress friends Babaei will put the cake i on top of the cake j only if the volume of the cake i is strictly greater than the volume of the cake j.\n\nBabaei wants to prepare a birthday cake that has a maximum possible total volume. Help him find this value.\n\n\n-----Input-----\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of simple cakes Babaei has.\n\nEach of the following n lines contains two integers r_{i} and h_{i} (1 ≤ r_{i}, h_{i} ≤ 10 000), giving the radius and height of the i-th cake.\n\n\n-----Output-----\n\nPrint the maximum volume of the cake that Babaei can make. Your answer will be considered correct if its absolute or relative error does not exceed 10^{ - 6}.\n\nNamely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if $\\frac{|a - b|}{\\operatorname{max}(1, b)} \\leq 10^{-6}$.\n\n\n-----Examples-----\nInput\n2\n100 30\n40 10\n\nOutput\n942477.796077000\n\nInput\n4\n1 1\n9 7\n1 4\n10 7\n\nOutput\n3983.539484752\n\n\n\n-----Note-----\n\nIn first sample, the optimal way is to choose the cake number 1.\n\nIn second sample, the way to get the maximum volume is to use cakes with indices 1, 2 and 4.",
        "solutions": "[\"import math\\nfrom functools import reduce\\nclass SegmentTree():\\n    def __init__(self, L, function = lambda x,y: x+y):\\n        self.function = function\\n        N = self.size = len(L)\\n        M = 1 << N.bit_length()\\n        self.margin = 2*M - N\\n        self.L = [None for i in range(self.margin)] + L\\n        for i in range(M-1, 0, -1):\\n            x, y = self.L[i<<1], self.L[i<<1|1]\\n            self.L[i] = None if x is None or y is None else function(x, y)\\n    def modify(self, pos, value):\\n        p = pos + self.margin\\n        self.L[p] = value \\n        while p > 1:\\n            x, y = self.L[p], self.L[p^1]\\n            if p&1: x, y = y, x\\n            self.L[p>>1] = None if x is None or y is None else self.function(x, y)\\n            p>>=1\\n    def query(self, left, right):\\n        l, r = left + self.margin, right + self.margin\\n        stack = []\\n        void = True\\n        while l < r:\\n            if l&1:\\n                if void:\\n                    result = self.L[l]\\n                    void = False\\n                else:\\n                    result = self.function(result, self.L[l])\\n                l+=1\\n            if r&1:\\n                r-=1\\n                stack.append(self.L[r])\\n            l>>=1\\n            r>>=1\\n        init = stack.pop() if void else result\\n        return reduce(self.function, reversed(stack), init)\\n\\nn = int(input())\\npies, index, first_equal = [0]*n, [0]*n, [0]*n\\nfor i in range(n):\\n    r, h = [int(x) for x in input().split()]\\n    pies[i] = r*r*h\\ns_pies = list(sorted(enumerate(pies), key = lambda p: p[1]))\\nfor i in range(n): index[s_pies[i][0]] = i\\nfor i in range(1, n):\\n    first_equal[s_pies[i][0]] = i if s_pies[i][1] != s_pies[i-1][1] else first_equal[s_pies[i-1][0]]\\ntowers = SegmentTree([0]*(n+1), max)\\nfor j, pie in enumerate(pies):\\n    i, k = index[j], first_equal[j]\\n    q = towers.query(0, k+1)\\n    towers.modify(i+1, q + pie)\\nprint(math.pi * towers.query(0, n+1))\\n\", \"from math import *\\nfrom bisect import *\\n\\ndef update(bit, size, idx, amount):\\n    while idx <= size:\\n        if bit[idx] < amount:\\n            bit[idx] = amount\\n        idx += idx & -idx\\n\\ndef read(bit, idx):\\n    rst = 0\\n    while idx >= 1:\\n        if bit[idx] > rst:\\n            rst = bit[idx]\\n        idx -= idx & -idx\\n    return rst\\n\\nn = int(input())\\narr = [list(map(int, input().split())) for _ in range(n)]\\narr = [r*r*h for r, h in arr]\\n\\narr2 = sorted(list(set(arr)))\\nn2 = len(arr2)\\nbit = [0] * (n2 + 1)\\n\\nfor v in arr:\\n    idx = bisect(arr2, v)\\n    update(bit, n2, idx, read(bit, idx-1) + v)\\n\\nprint(pi*max(bit))\\n\", \"from math import *\\nfrom bisect import *\\n\\ndef update(bit, size, idx, amount):\\n    while idx <= size:\\n        if bit[idx] < amount:\\n            bit[idx] = amount\\n        idx += idx & -idx\\n\\ndef read(bit, idx):\\n    rst = 0\\n    while idx >= 1:\\n        if bit[idx] > rst:\\n            rst = bit[idx]\\n        idx -= idx & -idx\\n    return rst\\n\\nn = int(input())\\narr = [map(int, input().split()) for _ in range(n)]\\narr = [pi*(r*r*h) for r, h in arr]\\n\\narr2 = sorted(list(set(arr)))\\nn2 = len(arr2)\\nbit = [0.0] * (n2 + 1)\\n\\nfor v in arr:\\n    idx = bisect(arr2, v)\\n    update(bit, n2, idx, read(bit, idx-1) + v)\\n\\nprint(max(bit))\", \"from sys import *\\nt = list(map(int, stdin.read().split()))\\np = [t[i + 1] * t[i] ** 2 for i in range(1, len(t), 2)]\\nk = {v: j for j, v in enumerate(sorted(set(p)))}\\nd = [0] * (len(k) + 1)\\nfor v in p: \\n    j = k[v]\\n    i = j + 1\\n    q = 0\\n    while j > 0:\\n        q = max(d[j], q)\\n        j -= j & -j\\n    q += v\\n    while i < len(d):\\n        d[i] = max(d[i], q)\\n        i += i & -i\\nprint(max(d) * 3.14159265)\", \"from sys import *\\nt = list(map(int, stdin.read().split()))\\np = [t[i + 1] * t[i] ** 2 for i in range(1, len(t), 2)]\\nk = {v: j for j, v in enumerate(sorted(set(p)))}\\nd = [0] * (len(k) + 1)\\nfor v in p: \\n    j = k[v]\\n    i = j + 1\\n    q = 0\\n    while j > 0:\\n        q = max(d[j], q)\\n        j -= j & -j\\n    q += v\\n    while i < len(d):\\n        d[i] = max(d[i], q)\\n        i += i & -i\\nprint(max(d) * 3.14159265)\\n\", \"from sys import *\\nt = list(map(int, stdin.read().split()))\\np = [t[i + 1] * t[i] ** 2 for i in range(1, len(t), 2)]\\nk = {v: j for j, v in enumerate(sorted(set(p)))}\\nd = [0] * (len(k) + 1)\\nfor v in p: \\n    j = k[v]\\n    i = j + 1\\n    q = 0\\n    while j > 0:\\n        q = max(d[j], q)\\n        j -= j & -j\\n    q += v\\n    while i < len(d):\\n        d[i] = max(d[i], q)\\n        i += i & -i\\nprint(max(d) * 3.14159265)\\n\", \"from math import pi\\nn = int(input())\\nsecuencia = [None] * n\\nmaximo_to = -1\\nfor num in range(n):\\n    r, h = (int(x) for x in input().strip().split())\\n    secuencia[num] = [r * r * h, num + 1]\\nsecuencia.reverse()\\nsecuencia.sort(key=lambda x: x[0])\\nactual = 0\\nbit = [0] * (n + 1)\\n\\ndef max_x(x, l):\\n    suma = 0\\n    while x != 0:\\n        suma = max(suma, l[x])\\n        x -= (x & -x)\\n    return suma\\n\\ndef update_x(x, l, max_n, val):\\n    while x <= max_n:\\n        if val > l[x]:\\n            l[x] = val\\n        else:\\n            return\\n        x += (x & -x)\\nfor e in range(n):\\n    maximo = secuencia[e][0] + max_x(secuencia[e][1] - 1, bit)\\n    update_x(secuencia[e][1], bit, n, maximo)\\n    if maximo > maximo_to:\\n        maximo_to = maximo\\nprint(maximo_to * pi)\"]",
        "difficulty": "interview",
        "input": "1\n1 1\n",
        "output": "3.141592654\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/629/D"
    },
    {
        "id": 1071,
        "task_id": 275,
        "test_case_id": 1,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1000\n111\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1072,
        "task_id": 275,
        "test_case_id": 2,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "00100\n11\n",
        "output": "=\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1073,
        "task_id": 275,
        "test_case_id": 5,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1\n10\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1074,
        "task_id": 275,
        "test_case_id": 8,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "00\n1\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1075,
        "task_id": 275,
        "test_case_id": 9,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "01\n010\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1076,
        "task_id": 275,
        "test_case_id": 10,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "111\n00\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1077,
        "task_id": 275,
        "test_case_id": 11,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1100\n11\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1078,
        "task_id": 275,
        "test_case_id": 12,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "0110\n001\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1079,
        "task_id": 275,
        "test_case_id": 14,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "01010\n0011\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1080,
        "task_id": 275,
        "test_case_id": 19,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "11111001000\n1011100100\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1081,
        "task_id": 275,
        "test_case_id": 20,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1001111010001100001010001010010010100010100011101101110011110101011000010111101100111000110110110010\n01111001101111100111111001110110100101001111010001000000001001001111100101101100001101111111100111101\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1082,
        "task_id": 275,
        "test_case_id": 21,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n0\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1083,
        "task_id": 275,
        "test_case_id": 22,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1084,
        "task_id": 275,
        "test_case_id": 23,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1\n100000000000000000000000000000000000000000000000000\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1085,
        "task_id": 275,
        "test_case_id": 24,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1086,
        "task_id": 275,
        "test_case_id": 25,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "11111111111111111111111111111111111111111111111111111111111111111111111111111111\n1111111111111111111111111111111111111111111111111111111111111111111111111111111\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1087,
        "task_id": 275,
        "test_case_id": 26,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n100000000000000000000\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1088,
        "task_id": 275,
        "test_case_id": 28,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1089,
        "task_id": 275,
        "test_case_id": 30,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1090,
        "task_id": 275,
        "test_case_id": 31,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n0\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1091,
        "task_id": 275,
        "test_case_id": 32,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n1110\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1092,
        "task_id": 275,
        "test_case_id": 33,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n1000\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1093,
        "task_id": 275,
        "test_case_id": 34,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n1000\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1094,
        "task_id": 275,
        "test_case_id": 35,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1095,
        "task_id": 275,
        "test_case_id": 36,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n0\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1096,
        "task_id": 275,
        "test_case_id": 37,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n10000\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1097,
        "task_id": 275,
        "test_case_id": 38,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "10000100001000010000100001000010000100001000010000\n1\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1098,
        "task_id": 275,
        "test_case_id": 39,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "101001010101010101010100101010101010101010101001010101010100101010101010100101101010100101010100101010101001010101010101010100101010101010101010101001010101010100101010101010100101101010100101010100101010101001010101010101010100101010101010101010101001010101010100101010101010100101101010100101010100101010\n1\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1099,
        "task_id": 275,
        "test_case_id": 42,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n0000001010101011\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1100,
        "task_id": 275,
        "test_case_id": 43,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "110010010101001001001010100100010101010101011111111111111010101000000000000000000010110111111110101010111111111111111111111111111111111\n1011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1101,
        "task_id": 275,
        "test_case_id": 45,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1111111111111111111111111111111111111111111111111\n0\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1102,
        "task_id": 275,
        "test_case_id": 46,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1100100101010010010010101001000101010101010111111111111110101010000000000000000000101101111111101010101111111111111111111111111111111\n1011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1103,
        "task_id": 275,
        "test_case_id": 47,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n100000000000000000000\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1104,
        "task_id": 275,
        "test_case_id": 48,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "100001000010000100001000010000100001000010000100001111111111111111111111111111111111111111111111111111111111111111111111\n1\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1105,
        "task_id": 275,
        "test_case_id": 49,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "11111111111111111111111111111111111111111111111111111111111111\n1\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1106,
        "task_id": 275,
        "test_case_id": 55,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1107,
        "task_id": 275,
        "test_case_id": 56,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "101010101010101010101010101010101010101010101010101010101010101010101010\n1000000000000000000000000000000000000000000000000000000000000000000000000\n",
        "output": "<\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1108,
        "task_id": 275,
        "test_case_id": 57,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n0\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1109,
        "task_id": 275,
        "test_case_id": 58,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "111\n1000\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1110,
        "task_id": 275,
        "test_case_id": 59,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "1000000000000000000000000000000000000000000000000\n000\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1111,
        "task_id": 275,
        "test_case_id": 60,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n10\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1112,
        "task_id": 275,
        "test_case_id": 61,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "111111111111111111111111111111111111111111111111\n11\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1113,
        "task_id": 275,
        "test_case_id": 62,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n000\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1114,
        "task_id": 275,
        "test_case_id": 63,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1115,
        "task_id": 275,
        "test_case_id": 64,
        "question": "Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number $q = \\frac{\\sqrt{5} + 1}{2}$, in particular that q^2 = q + 1, and she thinks it would make a good base for her new unique system. She called it \"golden system\". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expression a_0a_1...a_{n} equals to $\\sum_{i = 0}^{n} a_{i} \\cdot q^{n - i}$.\n\nSoon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.\n\nGiven two numbers written in golden system notation, determine which of them has larger decimal value.\n\n\n-----Input-----\n\nInput consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.\n\n\n-----Output-----\n\nPrint \">\" if the first number is larger, \"<\" if it is smaller and \"=\" if they are equal.\n\n\n-----Examples-----\nInput\n1000\n111\n\nOutput\n<\n\nInput\n00100\n11\n\nOutput\n=\n\nInput\n110\n101\n\nOutput\n>\n\n\n\n-----Note-----\n\nIn the first example first number equals to $((\\sqrt{5} + 1) / 2)^{3} \\approx 1.618033988^{3} \\approx 4.236$, while second number is approximately 1.618033988^2 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.\n\nIn the second example numbers are equal. Each of them is  ≈ 2.618.",
        "solutions": "[\"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"from itertools import dropwhile, chain\\n\\n\\ndef main():\\n    zeroes = lambda a: not a\\n    a, b = [list(chain([0, 0], dropwhile(zeroes, list(map(int, input())))))\\n            for _ in range(2)]\\n\\n    def tofib(l):\\n        i = 0\\n        while i < len(l) - 1:\\n            if l[i] > 0 and l[i + 1] > 0:\\n                l[i] -= 1\\n                l[i + 1] -= 1\\n                l[i - 1] += 1\\n                i -= 3\\n            i += 1\\n        return l\\n\\n    a = list(dropwhile(zeroes, tofib(a)))\\n    b = list(dropwhile(zeroes, tofib(b)))\\n\\n    if len(a) < len(b):\\n        print('<')\\n        return\\n    if len(a) > len(b):\\n        print('>')\\n        return\\n    for i in range(len(a)):\\n        if a[i] < b[i]:\\n            print('<')\\n            return\\n        if a[i] > b[i]:\\n            print('>')\\n            return\\n    print('=')\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"u = v = 0\\na, b = input(), input()\\nn, m = len(a), len(b)\\nif n > m: b = '0' * (n - m) + b\\nelse: a = '0' * (m - n) + a\\nfor i in range(max(n, m)):\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n    if u > 1:\\n        print('>')\\n        return\\n    elif u < -1:\\n        print('<')\\n        return\\nd = 2 * v + u\\nif u == v == 0: print('=')\\nelif u >= 0 and d >= 0: print('>')\\nelif u <= 0 and d <= 0: print('<')\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\", \"u = v = 0\\n\\na, b = input(), input()\\n\\nn, m = len(a), len(b)\\n\\nif n > m: b = '0' * (n - m) + b\\n\\nelse: a = '0' * (m - n) + a\\n\\nfor i in range(max(n, m)):\\n\\n    u, v = v + u, u + int(a[i]) - int(b[i])\\n\\n    if u > 1:\\n\\n        print('>')\\n\\n        return\\n\\n    elif u < -1:\\n\\n        print('<')\\n\\n        return\\n\\nd = 2 * v + u\\n\\nif u == v == 0: print('=')\\n\\nelif u >= 0 and d >= 0: print('>')\\n\\nelif u <= 0 and d <= 0: print('<')\\n\\nelse: print('>' if (u * u > v * (v + u)) ^ (u < 0) else '<')\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"from sys import stdin\\ns=list(stdin.readline().strip()[::-1])\\ns1=list(stdin.readline().strip()[::-1])\\ndef trans(s):\\n    s.append(\\\"0\\\")\\n    i=len(s)-1\\n    while i>1:\\n        while i>=len(s):\\n            s.append(\\\"0\\\")\\n        if s[i-1]==\\\"1\\\" and s[i-2]==\\\"1\\\":\\n            s[i]=\\\"1\\\"\\n            s[i-1]=\\\"0\\\"\\n            s[i-2]=\\\"0\\\"\\n            i+=2\\n        else:\\n            i-=1\\n    while len(s)>0 and s[-1]==\\\"0\\\":\\n        s.pop()\\n    return s\\ns=trans(s)\\ns1=trans(s1)\\nfor i in range(min(len(s),len(s1))):\\n    if s[i]==s1[i]:\\n        s[i]=\\\"0\\\"\\n        s1[i]=\\\"0\\\"\\nwhile len(s)>0 and s[-1]==\\\"0\\\":\\n    s.pop()\\nwhile len(s1)>0 and s1[-1]==\\\"0\\\":\\n    s1.pop()\\nif len(s)==len(s1):\\n    print(\\\"=\\\")\\nelif(len(s)>len(s1)):\\n    print(\\\">\\\")\\nelse:\\n    print(\\\"<\\\")\\n\", \"def clean(d):\\n    ans = ['0']\\n    for c in list(d):\\n        ans.append(c)\\n        i = len(ans) - 1 #find last index\\n        while i > 1 and ans[i-2]== '0' and ans[i - 1] == '1' and ans[i] == '1':\\n            ans[i - 2] = '1'\\n            ans[i - 1] = '0'\\n            ans[i] = '0'\\n            i -= 2\\n    return ''.join(ans).lstrip('0')\\n\\na = clean(input())\\nb = clean(input())\\n#print(a)\\n#print(b)\\nif a == b:\\n    print('=')\\nelif len(a) > len(b):\\n    print('>')\\nelif len(a) < len(b):\\n    print('<')\\nelif a > b: # now the length are equal\\n    print('>')\\nelse:\\n    print('<')\\n\"]",
        "difficulty": "interview",
        "input": "100000000000000000000000000000000000000000000000\n0\n",
        "output": ">\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/457/A"
    },
    {
        "id": 1116,
        "task_id": 289,
        "test_case_id": 1,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VK\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1117,
        "task_id": 289,
        "test_case_id": 2,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VV\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1118,
        "task_id": 289,
        "test_case_id": 5,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KVKV\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1119,
        "task_id": 289,
        "test_case_id": 7,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VKVVKVKVVKVKKKKVVVVVVVVKVKVVVVVVKKVKKVKVVKVKKVVVVKV\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1120,
        "task_id": 289,
        "test_case_id": 10,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KVVVVVKKVKVVKVVVKVVVKKKVKKKVVKVKKKVKKKKVKVVVVVKKKVVVVKKVVVVKKKVKVVVVVVVKKVKVKKKVVKVVVKVVKK\n",
        "output": "21\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1121,
        "task_id": 289,
        "test_case_id": 14,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KVKVKVKVKVKVKVKVKVKVVKVKVKVKVKVKVKVVKVKVKKVKVKVKVKVVKVKVKVKVKVKVKVKVKKVKVKVV\n",
        "output": "35\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1122,
        "task_id": 289,
        "test_case_id": 16,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKKKVKKVKVKVKKKVVVVKK\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1123,
        "task_id": 289,
        "test_case_id": 17,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KVKVKKVVVVVVKKKVKKKKVVVVKVKKVKVVK\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1124,
        "task_id": 289,
        "test_case_id": 18,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKVKKVKKKVKKKVKKKVKVVVKKVVVVKKKVKKVVKVKKVKVKVKVVVKKKVKKKKKVVKVVKVVVKKVVKVVKKKKKVK\n",
        "output": "22\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1125,
        "task_id": 289,
        "test_case_id": 19,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVVKVKVKVVVVVKVVVKKVVVKVVVVVKKVVKVVVKVVVKVKKKVVKVVVVVKVVVVKKVVKVKKVVKKKVKVVKVKKKKVVKVVVKKKVKVKKKKKK\n",
        "output": "25\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1126,
        "task_id": 289,
        "test_case_id": 21,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKVKVVVKKVV\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1127,
        "task_id": 289,
        "test_case_id": 22,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VKVKVKVKVKVKVKVKVKVKVVKVKVKVKVKVK\n",
        "output": "16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1128,
        "task_id": 289,
        "test_case_id": 23,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVKKKVVKKKVVKKKVVKKKVVKKKVVKKKVVKKKVVKKKVVKKKVVKKKVVKKKVVKKKVV\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1129,
        "task_id": 289,
        "test_case_id": 25,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVKVKKVVKKVVKKVVKKVVKKVKKVVKVKKVVKKVVKKVVKKVVKKVVKVVKKVVKVVKKVVKVVKKVVKKVKKVVKVVKKVVKVVKKVV\n",
        "output": "26\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1130,
        "task_id": 289,
        "test_case_id": 27,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VKVK\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1131,
        "task_id": 289,
        "test_case_id": 29,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KV\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1132,
        "task_id": 289,
        "test_case_id": 30,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KK\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1133,
        "task_id": 289,
        "test_case_id": 31,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKVK\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1134,
        "task_id": 289,
        "test_case_id": 32,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKKK\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1135,
        "task_id": 289,
        "test_case_id": 34,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKVKVK\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1136,
        "task_id": 289,
        "test_case_id": 35,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VKKVK\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1137,
        "task_id": 289,
        "test_case_id": 37,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKK\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1138,
        "task_id": 289,
        "test_case_id": 38,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KVV\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1139,
        "task_id": 289,
        "test_case_id": 41,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVVKVKVKVKVKVKVK\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1140,
        "task_id": 289,
        "test_case_id": 42,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KVVVK\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1141,
        "task_id": 289,
        "test_case_id": 43,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVVKK\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1142,
        "task_id": 289,
        "test_case_id": 44,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKVV\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1143,
        "task_id": 289,
        "test_case_id": 45,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKKKKKK\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1144,
        "task_id": 289,
        "test_case_id": 47,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKVVV\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1145,
        "task_id": 289,
        "test_case_id": 48,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVVVVV\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1146,
        "task_id": 289,
        "test_case_id": 50,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVKVV\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1147,
        "task_id": 289,
        "test_case_id": 52,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VKKV\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1148,
        "task_id": 289,
        "test_case_id": 54,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVKKVV\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1149,
        "task_id": 289,
        "test_case_id": 56,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KKKKK\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1150,
        "task_id": 289,
        "test_case_id": 60,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVV\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1151,
        "task_id": 289,
        "test_case_id": 61,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1152,
        "task_id": 289,
        "test_case_id": 62,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "VVKKKKKKVKK\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1153,
        "task_id": 289,
        "test_case_id": 63,
        "question": "Tonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times \"VK\" can appear as a substring (i. e. a letter \"K\" right after a letter \"V\") in the resulting string.\n\n\n-----Input-----\n\nThe first line will contain a string s consisting only of uppercase English letters \"V\" and \"K\" with length not less than 1 and not greater than 100.\n\n\n-----Output-----\n\nOutput a single integer, the maximum number of times \"VK\" can appear as a substring of the given string after changing at most one character.\n\n\n-----Examples-----\nInput\nVK\n\nOutput\n1\n\nInput\nVV\n\nOutput\n1\n\nInput\nV\n\nOutput\n0\n\nInput\nVKKKKKKKKKVVVVVVVVVK\n\nOutput\n3\n\nInput\nKVKV\n\nOutput\n1\n\n\n\n-----Note-----\n\nFor the first case, we do not change any letters. \"VK\" appears once, which is the maximum number of times it could appear.\n\nFor the second case, we can change the second character from a \"V\" to a \"K\". This will give us the string \"VK\". This has one occurrence of the string \"VK\" as a substring.\n\nFor the fourth case, we can change the fourth character from a \"K\" to a \"V\". This will give us the string \"VKKVKKKKKKVVVVVVVVVK\". This has three occurrences of the string \"VK\" as a substring. We can check no other moves can give us strictly more occurrences.",
        "solutions": "[\"s = input()\\nd = dict()\\nd['V'] = 'K'\\nd['K'] = 'V'\\nm = s.count('VK')\\ns = list(s)\\nfor i in range(len(s)):\\n    s[i] = d[s[i]]\\n    m = max(m,''.join(s).count('VK'))\\n    s[i] = d[s[i]]\\nprint(m)\", \"def alternate(c):\\n    if c == \\\"V\\\":\\n        return \\\"K\\\"\\n    return \\\"V\\\"\\n\\ns = input()\\nres = s.count(\\\"VK\\\")\\nfor i in range(len(s)):\\n    res = max(res, (s[:i]+alternate(s[i])+s[i+1:]).count(\\\"VK\\\"))\\nprint(res)\", \"import re\\ndef count(s):\\n    return len(re.findall(r'VK', s))\\n\\ns = input().strip()\\nbest = count(s)\\nfor i in range(len(s)):\\n    cur_s = s[:i] + 'V' + s[i + 1:]\\n    best = max(best, count(cur_s))\\n    cur_s = s[:i] + 'K' + s[i + 1:]\\n    best = max(best, count(cur_s))\\nprint(best)\\n\", \"s=str(input())\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    if s[i]=='V':\\n        t='K'\\n    else:\\n        t='V'\\n    temp=s[:i]+t+s[i+1:]\\n    #print(temp)\\n    if temp.count('VK')>m:\\n        m=temp.count('VK')\\nprint(m)\\n\", \"'''input\\nKKKKKKV\\n'''\\ns = input().replace(\\\"VK\\\", \\\".\\\")\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n\\tprint(s.count(\\\".\\\") + 1)\\nelse:\\n\\tprint(s.count(\\\".\\\"))\", \"#!/usr/bin/env python3\\nimport re\\n\\n\\ndef solve():\\n    s = input()\\n    m = 0\\n    for i in range(len(s)):\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"V\\\"+s[i+1:])))\\n        m = max(m, len(re.findall(\\\"VK\\\", s[:i]+\\\"K\\\"+s[i+1:])))\\n    print(m)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"def get(s):\\n    res = 0\\n    for i in range(len(s) - 1):\\n        if s[i] == 'V' and s[i + 1] == 'K':\\n            res += 1\\n            \\n    return res\\n\\n\\ns = input()\\nl = list(s)\\n\\nans = 0\\nfor i in range(len(l)):\\n    st = l[i]\\n    \\n    l[i] = 'V'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = 'K'\\n    ans = max(ans, get(''.join(l)))\\n    \\n    l[i] = st\\n    \\nprint(ans)\", \"s = input()\\nmaxx = 0\\nfor i in range(len(s)):\\n    news = s[:i] + 'V' + s[i+1:]\\n    maxx = max(news.count('VK'), maxx)\\n    news = s[:i] + 'K' + s[i + 1:]\\n    maxx = max(news.count('VK'), maxx)\\nprint(maxx)\\n\", \"s=input()\\nif len(s)==1:\\n    print(0)\\nelse:\\n    x=s.count('VK')\\n    for i in range(len(s)):\\n        if s[i]=='K':\\n            if i<len(s)-1 and s[i+1]=='K' and (i==0 or s[i-1]=='K'):\\n                x+=1\\n                break\\n        elif i>0 and s[i-1]=='V' and (i==len(s)-1 or s[i+1]=='V'):\\n            x+=1\\n            break\\n    print(x)\\n\", \"s = input().strip()\\ns = s.replace(\\\"VK\\\", \\\"*\\\")\\ncnt = sum(map(lambda x: x==\\\"*\\\",s))\\nif \\\"VV\\\" in s or \\\"KK\\\" in s:\\n  cnt +=1\\nprint(cnt)  \", \"s=input()\\nm=s.count('VK')\\nfor i in range(len(s)):\\n    s2=s[:i]+'V'+s[i+1:]\\n    s3=s[:i]+'K'+s[i+1:]\\n    m=max(m,s2.count('VK'))\\n    m=max(m,s3.count('VK'))\\n    #print(s2,s3)\\nprint(m)\", \"l=input()\\ns=[]\\nfor i in l:\\n\\tif(i=='V'):\\n\\t\\ts.append(1)\\n\\telse:\\n\\t\\ts.append(0)\\nls=len(s)\\ni=0\\nmaxc = 0\\nc = 0\\nwhile i+1<ls:\\n\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\tc+=1\\n\\ti+=1\\nmaxc = max(maxc,c)\\nj=0\\nwhile j<ls:\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\ti=0\\n\\tc=0\\n\\twhile i+1<ls:\\n\\t\\tif(s[i]==1 and s[i+1]==0):\\n\\t\\t\\tc+=1\\n\\t\\ti+=1\\n\\tmaxc=max(c,maxc)\\n\\tif(s[j]==1):\\n\\t\\ts[j]=0\\n\\telse:\\n\\t\\ts[j]=1\\n\\tj+=1\\nprint(maxc)\", \"import sys\\n\\ndef solve():\\n    s = [ch for ch in input()]\\n    ans = ''.join(s).count('VK')\\n\\n    for i in range(len(s)):\\n        if s[i] == 'V':\\n            s[i] = 'K'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'V'\\n        else:\\n            s[i] = 'V'\\n\\n            tmp = ''.join(s).count('VK')\\n            ans = max(ans, tmp)\\n\\n            s[i] = 'K'\\n\\n    print(ans)\\n\\ndef debug(x, table):\\n    for name, val in table.items():\\n        if x is val:\\n            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)\\n            return None\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"def main():\\n    s = input()\\n    c = s.count('VK')\\n    if s.find('VVV') >= 0 or s.find('KKK') >= 0 or s[:2] == 'KK' or s[-2:] == 'VV':\\n        c += 1\\n    print(c)\\nmain()\", \"s=input()\\na=s.count(\\\"VK\\\")\\ns=s.replace(\\\"VK\\\",\\\" \\\")\\na+=1 if \\\"VV\\\" in s or \\\"KK\\\" in s else 0\\nprint(a)\\n\", \"x=input()\\nt=x.count(\\\"VK\\\")\\nl=x.replace(\\\"VK\\\",\\\" \\\")\\nif \\\"KK\\\" in l:\\n    t+=1\\n    print(t)\\nelif \\\"VV\\\" in l:\\n    t+=1\\n    print(t)\\nelse:\\n    print(t)\", \"from sys import stdin, stdout\\n\\na = stdin.readline().rstrip()\\na=list(a)\\n\\nvkCount=0\\nchange=False\\nif a[0:2]==list('KK'):\\n    change=True\\n    a[0]='V'\\nelif a[-2:]==list('VV'):\\n    change=True\\n    a[-1]='K'\\n\\ni=0\\nwhile i<len(a)-2 and not change:\\n    if a[i:i+3]==list('VVV'):\\n        a[i+1]='K'\\n        change=True\\n    elif a[i:i+3]==list('KKK'):\\n        a[i+1]='V'\\n        change=True\\n    i+=1\\n        \\nfor i in range(len(a)-1):\\n    if a[i:i+2]==list('VK'):\\n        vkCount+=1\\n\\nprint(vkCount)\\n\", \"import sys\\n\\ndef main():\\n    s=sys.stdin.readline().rstrip()\\n    result=0\\n    \\n    for i in range(len(s)-1):\\n        if s[i:i+2]=='VK': result+=1\\n    \\n    if s.startswith('KK') or s.endswith('VV') or 'VKKK' in s or 'VVV' in s: result+=1\\n    \\n    sys.stdout.write(str(result)+'\\\\n')\\n    \\nmain()\\n\\n\", \"s = input()\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'V' and s[i + 1] == 'K':\\n        k += 1\\nfor i in range(len(s)):\\n    if i < len(s) - 1:\\n        if s[i] == 'V' and s[i + 1] == 'V' and i + 2 == len(s):\\n            k += 1\\n            break\\n        if s[i] == 'V' and s[i + 1] == 'V' and s[i + 2] == 'V':\\n            k += 1\\n            break\\n    if i >= 1:\\n        if i == 1 and s[1] == 'K' and s[0] == 'K':\\n            k += 1\\n            break\\n        if s[i] == 'K' and s[i- 1] == 'K' and s[i - 2] == 'K':\\n            k += 1\\n            break\\nprint(k)\", \"s=list(input())\\nans=0\\nn=len(s)\\nfor i in range(n-1):\\n    if s[i]=='V' and s[i+1]=='K': ans+=1\\nfor t in range(len(s)):\\n    anst=0\\n    ss=s[:]\\n    if ss[t]=='V': ss[t]='K'\\n    else: ss[t]='V'\\n    for i in range(n-1):\\n        if ss[i]=='V' and ss[i+1]=='K': anst+=1\\n    if anst>ans: ans=anst\\nprint(ans)\", \"import sys\\nimport math\\ns = input()\\ncnt = s.count(\\\"VK\\\");\\nif s[:2] == \\\"KK\\\":\\n    cnt += 1\\nelif s[-2:] == 'VV':\\n    cnt += 1\\nelif s.find(\\\"VVV\\\") >= 0:\\n    cnt += 1\\nelif s.find(\\\"KKK\\\") >= 0:\\n    cnt += 1\\nprint(cnt)\", \"#l=[int(i)for i in input().split()]\\ns=input()\\ni=0\\na=s.find(\\\"VK\\\")\\nans=0\\nwhile a!=-1:\\n\\tans+=1\\n\\ts=s[:a]+\\\".\\\"+s[a+2:]\\n\\ta=s.find(\\\"VK\\\")\\nif s.count(\\\"VV\\\")>0 or s.count(\\\"KK\\\")>0:ans+=1\\nprint(ans) \", \"def f(S):\\n    ans = 0\\n    for i in range(1, len(S)):\\n        if S[i - 1] == \\\"V\\\" and S[i] == \\\"K\\\":\\n            ans += 1\\n    return ans\\n\\nS = list(input())\\nans = f(S)\\nD = {\\\"V\\\" : \\\"K\\\", \\\"K\\\" : \\\"V\\\"}\\nfor i in range(len(S)):\\n    S[i] = D[S[i]]\\n    ans = max(ans, f(S))\\n    S[i] = D[S[i]]\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom sys import stdin,stdout\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\ns = input()\\nl = len(s)\\nv = [0 for i in range(l)]\\n\\nif l == 1:\\n    print(0)\\n    return\\n\\n\\ncount = 0\\nfor i in range(l-1):\\n    if v[i]:\\n        continue\\n    if s[i:i+2] == \\\"VK\\\":\\n        v[i] = 1\\n        v[i+1] = 1\\n        count += 1\\n\\nfor i in range(l-1):\\n    if v[i] or v[i+1]:\\n        continue\\n\\n    if s[i:i+2] == \\\"VV\\\" or s[i:i+2] == \\\"KK\\\":\\n        count += 1\\n        break\\n\\nprint(count)\\n\\n\", \"s=list(' '+input())\\nm=0\\nfor i in range(len(s)):\\n    ss=[]\\n    for i0 in range(len(s)):\\n        ss.append(s[i0])\\n    if ss[i]=='V':\\n        ss[i]='K'\\n    elif ss[i]=='K':\\n        ss[i]='V'\\n    mm=0\\n    for i0 in range(len(s)-1):\\n        if ss[i0]=='V'and ss[i0+1]=='K':\\n            mm=mm+1\\n    if mm>m:\\n        m=mm\\nprint(m)\\n\"]",
        "difficulty": "interview",
        "input": "KVKVKVV\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/801/A"
    },
    {
        "id": 1154,
        "task_id": 329,
        "test_case_id": 1,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nniinneetteeeenn\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1155,
        "task_id": 329,
        "test_case_id": 2,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1156,
        "task_id": 329,
        "test_case_id": 3,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nineteenineteen\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1157,
        "task_id": 329,
        "test_case_id": 5,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "eehihnttehtherjsihihnrhimihrjinjiehmtjimnrss\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1158,
        "task_id": 329,
        "test_case_id": 6,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "rrrteiehtesisntnjirtitijnjjjthrsmhtneirjimniemmnrhirssjnhetmnmjejjnjjritjttnnrhnjs\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1159,
        "task_id": 329,
        "test_case_id": 7,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "mmrehtretseihsrjmtsenemniehssnisijmsnntesismmtmthnsieijjjnsnhisi\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1160,
        "task_id": 329,
        "test_case_id": 8,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "hshretttnntmmiertrrnjihnrmshnthirnnirrheinnnrjiirshthsrsijtrrtrmnjrrjnresnintnmtrhsnjrinsseimn\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1161,
        "task_id": 329,
        "test_case_id": 9,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "snmmensntritetnmmmerhhrmhnehehtesmhthseemjhmnrti\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1162,
        "task_id": 329,
        "test_case_id": 12,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "rhtsnmnesieernhstjnmmirthhieejsjttsiierhihhrrijhrrnejsjer\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1163,
        "task_id": 329,
        "test_case_id": 13,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "emmtjsjhretehmiiiestmtmnmissjrstnsnjmhimjmststsitemtttjrnhsrmsenjtjim\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1164,
        "task_id": 329,
        "test_case_id": 14,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nmehhjrhirniitshjtrrtitsjsntjhrstjehhhrrerhemehjeermhmhjejjesnhsiirheijjrnrjmminneeehtm\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1165,
        "task_id": 329,
        "test_case_id": 18,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "sithnrsnemhijsnjitmijjhejjrinejhjinhtisttteermrjjrtsirmessejireihjnnhhemiirmhhjeet\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1166,
        "task_id": 329,
        "test_case_id": 20,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "jsihrimrjnnmhttmrtrenetimemjnshnimeiitmnmjishjjneisesrjemeshjsijithtn\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1167,
        "task_id": 329,
        "test_case_id": 21,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "hhtjnnmsemermhhtsstejehsssmnesereehnnsnnremjmmieethmirjjhn\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1168,
        "task_id": 329,
        "test_case_id": 23,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "mtstiresrtmesritnjriirehtermtrtseirtjrhsejhhmnsineinsjsin\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1169,
        "task_id": 329,
        "test_case_id": 26,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "hntrteieimrimteemenserntrejhhmijmtjjhnsrsrmrnsjseihnjmehtthnnithirnhj\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1170,
        "task_id": 329,
        "test_case_id": 28,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "eihstiirnmteejeehimttrijittjsntjejmessstsemmtristjrhenithrrsssihnthheehhrnmimssjmejjreimjiemrmiis\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1171,
        "task_id": 329,
        "test_case_id": 29,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "srthnimimnemtnmhsjmmmjmmrsrisehjseinemienntetmitjtnnneseimhnrmiinsismhinjjnreehseh\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1172,
        "task_id": 329,
        "test_case_id": 30,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "etrsmrjehntjjimjnmsresjnrthjhehhtreiijjminnheeiinseenmmethiemmistsei\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1173,
        "task_id": 329,
        "test_case_id": 32,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "mehsmstmeejrhhsjihntjmrjrihssmtnensttmirtieehimj\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1174,
        "task_id": 329,
        "test_case_id": 34,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "rhsmrmesijmmsnsmmhertnrhsetmisshriirhetmjihsmiinimtrnitrseii\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1175,
        "task_id": 329,
        "test_case_id": 38,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "eehnshtiriejhiirntminrirnjihmrnittnmmnjejjhjtennremrnssnejtntrtsiejjijisermj\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1176,
        "task_id": 329,
        "test_case_id": 39,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "rnhmeesnhttrjintnhnrhristjrthhrmehrhjmjhjehmstrijemjmmistes\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1177,
        "task_id": 329,
        "test_case_id": 44,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteen\n",
        "output": "13",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1178,
        "task_id": 329,
        "test_case_id": 45,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "ninetee\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1179,
        "task_id": 329,
        "test_case_id": 49,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "zninetneeineteeniwnteeennieteenineteenineteenineteenineteenineteenineteenineteenineteeninetzeenz\n",
        "output": "13",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1180,
        "task_id": 329,
        "test_case_id": 50,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nnnnnnniiiiiiiiiiiitttttttttteeeeeeeeeeeeeeeeee\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1181,
        "task_id": 329,
        "test_case_id": 51,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "ttttiiiieeeeeeeeeeeennnnnnnnn\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1182,
        "task_id": 329,
        "test_case_id": 52,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "ttttttttteeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiinnnnnnn\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1183,
        "task_id": 329,
        "test_case_id": 54,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiittttttttttttttttnnnnnnn\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1184,
        "task_id": 329,
        "test_case_id": 56,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nineteeeeeeeeeeeeeeeeettttttttttttttttttiiiiiiiiiiiiiiiiii\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1185,
        "task_id": 329,
        "test_case_id": 57,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nineteenieteenieteenieteenieteenieteenieteen\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1186,
        "task_id": 329,
        "test_case_id": 58,
        "question": "Alice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\n\n\n-----Output-----\n\nPrint a single integer — the maximum number of \"nineteen\"s that she can get in her string.\n\n\n-----Examples-----\nInput\nnniinneetteeeenn\n\nOutput\n2\nInput\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\n2\nInput\nnineteenineteen\n\nOutput\n2",
        "solutions": "[\"t = {i: 0 for i in 'qwertyuiopasdfghjklzxcvbnm'}\\nfor i in input(): t[i] += 1\\nprint(min([t['i'], t['t'], t['e'] // 3, max(0, (t['n'] - 1)) // 2]))\", \"import fileinput\\n\\nfor line in fileinput.input():\\n    x = line\\n\\n\\ncountn = 0\\ncounti = 0\\ncounte = 0\\ncountt = 0\\n\\nfor i in range(len(x)):\\n    if x[i] == 'n':\\n        countn+=1\\n    if x[i] == 'i':\\n        counti+=1\\n    if x[i] == 'e':\\n        counte+=1\\n    if x[i] =='t':\\n        countt+=1\\n\\ncountn -= 3\\ncounti -= 1\\ncounte -= 3\\ncountt -= 1\\n\\ntotal = 0\\nif countn>=0 and counti >= 0 and counte >= 0 and countt >= 0:\\n    total +=1\\n\\nwhile countn-2>=0 and counti-1>=0 and counte-3 >= 0 and countt - 1 >= 0:\\n    countn-=2\\n    counti-=1\\n    counte-=3\\n    countt-=1\\n    total+=1\\n\\nprint(total)\", \"s = input()\\nne = s.count('e')//3\\nnn = (s.count('n')-1) // 2\\nni = s.count('i')\\nnt = s.count('t')\\nm = min(ne,nn,ni,nt)\\nif m < 0: m = 0\\nprint(m)\", \"J=str(input())\\nN=J.count('n')\\nI=J.count('i')\\nT=J.count('t')\\nE=J.count('e')\\nN=(N-1)//2\\nE=E//3\\nif N>0:\\n    M=min(N,I,T,E)\\nelse:\\n    M=0\\nprint(M)\", \"s = input().strip()\\nletters = [0] * 30\\nfor i in range(len(s)):\\n    letters[ord(s[i]) - ord('a')] += 1\\nans = min(letters[ord('i') - ord('a')], letters[ord('e') - ord('a')] // 3)\\nans = min(ans, letters[ord('t') - ord('a')])\\nans = min(ans, (letters[ord('n') - ord('a')] - 3) // 2 + 1)\\nprint(max(0, ans))\", \"s = input()\\na = [0] * 26\\nb = [0] * 26\\nfor c in \\\"nineteen\\\":\\n  a[ord(c) - ord(\\\"a\\\")] += 1\\nfor c in s:\\n  b[ord(c) - ord(\\\"a\\\")] += 1\\ns = 0\\nif all(y >= x for x, y in zip(a, b)):\\n  s += 1\\n  for i in range(26):\\n    b[i] -= a[i]\\n  a[ord(\\\"n\\\") - ord(\\\"a\\\")] -= 1\\n  s += min(y // x for x, y in zip(a, b) if x > 0)\\nprint(s)\", \"te = input()\\ne = 0; i = 0; n = 0; t = 0\\nfor j in te:\\n    if j == 'e':\\n        e += 1\\n    elif j == 'i':\\n        i += 1\\n    elif j == 'n':\\n        n += 1\\n    elif j == 't':\\n        t += 1\\nif n > 3:\\n    n = 1 +(n-3)//2\\nelse:\\n    n = n//3\\nprint(min(e//3, t, i, n))\\n\", \"s = input()\\nform = 'nineteen'\\nans = 0\\nflag = True\\nwhile True:\\n    for i in range(len(form)):\\n        if s.find(form[i]) == -1:\\n            flag = False\\n            break\\n        if i == len(form) - 1:\\n            ans += 1\\n        else:\\n            s = s[:s.find(form[i])] + s[s.find(form[i]) + 1:]\\n    if not flag:\\n        break\\nprint(ans)\", \"from collections import Counter\\ns,w = Counter(input()), Counter('nineteen')\\nf = lambda k,v: (s['n']-1)//2 if k == 'n' else s[k]//v\\nprint(max(0, min(f(k,v) for k,v in w.items())))\", \"st = input()\\na = {'n':0, 'i':0, 'e':0, 't':0}\\n# n*3131-(n-1)*1000 = 2n+1,n,3n,n\\nfor c in st:\\n    if c in a:\\n        a[c] += 1\\nprint(max(min([(a['n'] - 1) // 2, a['i'], a['e'] // 3, a['t']]), 0))\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"a = str(input())\\ni = [0]\\nn = [0]\\nt = [0]\\ne = [0]\\nfor x in a:\\n\\tx = str(x)\\n\\tif x == 'i':\\n\\t\\ti[0] += 1\\n\\tif x == 'n':\\n\\t\\tn[0] += 1\\n\\tif x == 't':\\n\\t\\tt[0] += 1\\n\\tif x == 'e':\\n\\t\\te[0] += 1\\ni_m = i[0]\\ne_m = e[0]//3\\nt_m = t[0]\\nn_m = 0\\nif n[0] >= 3:\\n\\tn[0] -=3\\n\\tn_m += 1\\n\\tn_m += n[0]//2 \\nprint(min(i_m, n_m, e_m, t_m))\\n\\n\\n# 1481305185129\\n\", \"x=input()\\na=x.count('n')\\nb=x.count('i')\\nc=x.count('e')\\nd=x.count('t')\\nif a>=5:\\n\\ta-=1\\n\\ta/=2\\nelse:\\n\\ta/=3\\nc/=3\\na=int(a)\\nc=int(c)\\ni=0\\nwhile a>0 and b>0 and c>0 and d>0:\\n\\ti+=1\\n\\ta-=1\\n\\tb-=1\\n\\tc-=1\\n\\td-=1\\nprint(i)\\n\\n# 1481311408782\\n\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\", \"string = input()\\n\\nn = string.count('n')\\ni = string.count('i')\\ne = string.count('e')\\nt = string.count('t')\\n\\nn-=1\\n\\nvn = n/2\\nve = e/3\\nvi = i\\nvt = t\\n\\n\\n#if vn>1:\\n#\\tvn+=(vn-1)\\n\\nans = max(0, min(vn, ve, vi, vt))\\n\\nans = int(ans)\\n\\nprint(ans)\\n# 1481824118256\\n\", \"s=input()\\nk=s\\nl=s\\nd=s\\nr=s\\nk=k.replace(\\\"n\\\",\\\"\\\")\\nl=l.replace(\\\"i\\\",\\\"\\\")\\nd=d.replace(\\\"t\\\",\\\"\\\")\\nr=r.replace(\\\"e\\\",\\\"\\\")\\nn,i,t,e=0,0,0,0\\nn=len(s)-len(k)\\ni=len(s)-len(l)\\nt=len(s)-len(d)\\ne=len(s)-len(r)\\nx=0\\nif n-3>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n    g=\\\"nineteen\\\"\\n    n-=3\\n    i-=1\\n    t-=1\\n    e-=3\\n    x+=1\\n    while n-2>=0 and i-1>=0 and t-1>=0 and e-3>=0:\\n        n-=2\\n        i-=1\\n        t-=1\\n        e-=3\\n        x+=1\\nprint(x)\\n\", \"import sys\\n\\nline = sys.stdin.readline()\\nword = line.split()[0]\\n\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor c in word:\\n    if c == 'n':\\n        n += 1\\n    elif c == 'i':\\n        i += 1\\n    elif c == 'e':\\n        e += 1\\n    elif c == 't':\\n        t += 1\\n\\nN = max(0, (n - 1) // 2)\\nI = i\\nE = max(0, e // 3)\\nT = t\\n\\nprint(min([N, I, E, T]))\\n\\n# 1502215214848\\n\", \"import math;\\n\\ns = input();\\nsize = len(s);\\nletters = [0, 0, 0, 0]\\nn = 0;\\ni = 0;\\ne = 0;\\nt = 0;\\n\\nfor x in range(0, size):\\n\\tif s[x] == \\\"n\\\":\\n\\t\\tn += 1;\\n\\telif s[x] == \\\"i\\\":\\n\\t\\ti += 1;\\n\\telif s[x] == \\\"e\\\":\\n\\t\\te += 1;\\n\\telif s[x] == \\\"t\\\":\\n\\t\\tt += 1;\\n\\t\\t\\nif (n == 3):\\n  n = 1;\\nelif (n < 3):\\n  n = 0;\\nelse:\\n  n -= 3;\\n  n = math.floor(n / 2);\\n  n += 1;\\n\\ne = math.floor(e / 3);\\n\\nletters[0] = n;\\nletters[1] = i;\\nletters[2] = e;\\nletters[3] = t;\\n\\nprint((min(letters)));\\n# 1502216507489\\n\", \"st = input()\\nn = 0\\ni = 0\\ne = 0\\nt = 0\\n\\nfor el in st:\\n\\tif el=='n':\\n\\t\\tn+=1\\n\\telif el=='i':\\n\\t\\ti+=1\\n\\telif el=='e':\\n\\t\\te+=1\\n\\telif el=='t':\\n\\t\\tt+=1\\n\\nif n==0 or n==1 or n==2:\\n\\trn = 0\\nelse:\\n\\trn = (n-1)//2\\nprint(min([rn, i//1, e//3, t//1]))\\n\\n# 1502217389696\\n\", \"def v_19(s):\\n    a = [0, 0, 0, 0]\\n    #    n  e  i  t\\n\\n    for i in range(len(s)):\\n        if s[i] == 'n':\\n            a[0] += 1\\n        elif s[i] == 'i':\\n            a[2] += 1\\n        elif s[i] == 'e':\\n            a[1] += 1\\n        elif s[i] == 't':\\n            a[3] += 1\\n\\n    return a\\n\\n\\ns = input()\\n\\nq = v_19(s)\\n\\nif q[0] < 5:\\n    q[0] = q[0] // 3\\nelse:\\n    q[0] = (q[0] - 1) // 2\\n\\nq[1] = q[1] // 3\\n\\nprint(min(q))\\n\\n# 1502218585911\\n\", \"s='n'+'ineteen'*100\\nx=input()\\nd={}\\nfor i in s:d[i]=x.count(i)\\nj=0\\nwhile d[s[j]]>0:d[s[j]]-=1;j+=1\\nprint(s[:j].count('ineteen'))\", \"def main(s):\\n    from collections import Counter\\n    count = Counter(s)\\n    n = {'n': 2, 'i': 1, 'e': 3, 't': 1}\\n    f = True\\n    x = \\\"\\\"\\n    for i in range(len(s)):\\n        for c in n:\\n            if count[c] < n[c]:\\n                f = False\\n                break\\n        if not f:\\n            break\\n        for c in n:\\n            count[c] -= n[c]\\n        x += \\\"ninetee\\\"\\n    if count['n'] > 0:\\n        x += \\\"n\\\"\\n    r = 0\\n    for i in range(0, len(x) + 2 , 7):\\n        if x[i:i+8] == 'nineteen':\\n            r += 1\\n    return r\\n        \\n\\nprint(main(list(input())))\\n\", \"s = input()\\nl = list(s)\\ncul = list(0 for i in range(30))\\nfor el in l :\\n        cul[ord(el) - 97] += 1\\nif cul[ord('n')-97] > 0:\\n        cul[ord('n')-97]-=1\\n\\n\\nprint(min(cul[ord('n')-97]//2 , min(cul[ord('e')-97]//3 , min(cul[ord('t')-97] , cul[ord('i')-97]))))\\n\", \"# python 3\\n\\\"\\\"\\\"\\nRead tutorial, graph the moves, still don't understand this problem\\n\\\"\\\"\\\"\\n\\n\\ndef nineteen(string_str) -> int:\\n    letter_count_dict = dict()\\n    for letter in string_str:\\n        if letter_count_dict.get(letter, 0) == 0:\\n            letter_count_dict[letter] = 1\\n        else:\\n            letter_count_dict[letter] += 1\\n    nineteen_count = 0\\n    while letter_count_dict.get('n', 0) >= 3 and letter_count_dict.get('i', 0) >= 1 and \\\\\\n            letter_count_dict.get('e', 0) >= 3 and letter_count_dict.get('t', 0) >= 1:\\n        letter_count_dict['n'] -= 2\\n        letter_count_dict['i'] -= 1\\n        letter_count_dict['e'] -= 3\\n        letter_count_dict['t'] -= 1\\n        nineteen_count += 1\\n    return nineteen_count\\n\\n\\ndef __starting_point():\\n    \\\"\\\"\\\"\\n    Inside of this is the test. \\n    Outside is the API\\n    \\\"\\\"\\\"\\n\\n    string = input()\\n\\n    print(nineteen(string))\\n\\n__starting_point()\", \"s = input().strip()\\nn = s.count('n')\\ne = s.count('e') // 3\\ni = s.count('i')\\nt = s.count('t')\\n\\n#print(n, e, s.count('e'), i, t)\\n\\ncount = min(e, i, t)\\nfor i in range(count, -1, -1):\\n    if (2 * i + 1) <= n:\\n        print(i)\\n        break\\n    elif 3 * i <= n:\\n        print(i)\\n        break\"]",
        "difficulty": "interview",
        "input": "nineteenineteenineteenineteenineteen\n",
        "output": "5",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/393/A"
    },
    {
        "id": 1187,
        "task_id": 434,
        "test_case_id": 1,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "9\n8 6 4 2 1 4 7 10 2\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1188,
        "task_id": 434,
        "test_case_id": 2,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "9\n-1 6 -1 2 -1 4 7 -1 2\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1189,
        "task_id": 434,
        "test_case_id": 4,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "7\n-1 -1 4 5 1 2 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1190,
        "task_id": 434,
        "test_case_id": 16,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "3\n-1 1000000000 999999999\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1191,
        "task_id": 434,
        "test_case_id": 20,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "5\n-1 1 7 -1 5\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1192,
        "task_id": 434,
        "test_case_id": 27,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "7\n32 33 34 -1 -1 37 38\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1193,
        "task_id": 434,
        "test_case_id": 33,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "7\n11 8 5 -1 -1 -1 -1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1194,
        "task_id": 434,
        "test_case_id": 38,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "12\n-1 17 -1 54 -1 64 -1 74 79 84 -1 94\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1195,
        "task_id": 434,
        "test_case_id": 40,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "14\n-1 5 3 -1 -1 31 31 31 -1 31 -1 -1 4 7\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1196,
        "task_id": 434,
        "test_case_id": 43,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "17\n-1 -1 -1 -1 64 68 72 -1 45 46 47 48 49 50 51 52 53\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1197,
        "task_id": 434,
        "test_case_id": 44,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "18\n21 19 -1 -1 -1 48 50 -1 54 -1 5 1 -1 -1 -1 37 36 35\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1198,
        "task_id": 434,
        "test_case_id": 46,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "6\n-1 2 6 -1 -1 6\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1199,
        "task_id": 434,
        "test_case_id": 47,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "8\n-1 -1 1 7 -1 9 5 2\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1200,
        "task_id": 434,
        "test_case_id": 48,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "20\n-1 32 37 -1 -1 -1 57 -1 -1 40 31 33 -1 -1 39 47 43 -1 35 32\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1201,
        "task_id": 434,
        "test_case_id": 49,
        "question": "Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions.\n\nPolycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another.\n\nUnfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1.\n\nFor a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions.\n\nLet us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} =  - 1).\n\n\n-----Output-----\n\nPrint the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers.\n\n\n-----Examples-----\nInput\n9\n8 6 4 2 1 4 7 10 2\n\nOutput\n3\n\nInput\n9\n-1 6 -1 2 -1 4 7 -1 2\n\nOutput\n3\n\nInput\n5\n-1 -1 -1 -1 -1\n\nOutput\n1\n\nInput\n7\n-1 -1 4 5 1 2 3\n\nOutput\n2",
        "solutions": "[\"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nif n <= 2:\\n  print(1)\\n  return\\n\\na = [int(s) for s in sys.stdin.readline().split()]\\n\\nst = -1 # index of first positive number in current subset of a\\ned = -1 # index last positive number in current subset of a \\n        # differation is (a[ed] - a[st])/(ed - st)\\nleading_zeros = 0 # -1 before a[st]\\nseg_count = 1\\n\\nfor (i, v) in enumerate(a):\\n  if v == -1:\\n    if st == -1:\\n      leading_zeros += 1\\n    else:\\n      if ed != -1:\\n        # check if v should be a non-positive number\\n        if a[ed] + (i-ed) * (a[ed] - a[st])/(ed-st) <= 0:\\n          st = -1\\n          ed = -1\\n          leading_zeros = 1\\n          seg_count += 1\\n        else:\\n          pass\\n      else:\\n        pass\\n  else:\\n    if st == -1:\\n      st = i # find first positive number\\n    else:\\n      if ed == -1:\\n        ed = i\\n        #print(i)\\n        if (v - a[st]) % (i-st) != 0 or a[st] - (v-a[st])/(i-st) * leading_zeros <= 0:\\n          # a[st..i] can't be an arithmetic progression\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i\\n      else:\\n        if (v-a[ed])%(i-ed) != 0 or (v-a[ed]) * (ed - st) != (a[ed] - a[st]) * (i-ed):\\n          st = i\\n          ed = -1\\n          seg_count += 1\\n          leading_zeros = 0\\n        else:\\n          ed = i #leave ed the first positive number after a[st] is also ok\\n  #print( \\\"[\\\" +str(st) + \\\" \\\" + str(ed) + \\\"] \\\" + str(seg_count) + \\\" \\\" + str(leading_zeros) )\\n\\nprint(seg_count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ni = 0\\nans = 0\\n\\nwhile i < n:\\n    ans += 1\\n    i1 = i\\n    while i1 < n and a[i1] == -1:\\n        i1 += 1\\n    if i1 == n:\\n        break\\n    i2 = i1 + 1\\n    while i2 < n and a[i2] == -1:\\n        i2 += 1\\n    if i2 == n:\\n        break\\n    dist = i2 - i1\\n    step = (a[i2] - a[i1]) // dist\\n    if (a[i2] - a[i1]) % dist != 0 or (step > 0 and a[i1] - (i1 - i) * step <= 0):\\n        i = i2\\n        continue\\n    i3 = i2 + 1\\n    while i3 < n:\\n        nxt = a[i2] + step * (i3 - i2)\\n        if nxt <= 0 or (a[i3] != -1 and a[i3] != nxt):\\n            break\\n        i3 += 1\\n        \\n    i = i3\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "13\n2 -1 3 1 3 1 -1 1 3 -1 -1 1 1\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/416/D"
    },
    {
        "id": 1202,
        "task_id": 438,
        "test_case_id": 1,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "5\n",
        "output": "2\n1 4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1203,
        "task_id": 438,
        "test_case_id": 3,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "2\n",
        "output": "1\n2 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1204,
        "task_id": 438,
        "test_case_id": 4,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "1\n",
        "output": "1\n1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1205,
        "task_id": 438,
        "test_case_id": 5,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "3\n",
        "output": "2\n1 2 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1206,
        "task_id": 438,
        "test_case_id": 9,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "7\n",
        "output": "3\n1 2 4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1207,
        "task_id": 438,
        "test_case_id": 12,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "11\n",
        "output": "4\n1 2 3 5 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1208,
        "task_id": 438,
        "test_case_id": 14,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "13\n",
        "output": "4\n1 2 3 7 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1209,
        "task_id": 438,
        "test_case_id": 23,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "29\n",
        "output": "7\n1 2 3 4 5 6 8 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1210,
        "task_id": 438,
        "test_case_id": 26,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "37\n",
        "output": "8\n1 2 3 4 5 6 7 9 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1211,
        "task_id": 438,
        "test_case_id": 33,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "239\n",
        "output": "21\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 29 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1212,
        "task_id": 438,
        "test_case_id": 36,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "631\n",
        "output": "35\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 36 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1213,
        "task_id": 438,
        "test_case_id": 39,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "947\n",
        "output": "43\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1214,
        "task_id": 438,
        "test_case_id": 42,
        "question": "Santa Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.\n\n\n-----Input-----\n\nThe only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.\n\n\n-----Output-----\n\nPrint to the first line integer number k — maximal number of kids which can get candies.\n\nPrint to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.\n\nIf there are many solutions, print any of them.\n\n\n-----Examples-----\nInput\n5\n\nOutput\n2\n2 3\n\nInput\n9\n\nOutput\n3\n3 5 1\n\nInput\n2\n\nOutput\n1\n2",
        "solutions": "[\"n = int(input())\\nans = []\\nnxt = 1\\nwhile n > 0:\\n  x = nxt\\n  n -= nxt\\n  nxt += 1\\n  if n < nxt:\\n    x += n\\n    n = 0\\n  ans.append(str(x))\\nprint(len(ans))\\nprint(\\\" \\\".join(ans))\\n\", \"n = int(input())\\ncur = 1\\nans = []\\nwhile n > cur:\\n    n -= cur\\n    ans.append(cur)\\n    cur += 1\\nif n < cur:\\n    ans[-1] += n\\nelse:\\n    ans.append(n)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input().strip())\\nk = int(((8 * n + 1) ** 0.5 - 1) // 2)\\ns = \\\"\\\"\\n\\na = []\\nfor i in range(k - 1):\\n    s += str(i + 1) + \\\" \\\"\\ns += str(n - (k * (k - 1)) // 2)\\n\\nprint(k)\\nprint(s)\\n\", \"n = int(input())\\nans = 0\\nL = []\\ni = 1\\nwhile i <= n:\\n    ans += 1\\n    L.append(i)\\n    n -= i\\n    i += 1\\nL[-1] += n\\nprint(ans)\\nprint(*L)\", \"n = int(input())\\nx = n\\ni = 1\\nwhile n >= i:\\n    n -= i\\n    i += 1\\nprint(i-1)\\nfor j in range(1,i):\\n    if j == i-1:\\n        print(x)\\n        break\\n    else:\\n        print(j,end= ' ')\\n        x -= j\", \"q=int(input())\\na=[1]\\nq-=1\\nl=1\\nwhile q>a[l-1]:\\n    q-=l+1\\n    a.append(l+1)\\n    l+=1\\na[l-1]+=q\\nprint(len(a))\\nfor i in a:\\n    print(i,end=' ')\\n\", \"n = int(input()) - 1\\nans = [1]\\nwhile n > ans[-1]:\\n    n -= ans[-1] + 1\\n    ans.append(ans[-1] + 1)\\nans[-1] += n\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\narr = []\\non = 1\\nwhile n>2*on:\\n  n-=on\\n  arr.append(on)\\n  on+=1\\narr.append(n)\\nprint(len(arr))\\nprint(' '.join(map(str,arr)))\", \"n = int(input())\\nk = int(-0.4999999 + (0.25 + 2*n)**0.5)\\nprint(k)\\nfor i in range(1,k):\\n    print(i, end = \\\" \\\")\\nprint(n - k*(k-1)//2)    \", \"n = int(input())\\ncur = 1\\nwhile(n>=cur):\\n    n-=cur\\n    cur+=1\\nprint(cur-1)\\nfor i in range(1,cur-1):\\n    print(i,end=' ')\\nprint(cur-1+n)\\n\\n\", \"#!/usr/bin/env python3\\n\\ndef main():\\n    try:\\n        while True:\\n            t = n = int(input())\\n            result = 0\\n            i = 1\\n            while n >= i:\\n                n -= i\\n                i += 1\\n                result += 1\\n            print(result)\\n            for i in range(1, result):\\n                print(i, end=' ')\\n            print(t - sum(range(result)))\\n\\n    except EOFError:\\n        pass\\n\\nmain()\\n\", \"n = int(input())\\nk = 0\\nsize = n\\nfor i in range(1,size+1):\\n\\tn -= i\\n\\tk += 1\\n\\tif n<=i: break\\n\\nprint(k)\\nL = size\\nfor i in range(1,L+1):\\n\\tif size-i<=i:\\n\\t\\tprint(size)\\n\\t\\tbreak\\n\\tprint(i, end=\\\" \\\")\\n\\tsize -= i\\n\\t\\n\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\\n\", \"from math import *\\ndef Main(n):\\n    sm = 0\\n    A = []\\n    for i in range(1,n + 1):\\n        sm += i\\n        A.append(i)\\n        if(sum(A) == n):\\n            break\\n        elif(sum(A) > n):\\n            break\\n    # print(A)\\n    rez = abs(n - sum(A))\\n\\n    if rez in A:\\n        value_index = A.index(rez)\\n        A.pop(value_index)\\n\\n    print(len(A))\\n    print(*A)\\n\\n\\n    # print(int(sqrt(n)))\\n    # if n%2 == 1:\\n    #     res = n//2\\n    #     print(res, end = \\\" \\\")\\n    #     for i in range(res - 1, 1, -1):\\n    #         print(i, end = ' ')\\n    #     print()\\n\\ndef __starting_point():\\n    n = int(input())\\n    Main(n)\\n__starting_point()\", \"candies = int(input())\\n\\ndef printCandies(touse):\\n    print(len(result))\\n    resultS = \\\"\\\"\\n    for child in touse:\\n        resultS += str(child) + \\\" \\\"\\n    print(resultS)\\n\\nif candies >= 1 and candies <= 1000:\\n    result = []\\n    for i in range(1, candies + 1):\\n        result.append(i)\\n        if sum([int(i) for i in result]) > candies:\\n            result = result[0:-1]\\n            break\\n    sumN = sum(result)\\n    if sumN == candies:\\n        printCandies(result)\\n    else:\\n        remain = candies - sum(result)\\n\\n        for i in range(remain, 0, -1):\\n            result[-1 - (i-1)] += 1\\n        \\n        printCandies(result)\\n        \\n\", \"max = -float('inf')\\ncur = []\\n\\ndef candies(n, arr):\\n\\tnonlocal cur, max\\n\\tif sum(arr) == n:\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\n\\t\\t\\tmax = len(arr)\\t\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0 \\n\\n\\tif sum(arr) > n:\\n\\t\\tarr.pop()\\n\\t\\tif len(arr) > max or (len(arr) == max and sum(arr) > sum(cur)):\\t\\t\\n\\t\\t\\tmax = len(arr)\\n\\t\\t\\tcur = arr[:]\\t\\t\\t\\t\\n\\t\\treturn 0\\n\\n\\tfor i in range(1, n+1):\\n\\t\\tif i not in arr:\\n\\t\\t\\tarr.append(i)\\t\\t\\t\\n\\t\\t\\tif candies(n, arr) == 0:\\t\\n\\t\\t\\t\\tbreak\\n\\t\\t\\tif i in arr: arr.remove(i);\\n\\t#print(cur)\\n\\treturn 1\\n\\t\\t\\n\\nn = int(input())\\n\\n\\ncandies(n, [])\\nprint(max)\\nfor each in cur:\\n\\tprint(each, end=\\\" \\\") \\n\\n\", \"n = int(input())\\nans = list()\\ni = 1\\nwhile 1:\\n\\tif n < i :\\n\\t\\tbreak\\n\\tn-=i \\n\\tans.append(i)\\n\\ti +=1\\nans[len(ans)-1] += n\\nprint(len(ans))\\nfor i in ans :\\n\\tprint(i,end=' ')\\n\", \"n = int(input())\\na = [0]\\n\\nwhile n > 2*(a[-1]+1):\\n\\tn -= a[-1]+1\\n\\ta.append(a[-1]+1)\\n\\nif n != 0:\\n\\ta.append(n)\\n\\na.remove(0)\\n\\nprint(len(a))\\nprint(*a)\", \"N = int(input())\\nM = 0\\nwhile (M + 1) * (M + 2) / 2 <= N :\\n\\tM += 1\\nprint(M)\\nfor i in range(1, M) :\\n\\tprint(i, end = ' ')\\n\\tN -= i\\nprint(N)\\t\\n\", \"n=int(input())\\ns=''\\ni=0\\nwhile True:\\n    i+=1\\n    n-=i\\n    if n>i:\\n        s+=str(i)+' '\\n    else:\\n        s+=str(n+i)\\n        break\\nprint(i)\\nprint(s)\", \"n = int(input())\\nk = 1\\nwhile k * (k + 1) // 2 <= n:\\n    k += 1\\nk -= 1\\nprint(k)\\nfor i in range(1, k):\\n    print(i, end=' ')\\nprint(n - k * (k - 1) // 2)\", \"n=int(input())\\nif n==1:\\n    print(1)\\n    print(1)\\nelif n==2:\\n    print(1)\\n    print(2)\\nelse:\\n    t=[]\\n    i=1\\n    while i<=n:\\n        n-=i\\n        t.append(i)\\n        i+=1\\n    k=len(t)\\n    t[k-1]+=n\\n    print(k)\\n    for i in t:\\n        print(i,end=\\\" \\\")\", \"#not submitted not completed\\n#http://codeforces.com/problemset/problem/753/A\\nn = int(input())\\nsum = 0\\nnumbers = []\\ni = 1\\nwhile sum < n:\\n\\tnumbers.append(i)\\n\\tsum += i\\n\\ti += 1\\nif sum > n:\\n\\tdel numbers[sum - n - 1]\\nprint(len(numbers))\\nfor j in numbers:\\n\\tprint(j, end=\\\" \\\")\\nprint()\", \"n = int(input())\\nc=1\\nsol = []\\nwhile n>c:\\n    n = n-c\\n    sol.append(c)\\n    c=c+1\\nif n >= c:\\n    sol.append(n)\\nelse:\\n    sol[-1] += n\\nprint(len(sol))\\nprint(*sol)\\n\"]",
        "difficulty": "interview",
        "input": "991\n",
        "output": "44\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/753/A"
    },
    {
        "id": 1215,
        "task_id": 471,
        "test_case_id": 3,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "5 0\n0 0 1000 0 0\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1216,
        "task_id": 471,
        "test_case_id": 5,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "2 1\n4 -8\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1217,
        "task_id": 471,
        "test_case_id": 10,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "9 -3\n-10 -7 -3 -4 7 -6 10 -10 -7\n",
        "output": "24\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1218,
        "task_id": 471,
        "test_case_id": 16,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "65 13\n14 10 16 19 12 12 10 14 20 11 12 11 17 12 11 14 20 20 16 12 17 14 11 20 10 11 10 13 10 20 19 14 14 11 10 18 10 18 13 10 20 20 10 13 16 10 12 10 12 17 16 18 10 10 12 16 10 13 15 20 13 12 19 20 16\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1219,
        "task_id": 471,
        "test_case_id": 17,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "73 14\n11 19 16 17 10 14 15 13 19 15 12 10 17 13 11 17 12 20 17 10 18 18 12 12 16 15 16 19 10 14 19 16 17 18 17 18 16 20 18 16 19 20 20 20 18 19 11 12 11 15 13 16 12 18 11 20 19 10 19 16 14 11 18 14 13 19 16 11 11 10 12 16 18\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1220,
        "task_id": 471,
        "test_case_id": 20,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "11 -28\n-20 -18 -12 -11 -13 -14 -13 -17 -14 -10 -10\n",
        "output": "18\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1221,
        "task_id": 471,
        "test_case_id": 28,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "97 -13\n-17 -11 -20 -16 -11 -18 -17 -14 -19 -13 -11 -19 -15 -17 -11 -20 -10 -19 -10 -18 -11 -14 -11 -15 -13 -13 -11 -18 -18 -18 -11 -14 -20 -19 -10 -17 -18 -19 -17 -11 -11 -11 -20 -19 -16 -15 -18 -15 -15 -20 -19 -20 -16 -13 -17 -11 -13 -18 -10 -13 -10 -14 -12 -17 -20 -10 -11 -19 -19 -15 -19 -10 -18 -14 -15 -15 -11 -13 -20 -10 -10 -16 -18 -15 -14 -13 -13 -11 -16 -10 -16 -18 -11 -19 -11 -14 -18\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1222,
        "task_id": 471,
        "test_case_id": 31,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "1 -1000000\n1000000\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1223,
        "task_id": 471,
        "test_case_id": 32,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "1 89765\n89782\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1224,
        "task_id": 471,
        "test_case_id": 33,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "1 -78621\n-77777\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1225,
        "task_id": 471,
        "test_case_id": 34,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "5 10\n1 1 1 1 1\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1226,
        "task_id": 471,
        "test_case_id": 36,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "1 100\n300\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1227,
        "task_id": 471,
        "test_case_id": 42,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "5 3\n-100000 1 1 2 10\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1228,
        "task_id": 471,
        "test_case_id": 45,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "6 4\n-100 1 2 3 4 5\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1229,
        "task_id": 471,
        "test_case_id": 47,
        "question": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.\n\nVasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.\n\nThe second line contains n integers x_1, x_2, ..., x_{n} ( - 1 000 000 ≤ x_{i} ≤ 1 000 000) — coordinates of the checkpoints.\n\n\n-----Output-----\n\nPrint one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.\n\n\n-----Examples-----\nInput\n3 10\n1 7 12\n\nOutput\n7\n\nInput\n2 0\n11 -10\n\nOutput\n10\n\nInput\n5 0\n0 0 1000 0 0\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.\n\nIn the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.",
        "solutions": "[\"from math import *\\nn, a = map(int, input().split())\\nA = list(map(int, input().split()))\\nA.sort()\\nif n == 1:\\n    print(0)\\n    \\nelse:\\n    if a > A[-1]:\\n        print(abs(a - A[1]))\\n    elif a < A[0]:\\n        print(abs(a - A[-2]))\\n    else:\\n        per1 = abs(A[0] - A[-2])\\n        per2 = abs(A[1] - A[-1])\\n        ans1 = abs(A[0] - a) + per1\\n        ans2 = per1 + abs(A[-2] - a)\\n        ans3 = per2 + abs(a - A[-1])\\n        ans4 = per2 + abs(a - A[1])\\n        print(min(ans1, ans2, ans3, ans4))\", \"#!/usr/bin/env python3.5\\nimport sys\\n\\ndef read_data():\\n    n, x0 = list(map(int, next(sys.stdin).split()))\\n    checkpoints = list(map(int, next(sys.stdin).split()))\\n    return x0, checkpoints\\n\\n\\ndef solve(x0, checkpoints):\\n    n = len(checkpoints)\\n    checkpoints.sort()\\n    if n == 1:\\n        return 0\\n    case0 = abs(x0 - checkpoints[1]) + abs(checkpoints[n-1] - checkpoints[1])\\n    case1 = abs(x0 - checkpoints[n-2]) + abs(checkpoints[0] - checkpoints[n-2])\\n    case2 = abs(x0 - checkpoints[0]) + abs(checkpoints[n-2] - checkpoints[0])\\n    case3 = abs(x0 - checkpoints[n-1]) + abs(checkpoints[1] - checkpoints[n-1])\\n    return min(case0, case1, case2, case3)\\n\\n\\ndef __starting_point():\\n    x0, checkpoints = read_data()\\n    length = solve(x0, checkpoints)\\n    print(length)\\n\\n__starting_point()\", \"def calc_dist(coords, a):\\n    if len(coords) == 0:\\n        return 0\\n    \\n    if a > coords[-1]:\\n        return a - coords[0]\\n    if a < coords[0]:\\n        return coords[-1] - a\\n    \\n    return coords[-1] - coords[0] + min(a - coords[0], coords[-1] - a)\\n\\n\\nn, a = list(map(int, input().split()))\\n\\ncoords = list(map(int, input().split()))\\n\\ncoords.sort()\\n\\n#~ print(coords[:-1], coords[1:])\\n\\nprint(min(calc_dist(coords[:-1], a), calc_dist(coords[1:], a)))\\n\", \"n, a = [int(i) for i in input().split()]\\n\\npoints = [int(i) for i in input().split()]\\n\\nright = None\\nright2 = None\\nleft = None\\nleft2 = None\\n\\nfor point in points:\\n    if right is None:\\n        right = point\\n\\n    else:\\n        if point > right:\\n            right2 = right\\n            right = point\\n        elif right2 is None or point > right2:\\n            right2 = point\\n\\n    if left is None:\\n        left = point\\n    else:\\n        if point < left:\\n            left2 = left\\n            left = point\\n        elif left2 is None or point < left2:\\n            left2 = point\\n\\n\\nif n == 1:\\n    print(0)\\nelif a >= right:\\n    print(a-left2)\\nelif a <= left:\\n    print(right2-a)\\n\\nelse:\\n    x1 = abs(a-left)+abs(right2-left)\\n    x2 = abs(a-left2)+abs(right-left2)\\n    x3 = abs(right-a)+abs(right-left2)\\n    x4 = abs(right2-a)+abs(right2-left)\\n    print(min((x1,x2,x3,x4)))\\n    \\n\", \"n, a = map(int, input().split())\\nc = list(map(int, input().split()))\\nc.sort()\\nif n == 1:\\n    print(0)\\nelif n == 2:\\n    print(min(abs(c[0] - a), abs(c[1] - a)))\\nelse:\\n    if abs(c[0] - a) < abs(c[n - 2] - a):\\n        ans = abs(c[0] - a) + abs(c[0] - c[n - 2])\\n    else:\\n        ans = abs(c[n - 2] - a) + abs(c[0] - c[n - 2])\\n    if abs(c[1] - a) < abs(c[n - 1] - a):\\n        ans = min(ans, abs(c[1] - a) + abs(c[1] - c[n - 1]))\\n    else:\\n        ans = min(ans, abs(c[n - 1] - a) + abs(c[n - 1] - c[1]))\\n    print(ans)\", \"n, a = [int(i) for i in input().split()]\\ns = [int(i) for i in input().split()]\\ns.sort()\\nt = len(s)-1\\nfor i in range(n):\\n\\tif s[i] >a:\\n\\t\\tt = i-1\\n\\t\\tbreak\\nif n == 1:\\n\\tprint(0)\\nelif t == -1:\\n\\tprint(abs(s[-2]-a))\\nelif t == n-1:\\n\\tprint(abs(a-s[1]))\\nelif t == 0:\\n\\tprint(min(abs(s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a)))\\nelif t == n-2:\\n\\tprint(min(abs(a-s[0]), abs(s[-1]-s[1]+s[-1]-a), abs(s[-1]-s[1]+a-s[1])))\\nelse:\\n\\tans = min(abs(s[-1]-s[1]+a-s[1]),abs(s[-1]-s[1]+s[-1]-a), abs(s[-2]-s[0]+a-s[0]), abs(s[-2]-s[0]+s[-2]-a))\\n\\tprint(ans)\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\ndef visit(a,b,c):\\n    if a<=b:\\n        return c-a\\n    if a>=c:\\n        return a-b\\n    return c-b + min(c-a, a-b)\\nx.sort()\\nif n <= 1:\\n    print(0)\\nelif a <= x[0]:\\n    print(x[-2]-a)\\nelif a >= x[-1]:\\n    print(a-x[1])\\nelse:\\n    #~ ans = 10**7\\n    print(min(visit(a, x[0], x[-2]), visit(a,x[1],x[-1])))\\n    \\n\", \"# You lost the game.\\nn,a = list(map(int, input().split()))\\nL = list(map(int, input().split()))\\nL.sort()\\nif n == 1:\\n    print(0)\\nelif a >= L[n-1]:\\n    print(a-L[1])\\nelif a <= L[0]:\\n    print(L[n-2]-a)\\nelse:\\n    gauche = min(abs(a - L[0]),abs(L[n-2] - a)) + L[n-2] - L[0]\\n    droite = min(abs(a - L[1]),abs(L[n-1] - a)) + L[n-1] - L[1]\\n    if gauche < droite:\\n        print(gauche)\\n    else:\\n        print(droite)\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Wed Aug 24 12:53:13 2016\\n\\n@author: Felicia\\n\\\"\\\"\\\"\\n\\ninp1 = input()\\ninp11 = inp1.split(' ')\\nn = int(inp11[0])\\na = int(inp11[1])\\n\\ninp2 = input()\\ninp21 = inp2.split(' ')\\nx0 = []\\nfor i in inp21:\\n    j=int(i)\\n    x0.append(j)\\n\\nx = sorted(x0)\\n\\ndef f(x):\\n    if x>0:\\n        return x\\n    else:\\n        return 0\\nif n>1:\\n    len1 = 2*f(a-x[0])+f(x[n-2]-a)\\n    len2 = 2*f(x[n-2]-a)+f(a-x[0])\\n    len3 = 2*f(a-x[1])+f(x[n-1]-a)\\n    len4 = 2*f(x[n-1]-a)+f(a-x[1])\\n    \\n    print(min(len1,len2,len3,len4))\\nelse:\\n    print(0)\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,a = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb.sort()\\nif(len(b) == 1):\\n    print(0)\\nelif(len(b) == 2):\\n    print(min(abs(a - b[0]), abs(a - b[1])))\\nelif(a < b[0]):\\n    print(b[-2] - a)\\nelif(a > b[-1]):\\n    print(a - b[1])\\nelif(a == b[0]):\\n    print(b[-2] - a)\\nelif(a == b[-1]):\\n    print(a - b[1])\\nelif(len(b) == 3):\\n    if(a < b[1]):\\n        print(min(a - b[0] - b[0] + b[1], b[1]-a + b[1]-a + a-b[0], b[2] - a))\\n    elif(a > b[1]):\\n        print(min(a - b[0], a - b[1] + a - b[1] + b[2] - a, b[2] - a + b[2] - a + a - b[1]))\\n    else:\\n        print(min(a - b[0], b[2] - a))\\nelif(a < b[1]):\\n    print(min(a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0], b[-1] - a))\\nelif(a > b[-2]):\\n    print(min(a - b[0], b[-1] - a + b[-1] - a + a - b[1], a - b[1] + a - b[1] + b[-1] - a))\\nelse:\\n    print(min(a - b[1] + a - b[1] + b[-1] - a, b[-1] - a + b[-1] - a + a - b[1],a - b[0] + a - b[0] + b[-2] - a, b[-2] - a + b[-2] - a + a - b[0]))\\n\", \"n,a=list(map(int,input().split()))\\nip=list(map(int,input().split()))\\ntry:\\n    if a not in ip:\\n        ip.append(a)\\n        n+=1\\n    ip=sorted(ip)\\n    k=ip.index(a)\\n    l1=0\\n    l2=0\\n    for i in range(k):\\n        l1+=ip[i+1]-ip[i]\\n    for i in range(k,n-1):\\n        l2+=ip[i+1]-ip[i]\\n    n1=ip[1]-ip[0]\\n    n2=ip[-1]-ip[-2]\\n    if l1==0:\\n        print(l2-n2)\\n    elif l2==0:\\n        print(l1-n1)\\n    else:\\n        print(min(l1-n1+2*l2, 2*l1-2*n1+l2, l2-n2+2*l1, 2*l2-2*n2+l1))\\nexcept:\\n    print(0)\\n\", \"n, a = list(map(int, input().split()))\\nline = list(map(int, input().split()))\\nline.sort()\\nif len(line) == 1:\\n    print(0)\\nelse:    \\n    r1 = abs(line[-1] - line[1])\\n    otvet1 = min(abs(a - line[1]), abs(a - line[-1])) + r1\\n    r2 = abs(line[-2] - line[0])\\n    otvet2 = min(abs(a - line[-2]), abs(a - line[0])) + r2\\n    print(min(otvet1, otvet2))\", \"#!/usr/bin/env python3\\n\\nfrom sys import stdin\\n\\n\\ndef main():\\n    n, a = stdin_get_ints_from_line()\\n    x = stdin_get_ints_list_from_line()\\n    x.sort()\\n\\n    if n == 1:\\n        print(0)\\n        return\\n\\n    #print(get_result(a, x[1], x[-1]), get_result(a, x[1], x[-1]))\\n\\n    print(min(get_result(a, x[1], x[-1]), get_result(a, x[0], x[-2])))\\n\\n\\ndef get_result(a, left, right):\\n    #print(a, left, right)\\n    if left < a < right:\\n        if abs(a-left) < abs(a-right): # go left first\\n            return (abs(a-left) * 2) + abs(a-right)\\n        else:\\n            return abs(a-left) + (abs(a-right) * 2)\\n\\n    if a <= left:\\n        return abs(a-right)\\n\\n    if a >= right:\\n        return abs(a-left)\\n\\n\\ndef stdin_get_ints_from_line():\\n    return (int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_ints_list_from_line():\\n    return list(int(x) for x in stdin.readline().strip().split(' '))\\n\\n\\ndef stdin_get_string_from_line():\\n    return stdin.readline().strip()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,p = list(map(int,input().split()))\\na = list(map(int,input().split()))\\na.sort()\\nif n==1:\\n    print(0)\\nelif n==2:\\n    print(min(abs(a[0]-p),abs(a[1]-p)))\\n\\nelse:\\n    a1 = min(abs(a[0]-p),abs(a[-2]-p)) + abs(a[0]-a[-2])\\n    a2 = min(abs(a[1]-p),abs(a[-1]-p)) + abs(a[1]-a[-1])\\n    print(min(a1,a2))\\n\\n\\n\\n\", \"n, a = list(map(int, input().split()))\\nx = list(map(int, input().split()))\\n\\nx.sort()\\nres = 2**30\\n\\ndef solve(a, i, j):\\n    if a >= x[j]:\\n        return a - x[i]\\n    elif a <= x[i]:\\n        return x[j] - a\\n    else:\\n        sumLeft = (a - x[i]) * 2 + x[j] - a\\n        sumRight = (x[j] - a) * 2 + a - x[i]\\n        return min(sumLeft, sumRight)\\n\\nif n <= 1:\\n    res = 0\\n\\nelif n == 2:\\n    for value in x:\\n        res = min(res, abs(value - a))\\nelse:\\n    if a <= x[0]:\\n        res = x[len(x) - 2] - a;\\n    elif a >= x[len(x) - 1]:\\n        res = a - x[1]\\n    else:\\n        leftValue = solve(a, 1, len(x) - 1)\\n        rightValue = solve(a, 0, len(x) - 2)\\n        res = min(leftValue, rightValue)\\n\\nprint(res)\\n\\n\", \"n,x=[int(i) for i in input().strip().split()]\\na=[int(i) for i in input().strip().split() if int(i)!=x]\\nif len(a)<=1:\\n  ans=0\\nelse:\\n  a=sorted([x]+a)\\n  ind=a.index(x)\\n  if ind==0:\\n    ans=a[-2]-a[0]\\n  elif ind==len(a)-1:\\n    ans=a[-1]-a[1]\\n  else:\\n    ans=min((a[ind]+a[-2]-2*a[0]), (2*a[-2]-a[ind]-a[0]), (a[ind]+a[-1]-2*a[1]), (2*a[-1]-a[ind]-a[1]))\\nprint(ans)\", \"N, A = list(map(int, input().split()))\\nX = list(map(int, input().split()))\\nX.sort()\\nif N == 1:\\n    print(0)\\n    return\\nelif N == 2:\\n    print(min(abs(X[0] - A), abs(X[1] - A)))\\n    return\\nans = int(1e18)\\nans = min(ans, abs(X[N-2] - X[0]) + min(abs(A - X[0]), abs(A - X[N-2])))\\nans = min(ans, abs(X[N-1] - X[1]) + min(abs(A - X[1]), abs(A - X[N-1])))\\nprint(ans)\\n\", \"n, a = list(map(int, input().split(' ')))\\nx = list(map(int, input().split(' ')))\\n\\nMAX, MIN = 1000000, -1000000\\n\\nr1, r2, l1, l2 = MIN-1, MIN-1, MAX+1, MAX+1\\n\\nfor xi in x:\\n    if xi <= l1:\\n        l2 = l1\\n        l1 = xi\\n    elif xi < l2:\\n        l2 = xi\\n        \\n    if xi >= r1:\\n        r2 = r1\\n        r1 = xi\\n    elif xi > r2:\\n        r2 = xi\\n\\nif n == 1:\\n    print(0)\\nelse:        \\n    print((min(\\n        r1 - l2 + abs(a - r1),\\n        r1 - l2 + abs(a - l2),\\n        r2 - l1 + abs(a - r2),\\n        r2 - l1 + abs(a - l1))))\\n\", \"n,d = map(int,input().split())\\na = list(map(int,input().strip().split()))\\n\\n#print(n)\\n#print(a)\\na.sort()\\n#print(a)\\n\\nans =0\\nif n==1:\\n    ans=0\\nelif n<=2:\\n    ans = min(abs(a[0]-d),abs(a[n-1]-d))     \\nelse:\\n   # print(\\\"en\\\")\\n    ans =a[n-2]-a[0] + min(abs(a[0]-d),abs(a[n-2]-d))\\n    #print(ans)    \\n    ans = min(ans,a[n-1]-a[1] + min(abs(a[1]-d),abs(a[n-1]-d)))\\n   # print(ans)\\nprint(ans)\", \"from math import *\\n\\n[n, a] = [int(x) for x in input().split()]\\n\\nif n == 1:\\n    print(0)\\n    return\\n\\npoints = [int(x) for x in input().split()]\\npoints.sort()\\n\\ndis1 = abs(points[n-2] - points[0])\\ndis2 = abs(points[n-1] - points[1])\\n\\nto0 = abs(a - points[0])\\nto1 = abs(a - points[1])\\nton = abs(a - points[n-1])\\nton2 = abs(a - points[n-2])\\n\\nprint(min(to0 + dis1, to1 + dis2, ton + dis2, ton2 + dis1))\", \"def solve():\\n    n, a = list(map(int, input().split()))\\n    x = list(map(int, input().split()))\\n    x.append(a)\\n    x.sort()\\n    bi = 0\\n    for i in range(n + 1):\\n        if x[i] == a:\\n            bi = i\\n            break\\n    ans = float('inf')\\n    for s in range(2):\\n        l = 0\\n        r = 0\\n        ok = x[s] == a\\n        for i in range(s + 1, s + n):\\n            ok = ok or x[i] == a\\n            if i <= bi:\\n                l += x[i] - x[i - 1]\\n            else:\\n                r += x[i] - x[i - 1]\\n        if ok:\\n            ans = min(ans, min(l, r) * 2 + max(l, r))\\n    print(ans)\\n\\n\\ndef main():\\n    solve()\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a = list(map(int, input().split()))\\n\\nl = input().split()\\nl = [int(i) for i in l]\\n\\nif(n == 1):\\n    print(0)\\nelif(n == 2):\\n    if(abs(a-l[0]) < abs(a-l[1])):\\n        print(abs(a-l[0]))\\n    else:\\n        print(abs(a-l[1]))\\nelse:\\n    ma = max(l)\\n    mi = min(l)\\n    l.remove(ma)\\n    max2 = max(l)\\n    l.append(ma)\\n    l.remove(mi)\\n    min2 = min(l)\\n    l.append(mi)\\n\\n    if(a > ma):\\n        print(a-min2)\\n    elif(a < mi):\\n        print(max2-a)\\n    else:\\n        ans=list()\\n        ans.append(abs(max2 - a) + max2 - mi)\\n        ans.append(abs(a - mi) + max2 - mi)\\n        ans.append(ma - min2 + abs(ma - a))\\n        ans.append(ma - min2 + abs(a - min2))\\n        while(min(ans) < 0):\\n            ans.remove(min(ans))\\n        print(min(ans))\\n\", \"n, a = map(int, input().split())\\nN = sorted(list(map(int, input().split())))\\ndist = 0\\n \\nif n == 1:\\n    dist = 0\\n   \\nelif n == 2:\\n    dist = min(abs(N[0] - a), abs(N[1] - a))\\n   \\nelif a <= N[0]:\\n    dist = abs(N[-2] - a)\\n   \\nelif a >= N[-1]:\\n    dist = abs(a - N[1])\\n\\nelif a >= N[-2]:\\n    dist = min(abs(a - N[0]), 2 * abs(a - N[-1]) + abs(a - N[1]), abs(a - N[-1]) + 2 * abs(a - N[1]))\\n\\nelif a <= N[1]:\\n    dist = min(abs(a - N[-1]), 2 * abs(a - N[0]) + abs(a - N[-2]), abs(a - N[0]) + 2 * abs(a - N[-2]))\\n   \\nelse:\\n    dist = min(2 * abs(N[0] - a) + abs(N[-2] - a), 2 * abs(N[1] - a) + abs(N[-1] - a), 2 * abs(N[-1] - a) + abs(N[1] - a), 2 * abs(N[-2] - a) + abs(N[0] - a))\\n\\n\\nprint(dist)\"]",
        "difficulty": "interview",
        "input": "6 -2\n-3 1 2 3 4 6\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/709/B"
    },
    {
        "id": 1230,
        "task_id": 509,
        "test_case_id": 1,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "3\n10\n20\n30\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1231,
        "task_id": 509,
        "test_case_id": 2,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "3\n10\n10\n10\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1232,
        "task_id": 509,
        "test_case_id": 3,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "3\n120\n120\n120\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1233,
        "task_id": 509,
        "test_case_id": 4,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "10\n151\n172\n68\n9\n8\n1\n18\n116\n59\n117\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1234,
        "task_id": 509,
        "test_case_id": 5,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "11\n121\n62\n66\n177\n5\n173\n16\n31\n80\n31\n54\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1235,
        "task_id": 509,
        "test_case_id": 6,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "12\n16\n27\n65\n54\n154\n90\n23\n135\n102\n42\n17\n173\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1236,
        "task_id": 509,
        "test_case_id": 7,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "15\n68\n97\n79\n11\n88\n144\n139\n77\n90\n157\n102\n170\n1\n147\n70\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1237,
        "task_id": 509,
        "test_case_id": 8,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "9\n1\n2\n4\n8\n16\n32\n64\n128\n76\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1238,
        "task_id": 509,
        "test_case_id": 9,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "10\n1\n1\n2\n4\n8\n16\n32\n64\n128\n76\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1239,
        "task_id": 509,
        "test_case_id": 10,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "1\n180\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1240,
        "task_id": 509,
        "test_case_id": 11,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "1\n1\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1241,
        "task_id": 509,
        "test_case_id": 12,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "2\n180\n180\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1242,
        "task_id": 509,
        "test_case_id": 13,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "15\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1243,
        "task_id": 509,
        "test_case_id": 14,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "15\n24\n24\n24\n24\n24\n24\n24\n24\n24\n24\n24\n24\n24\n24\n24\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1244,
        "task_id": 509,
        "test_case_id": 15,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "8\n1\n2\n4\n8\n16\n32\n64\n128\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1245,
        "task_id": 509,
        "test_case_id": 16,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "10\n1\n1\n3\n3\n9\n9\n27\n27\n81\n81\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1246,
        "task_id": 509,
        "test_case_id": 17,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "11\n1\n1\n3\n3\n9\n9\n27\n27\n81\n81\n117\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1247,
        "task_id": 509,
        "test_case_id": 18,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "9\n1\n2\n4\n8\n16\n32\n64\n128\n104\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1248,
        "task_id": 509,
        "test_case_id": 19,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "12\n1\n1\n2\n5\n5\n10\n25\n25\n50\n125\n125\n110\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1249,
        "task_id": 509,
        "test_case_id": 20,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "3\n11\n6\n7\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1250,
        "task_id": 509,
        "test_case_id": 21,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "10\n77\n92\n11\n84\n57\n126\n18\n146\n139\n54\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1251,
        "task_id": 509,
        "test_case_id": 22,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "13\n122\n12\n117\n71\n30\n87\n168\n145\n12\n134\n139\n57\n64\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1252,
        "task_id": 509,
        "test_case_id": 23,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "15\n100\n10\n14\n2\n3\n11\n10\n1\n3\n7\n6\n5\n4\n3\n1\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1253,
        "task_id": 509,
        "test_case_id": 24,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "15\n22\n145\n26\n44\n142\n44\n83\n5\n44\n53\n66\n35\n13\n13\n35\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1254,
        "task_id": 509,
        "test_case_id": 25,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "15\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1255,
        "task_id": 509,
        "test_case_id": 26,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "14\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1256,
        "task_id": 509,
        "test_case_id": 27,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "15\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1257,
        "task_id": 509,
        "test_case_id": 28,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "5\n179\n179\n179\n179\n4\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1258,
        "task_id": 509,
        "test_case_id": 29,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "5\n40\n170\n170\n170\n170\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1259,
        "task_id": 509,
        "test_case_id": 30,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "5\n179\n178\n177\n176\n10\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1260,
        "task_id": 509,
        "test_case_id": 31,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "5\n144\n144\n144\n144\n144\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1261,
        "task_id": 509,
        "test_case_id": 32,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "6\n180\n178\n157\n143\n63\n1\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1262,
        "task_id": 509,
        "test_case_id": 33,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "5\n179\n179\n179\n92\n91\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1263,
        "task_id": 509,
        "test_case_id": 34,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "15\n49\n52\n58\n34\n40\n43\n49\n55\n34\n52\n43\n55\n55\n46\n55\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1264,
        "task_id": 509,
        "test_case_id": 35,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "4\n1\n178\n180\n1\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1265,
        "task_id": 509,
        "test_case_id": 36,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "5\n100\n100\n100\n100\n40\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1266,
        "task_id": 509,
        "test_case_id": 37,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "6\n129\n156\n147\n174\n126\n138\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1267,
        "task_id": 509,
        "test_case_id": 38,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "10\n145\n129\n125\n164\n164\n55\n98\n43\n157\n100\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1268,
        "task_id": 509,
        "test_case_id": 39,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "2\n10\n10\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1269,
        "task_id": 509,
        "test_case_id": 40,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "6\n125\n125\n125\n125\n125\n95\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1270,
        "task_id": 509,
        "test_case_id": 41,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "6\n100\n110\n125\n130\n140\n115\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1271,
        "task_id": 509,
        "test_case_id": 42,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "5\n120\n120\n120\n40\n40\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1272,
        "task_id": 509,
        "test_case_id": 43,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "11\n70\n70\n70\n70\n70\n70\n70\n70\n70\n70\n20\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1273,
        "task_id": 509,
        "test_case_id": 44,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "5\n179\n170\n160\n111\n100\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1274,
        "task_id": 509,
        "test_case_id": 45,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "9\n80\n80\n80\n80\n80\n80\n80\n80\n80\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1275,
        "task_id": 509,
        "test_case_id": 46,
        "question": "Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $360$ degrees and a pointer which initially points at zero:\n\n [Image] \n\nPetr called his car dealer, who instructed him to rotate the lock's wheel exactly $n$ times. The $i$-th rotation should be $a_i$ degrees, either clockwise or counterclockwise, and after all $n$ rotations the pointer should again point at zero.\n\nThis confused Petr a little bit as he isn't sure which rotations should be done clockwise and which should be done counterclockwise. As there are many possible ways of rotating the lock, help him and find out whether there exists at least one, such that after all $n$ rotations the pointer will point at zero again.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($1 \\leq n \\leq 15$) — the number of rotations.\n\nEach of the following $n$ lines contains one integer $a_i$ ($1 \\leq a_i \\leq 180$) — the angle of the $i$-th rotation in degrees.\n\n\n-----Output-----\n\nIf it is possible to do all the rotations so that the pointer will point at zero after all of them are performed, print a single word \"YES\". Otherwise, print \"NO\". Petr will probably buy a new car in this case.\n\nYou can print each letter in any case (upper or lower).\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\nYES\n\nInput\n3\n10\n10\n10\n\nOutput\nNO\n\nInput\n3\n120\n120\n120\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first example, we can achieve our goal by applying the first and the second rotation clockwise, and performing the third rotation counterclockwise.\n\nIn the second example, it's impossible to perform the rotations in order to make the pointer point at zero in the end.\n\nIn the third example, Petr can do all three rotations clockwise. In this case, the whole wheel will be rotated by $360$ degrees clockwise and the pointer will point at zero again.",
        "solutions": "[\"import getpass\\nimport sys\\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\\nn = ria()[0]\\nar = []\\nfor i in range(n):\\n    ar.append(ria()[0])\\n\\nsm = sum(ar) / 2\\nfor i in range(2 ** n):\\n    c = 0\\n    for j in range(n):\\n        if i & (1 << j):\\n            c += ar[j]\\n        else:\\n            c -= ar[j]\\n    if c % 360 == 0:\\n        print('YES')\\n        return\\nprint('NO')\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = [ii() for i in range(n)]\\nans = 0\\nfor i in range(2 ** n):\\n    s = 0\\n    for b in range(n):\\n        if i >> b & 1:\\n            s += a[b]\\n        else:\\n            s -= a[b]\\n    if s % 360 == 0:\\n        ans = 1\\n        break\\nprint('YES' if ans else 'NO')\\n\", \"n = int(input())\\n\\na = [int(input()) for _ in range(n)]\\n\\nok = False\\n\\nfor i in range(2**n):\\n\\tbi = bin(i)[2:]\\n\\tbi = '0' * (n - len(bi)) + bi\\n\\tif sum((-1 if bi[j] == '0' else 1) * a[j] for j in range(n)) % 360 == 0:\\n\\t\\tok = True\\n\\nprint('YES' if ok else 'NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\n\\ndef rec(s, a, i):\\n    if i == len(a):\\n        return (s % 360 == 0)\\n    return rec((s + a[i]) % 360, a, i + 1) or rec((s - a[i]) % 360, a, i + 1)\\n\\nprint('YES' if rec(0, a, 0) else 'NO')\", \"N = int(input())\\nn = [int(input())for i in range(N)]\\ns = sum(n)\\nw = 0\\nfor k in range(2**N) :\\n    p = sum(n[i]for i in range(N)if k&(1<<i))\\n    if (s-p-p)%360 == 0 :\\n        print('YES')\\n        w = 1\\n        break\\nif w == 0 :\\n    print('NO')\\n        \\n\", \"\\nn = int(input())\\na = [ int(input()) for x in range(0, n) ]\\n\\nfor x in range(0, 2 ** n + 1):\\n    v = 0\\n    for p in range(0, n):\\n        if (x >> p) & 1 != 0:\\n            v += a[p]\\n        else:\\n            v -= a[p]\\n\\n    if v % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\\n\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\ndef getIntList():\\n    return list(map(int, input().split()))    \\n\\ntry :\\n    #raise ModuleNotFoundError\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\n\\ninId = 0\\noutId = 0\\nif inId>0:\\n    dprint('use input', inId)\\n    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\nif outId>0:\\n    dprint('use output', outId)\\n    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n    atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n    \\nN, = getIntList()\\n#print(N)\\nza = []\\nfor i in range(N):\\n    a, = getIntList()   \\n    za.append(a)\\n\\nfor mm in range( 1<<N):\\n    c = 0\\n    for i in range(N):\\n        if mm & (1<<i):\\n            c+=za[i]\\n        else:\\n            c-= za[i]\\n    if c%360==0:\\n        print(\\\"YES\\\")\\n        return\\n\\nprint(\\\"NO\\\")\\n\\n\\n\\n\", \"from itertools import product\\n\\nN = int(input())\\nA = [int(input()) for i in range(N)]\\n\\nfor P in product([0, 1], repeat=N):\\n    d = 0\\n    for a, p in zip(A, P):\\n        if p:\\n            d += a\\n        else:\\n            d -= a\\n    if d % 360 == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\", \"def gen(i, angle):\\n    if i == n:\\n        return angle % 360 == 0\\n    return gen(i + 1, angle + a[i]) or gen(i + 1, angle - a[i])\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nprint(\\\"YES\\\" if gen(0, 0) else \\\"NO\\\")\", \"n = int(input())\\n\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\np = False\\n\\nfor i in range(2**n):\\n    k = ('0'*20 + str(bin(i))[2:])[-n:]\\n\\n    total = 0\\n    for j in range(n):\\n        if (k[j] == '0'):\\n            total += l[j]\\n        else:\\n            total -= l[j]\\n\\n    if (total%360 == 0):\\n        p = True\\n\\nif p:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\nl = []\\nfor i in range(n):\\n    l.append(int(input()))\\n\\ns = sum(l)\\n\\nout = False\\n\\nfor test in range(pow(2, n)):\\n    snew = sum([l[i] for i in range(n) if (test & pow(2,i) != 0)])\\n    if (s - 2 * snew) % 360 == 0:\\n        out = True\\n        break\\n\\nif out:\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nfor i in range(2 ** n):\\n\\tsu = 0\\n\\tfor j in range(n):\\n\\t\\tif ((1 << j) | i) != i:\\n\\t\\t\\tsu += a[j]\\n\\t\\telse:\\n\\t\\t\\tsu -= a[j]\\n\\tif su % 360 == 0:\\n\\t\\tprint('YES')\\n\\t\\treturn\\nprint('NO')\", \"n = int(input())\\na = [int(input()) for i in range(n)]\\nok = [False for i in range(360)]\\nok[0] = True\\n\\nfor i in range(n):\\n    ok2 = [False for i in range(360)]\\n    for j in range(360):\\n        if ok[j]:\\n            ok2[(j + a[i]) % 360] = True\\n            ok2[(j - a[i]) % 360] = True\\n    ok = ok2[:]\\n\\nif ok[0]:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\na = [0]\\nfor i in range(n):\\n    st = []\\n    t = int(input())\\n    for i in a:\\n        st.append(i + t)\\n        st.append(i - t)\\n    a = st\\nr = False\\nfor i in a:\\n    if ((i % 360) + 360) % 360 == 0:\\n        r = True\\nprint('YES' if r else 'NO')\\n\", \"import sys\\nn = int(input())\\ntab = [0]\\nfor i in range(n):\\n\\tnewtab = []\\n\\tnew = int(input())\\n\\tfor j in tab:\\n\\t\\tnewtab.append(j+new)\\n\\t\\tnewtab.append(j-new)\\n\\ttab = newtab\\nfor i in tab:\\n\\tif i%360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\", \"#! usr/bin/env python\\n# -*- coding : utf-8 -*-\\n\\nfrom collections import deque\\nimport heapq\\nimport bisect\\nimport math\\n\\n\\ndef main():\\n    n = int(input())\\n    a = [int(input()) for i in range(n)]\\n\\n    for i in range(1 << n):\\n        cur = 0\\n        for j in range(n):\\n            if (i >> j) & 1:\\n                cur += a[j]\\n            else:\\n                cur -= a[j]\\n\\n        if cur % 360 == 0:\\n            print(\\\"YES\\\")\\n            return\\n\\n    print(\\\"NO\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(int(input()))\\nimport itertools as it\\nif sum(a) % 2:\\n    print('NO')\\nelse:\\n    f = False\\n    q = it.product([-1,1], repeat = n)\\n    for i in q:\\n        s = 0\\n        for j in range(len(i)):\\n            s += i[j] * a[j]\\n        if s % 360 == 0:\\n            f = True\\n            break\\n    if f:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\", \"n = int(input())\\na = []\\nfor i in range(n):\\n    a.append(int(input()))\\nfor i in range(1<<n):\\n    lol = 0\\n    for j in range(n):\\n        if((1<<j)&i):\\n            lol += a[j]\\n        else:\\n            lol -= a[j]\\n    if (lol%360) == 0:\\n        print(\\\"YES\\\")\\n        break\\nelse:\\n    print(\\\"NO\\\")\\n\", \"from itertools import combinations\\nn = int(input())\\nu = []\\nfor i in range(n):\\n    u.append(int(input()))\\ns = sum(u)\\nans = s\\nk = 0\\nfor i in range(n // 2 + 1):\\n    a = combinations(u, i)\\n    for j in a:\\n        s1 = sum(j)\\n        if abs(s - s1 * 2) % 360 < ans:\\n            ans = abs(s - s1 * 2) % 360\\nif ans != 0:\\n    print('NO')\\nelse:\\n    print('YES')\\n\", \"n = int(input())\\nl = [int(input()) for _ in range(n)]\\n\\ni = 0\\nn2 = 1 << n\\nres = False\\nwhile i < n2:\\n    b = bin(i)[2:].zfill(n)\\n    s = 0\\n    for j, e in enumerate(b):\\n        if e == '0':\\n            s += l[j]\\n        else:\\n            s -= l[j]\\n    if s % 360 == 0:\\n        res = True\\n    i += 1\\n\\nif res:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"# import sys\\n# sys.stdin = open('input', 'r')\\n# sys.stdout = open('output', 'w')\\n\\ndef check(A, sum, n):\\n\\tif n == 0:\\n\\t\\tif sum%360 == 0:\\n\\t\\t\\treturn True\\n\\t\\telse:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn check(A[1:], sum + A[0], n-1) or check(A[1:], sum - A[0], n-1)\\n\\n\\nn = int(input())\\nA = []\\n\\nfor _ in range(n):\\n\\tx = int(input())\\n\\tA.append(x)\\n\\nif check(A, 0, n):\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"def read(type = 1):\\n    if type:\\n        file = open(\\\"input.dat\\\", \\\"r\\\")\\n        n = int(file.readline())\\n        a = []\\n        for i in range(n):\\n            a.append(int(file.readline()))\\n        file.close()\\n    else:\\n        n = int(input().strip())\\n        a = []\\n        for i in range(n):\\n            a.append(int(input().strip()))\\n    return n, a\\n\\n\\ndef check():\\n    s = 0\\n    for i in range(n):\\n        if c[i]:\\n            s += a[i]\\n        else:\\n            s -= a[i]\\n    if s % 360 == 0:\\n        return 1\\n\\n\\ndef back():\\n    if len(c) == n:\\n        if check():\\n            return 1\\n    else:\\n        for i in range(2):\\n            c.append(i)\\n            if back():\\n                return 1\\n            c.pop()\\n\\n\\ndef solve():\\n    if back():\\n        return 1\\n    else:\\n        return 0\\n\\n\\nc = []\\nn, a = read(0)\\nif solve():\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"\\ndef main():\\n    count=int(input())\\n    arr=[]\\n    for x in range(count):\\n        arr.append(int(input()))\\n    store=[0]\\n    for x in arr:\\n        duplicate=[]\\n        for y in store:\\n            duplicate.append((y+x)%360)\\n            duplicate.append((y-x)%360)\\n        store=duplicate.copy()\\n    if 0 in store:\\n        print(\\\"YES\\\")\\n    else:\\n        print(\\\"NO\\\")\\nmain()\\n\", \"import sys\\nfrom itertools import product\\n\\nn = int(input())\\na = [int(input()) for _ in range(n)]\\n\\nfor p in product([1, -1], repeat=n):\\n\\ttmp = 0\\n\\tfor i, sgn in enumerate(p):\\n\\t\\ttmp += sgn * a[i]\\n\\tif tmp % 360 == 0:\\n\\t\\tprint(\\\"YES\\\")\\n\\t\\treturn\\nprint(\\\"NO\\\")\"]",
        "difficulty": "interview",
        "input": "5\n30\n30\n120\n120\n120\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1097/B"
    },
    {
        "id": 1276,
        "task_id": 529,
        "test_case_id": 2,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "abcdefabc\n3\n",
        "output": "ABCdefABC\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1277,
        "task_id": 529,
        "test_case_id": 3,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "fgWjSAlPOvcAbCdDEFjz\n7\n",
        "output": "FGwjsAlpovCABCDDEFjz\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1278,
        "task_id": 529,
        "test_case_id": 5,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "GnlFOqPeZtPiBkvvLhaDvGPgFqBTnLgMT\n12\n",
        "output": "GnLFoqpEztpIBKvvLHADvGpGFqBtnLGmt\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1279,
        "task_id": 529,
        "test_case_id": 6,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "sPWSFWWqZBPon\n3\n",
        "output": "spwsfwwqzBpon\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1280,
        "task_id": 529,
        "test_case_id": 7,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "fQHHXCdeaintxHWcFcaSGWFvqnYMEByMlSNKumiFgnJB\n0\n",
        "output": "fqhhxcdeaintxhwcfcasgwfvqnymebymlsnkumifgnjb\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1281,
        "task_id": 529,
        "test_case_id": 8,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "RtsUOGkraqKyjTktAXloOEmQj\n18\n",
        "output": "RtsuOGKRAQKyJtKtAxLOOEMQJ\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1282,
        "task_id": 529,
        "test_case_id": 9,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "DuFhhnq\n4\n",
        "output": "Dufhhnq\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1283,
        "task_id": 529,
        "test_case_id": 10,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "RvpuYTxsbDiJDOLauRlfatcfwvtnDzKyaewGrZ\n22\n",
        "output": "RVPUyTxSBDIJDOLAURLFATCFwVTNDzKyAEwGRz\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1284,
        "task_id": 529,
        "test_case_id": 11,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "isfvbcBEEPaXUDhbVhwddjEutVQqNdlimIKjUnajDQ\n2\n",
        "output": "isfvBcBeepAxudhBvhwddjeutvqqndlimikjunAjdq\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1285,
        "task_id": 529,
        "test_case_id": 12,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "VtQISIHREYaEGPustEkzJRN\n20\n",
        "output": "vTQISIHREyAEGPuSTEKzJRN\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1286,
        "task_id": 529,
        "test_case_id": 14,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "VWOibsVSFkxPCmyZLWIOxFbfXdlsNzxVcUVf\n8\n",
        "output": "vwoiBsvsFkxpCmyzlwioxFBFxDlsnzxvCuvF\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1287,
        "task_id": 529,
        "test_case_id": 16,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "tAjlldiqGZUayJZHFQHFJVRukaIKepPVucrkyPtMrhIXoxZbw\n12\n",
        "output": "tAJLLDIqGzuAyJzHFqHFJvruKAIKEppvuCrKyptmrHIxoxzBw\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1288,
        "task_id": 529,
        "test_case_id": 17,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "fBUycJpfGhsfIVnXAovyoDyndkhv\n9\n",
        "output": "FBuyCjpFGHsFIvnxAovyoDynDkHv\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1289,
        "task_id": 529,
        "test_case_id": 18,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "uehLuNwrjO\n0\n",
        "output": "uehlunwrjo\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1290,
        "task_id": 529,
        "test_case_id": 19,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "gfSAltDEjuPqEsOFuiTpcUpCOiENCLbHHnCgvCQtW\n13\n",
        "output": "GFsALtDEJupqEsoFuItpCupCoIEnCLBHHnCGvCqtw\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1291,
        "task_id": 529,
        "test_case_id": 20,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "SICNEaKsjCnvOEcVqFHLIC\n16\n",
        "output": "sICNEAKsJCNvOECvqFHLIC\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1292,
        "task_id": 529,
        "test_case_id": 21,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "LdsmfiNFkPfJgRxytsSJMQZnDTZZ\n11\n",
        "output": "lDsmFInFKpFJGrxytssJmqznDtzz\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1293,
        "task_id": 529,
        "test_case_id": 23,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "kGqopTbelcDUcoZgnnRYXgPCRQwSLoqeIByFWDI\n26\n",
        "output": "KGQOPTBELCDUCOZGNNRYXGPCRQWSLOQEIBYFWDI\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1294,
        "task_id": 529,
        "test_case_id": 24,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "WHbBHzhSNkCZOAOwiKdu\n17\n",
        "output": "wHBBHzHsNKCzOAOwIKDu\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1295,
        "task_id": 529,
        "test_case_id": 26,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "WlwbRjvrOZakKXqecEdlrCnmvXQtLKBsy\n5\n",
        "output": "wlwBrjvrozAkkxqECEDlrCnmvxqtlkBsy\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1296,
        "task_id": 529,
        "test_case_id": 28,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "vPuebwksPlxuevRLuWcACTBBgVnmcAUsQUficgEAhoEm\n9\n",
        "output": "vpuEBwksplxuEvrluwCACtBBGvnmCAusquFICGEAHoEm\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1297,
        "task_id": 529,
        "test_case_id": 29,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "hQfrRArEPuVAQGfcSuoVKBKvY\n22\n",
        "output": "HQFRRAREPUVAQGFCSUOVKBKVy\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1298,
        "task_id": 529,
        "test_case_id": 31,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "abczxy\n0\n",
        "output": "abczxy\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1299,
        "task_id": 529,
        "test_case_id": 32,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "aaaaaaAAAaaaaAaaAaaAaaaaAAaAAAaaAAaaaAAaaaaaAaaAAa\n2\n",
        "output": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1300,
        "task_id": 529,
        "test_case_id": 33,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "aaaaAaaaaaaAAaaAaaAaAaaaAaaaaaAAaaAAAAAaaAaAAAAaAA\n4\n",
        "output": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1301,
        "task_id": 529,
        "test_case_id": 34,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "bBbAbbbbaaAAAaabbBbaaabBaaaBaBbAaBabaAAAaaaaBabbb\n4\n",
        "output": "BBBABBBBAAAAAAABBBBAAABBAAABABBAABABAAAAAAAABABBB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1302,
        "task_id": 529,
        "test_case_id": 35,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "BCABcbacbcbAAACCabbaccAabAAaaCCBcBAcCcbaABCCAcCb\n4\n",
        "output": "BCABCBACBCBAAACCABBACCAABAAAACCBCBACCCBAABCCACCB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1303,
        "task_id": 529,
        "test_case_id": 36,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "cdccAAaBBAADdaCDBbDcaDDabdadAbBccCCCDDBADDcdAdC\n4\n",
        "output": "CDCCAAABBAADDACDBBDCADDABDADABBCCCCCDDBADDCDADC\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1304,
        "task_id": 529,
        "test_case_id": 37,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "EcCEECdCEBaaeCBEBbAaCAeEdeCEedCAdDeEbcACdCcCCd\n4\n",
        "output": "eCCeeCDCeBAAeCBeBBAACAeeDeCeeDCADDeeBCACDCCCCD\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1305,
        "task_id": 529,
        "test_case_id": 38,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "cefEDAbedffbaCcEDfEeCEaAcCeFCcEabEecdEdcaFFde\n4\n",
        "output": "CefeDABeDffBACCeDfeeCeAACCefCCeABeeCDeDCAffDe\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1306,
        "task_id": 529,
        "test_case_id": 39,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "nifzlTLaeWxTD\n0\n",
        "output": "nifzltlaewxtd\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1307,
        "task_id": 529,
        "test_case_id": 40,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "LiqWMLEULRhW\n1\n",
        "output": "liqwmleulrhw\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1308,
        "task_id": 529,
        "test_case_id": 43,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "MDJivQRiOIVRcCdkSuUlNbMEOkIVJRMTAnHbkVaOmOblLfignh\n25\n",
        "output": "MDJIVQRIOIVRCCDKSUULNBMEOKIVJRMTANHBKVAOMOBLLFIGNH\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1309,
        "task_id": 529,
        "test_case_id": 44,
        "question": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nOutput the required string.\n\n\n-----Examples-----\nInput\nAprilFool\n14\n\nOutput\nAprILFooL",
        "solutions": "[\"t, p = input().lower(), 'abcdefghijklmnopqrstuvwxyz|'[int(input())]\\nprint(''.join(i.upper() if i < p else i for i in t))\", \"_27 = input()\\n_16 = int(input())\\n_27 = _27.lower()\\n_4 = \\\"\\\"\\nfor _26 in range(len(_27)):\\n    _19 = _27[_26]\\n    if ord(_19) < _16 + 97:\\n        _4 = _4 + _19.upper()\\n    else:\\n        _4 = _4 + _19.lower()\\nprint(_4)\\n\", \"s, n = input(), int(input())\\n\\nres = ''\\n\\nfor x in s.lower():\\n    if ord(x) < n + 97: res += x.upper()\\n    else: res += x\\n\\nprint(res)\", \"s, x = input().lower(), int(input())\\nprint(''.join(ch.upper() if ord(ch) < x + 97 else ch.lower() for ch in s))\", \"text = input().lower()\\ncaps = int(input())+97\\nfor letter in text:\\n\\tprint(letter.upper(), end='')if letter < chr(caps) else print(letter, end='')\\nprint()\", \"s=input();s=s.lower();s=(' '.join(s)).split();n=int(input())\\nfor i in range(0,len(s)):\\n    if n+96>=ord(s[i]):\\n        s[i]=chr(ord(s[i])-32)\\nfor j in range(0,len(s)):\\n    print(s[j],end='')\\n\", \"s = input()\\nn = int(input())\\nd = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\\ne = 'abcdefghijklmnopqrstuvwxyz'\\nfor i in s:\\n    z = ord(i) - ord('a') if ord('a') <= ord(i) and ord(i) <= ord('z') else ord(i) - ord('A')\\n    if z < n:\\n        print(d[z], end = '')\\n    else:\\n        print(e[z], end = '')\", \"a, s = input().lower(), int(input())\\nprint(''.join(t.upper() if ord(t) < s + 97 else t.lower() for t in a))\", \"a = list(input().lower())\\nb = int(input())\\nfor i in range(len(a)):\\n\\tif ord(a[i]) - ord('a') < b:\\n\\t\\ta[i] = a[i].upper()\\nprint(''.join(a))\", \"s = input().lower()\\nk = int(input())\\nresult = ''.join(c.upper()\\n                 if ord(c) < k+97\\n                 else c.lower()\\n                 for c in s)\\nprint(result)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\", \"x = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\nX = \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\\\"\\nz = list(input())\\nn = int(input())\\nfor i in range(len(z)):\\n    if(z[i] in x):\\n        k = x.index(z[i]) + 1\\n    else:\\n        k = X.index(z[i]) + 1\\n    if(k <= n):\\n        z[i] = z[i].upper()\\n    else:\\n        z[i] = z[i].lower()\\nans = \\\"\\\".join(z)\\nprint(ans)\", \"s=input()\\nn=int(input())\\ns=s.lower()\\nans=\\\"\\\"\\nfor i in range(len(s)):\\n    x=s[i]\\n    if(ord(x)<n+97):\\n        ans+=x.upper()\\n    else:\\n        ans+=x.lower()\\nprint(ans)\\n\", \"a = input().lower()\\nnum = int(input())\\nc = \\\"\\\"\\nfor i in a:\\n    if ord(i) < num+97:\\n        c += i.upper()\\n    else:\\n        c += i.lower()\\nprint(c)\\n\"]",
        "difficulty": "interview",
        "input": "pFgLGSkFnGpNKALeDPGlciUNTTlCtAPlFhaIRutCFaFo\n24\n",
        "output": "PFGLGSKFNGPNKALEDPGLCIUNTTLCTAPLFHAIRUTCFAFO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/D"
    },
    {
        "id": 1310,
        "task_id": 621,
        "test_case_id": 1,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n",
        "output": "3\n5 3 3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1311,
        "task_id": 621,
        "test_case_id": 2,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "5\n0 -1 100 -1 0\n",
        "output": "1\n5 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1312,
        "task_id": 621,
        "test_case_id": 3,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "1\n0\n",
        "output": "1\n1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1313,
        "task_id": 621,
        "test_case_id": 4,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "1\n-1\n",
        "output": "1\n1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1314,
        "task_id": 621,
        "test_case_id": 5,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "2\n0 0\n",
        "output": "1\n2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1315,
        "task_id": 621,
        "test_case_id": 6,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "2\n-2 2\n",
        "output": "1\n2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1316,
        "task_id": 621,
        "test_case_id": 7,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "2\n-2 -1\n",
        "output": "1\n2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1317,
        "task_id": 621,
        "test_case_id": 8,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "12\n1 -12 -5 -8 0 -8 -1 -1 -6 12 -9 12\n",
        "output": "4\n3 3 2 4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1318,
        "task_id": 621,
        "test_case_id": 9,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n1 2 0 3\n",
        "output": "1\n4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1319,
        "task_id": 621,
        "test_case_id": 10,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n4 -3 3 3\n",
        "output": "1\n4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1320,
        "task_id": 621,
        "test_case_id": 11,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n0 -3 4 -3\n",
        "output": "1\n4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1321,
        "task_id": 621,
        "test_case_id": 12,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n-3 -2 4 -3\n",
        "output": "2\n1 3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1322,
        "task_id": 621,
        "test_case_id": 13,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n-3 -2 -1 -4\n",
        "output": "2\n2 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1323,
        "task_id": 621,
        "test_case_id": 14,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "5\n-2 -2 4 0 -1\n",
        "output": "2\n1 4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1324,
        "task_id": 621,
        "test_case_id": 15,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "5\n-5 -3 -1 2 -1\n",
        "output": "2\n2 3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1325,
        "task_id": 621,
        "test_case_id": 16,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "5\n-3 -2 -3 -2 -3\n",
        "output": "3\n1 2 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1326,
        "task_id": 621,
        "test_case_id": 17,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "10\n0 5 2 3 10 9 4 9 9 3\n",
        "output": "1\n10 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1327,
        "task_id": 621,
        "test_case_id": 18,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "10\n10 2 1 2 9 10 7 4 -4 5\n",
        "output": "1\n10 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1328,
        "task_id": 621,
        "test_case_id": 19,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "10\n1 -3 1 10 -7 -6 7 0 -5 3\n",
        "output": "2\n5 5 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1329,
        "task_id": 621,
        "test_case_id": 20,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "10\n6 5 -10 -4 -3 -7 5 -2 -6 -10\n",
        "output": "4\n3 2 3 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1330,
        "task_id": 621,
        "test_case_id": 21,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "10\n-2 -4 -1 -6 -5 -5 -7 0 -7 -8\n",
        "output": "5\n1 2 2 2 3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1331,
        "task_id": 621,
        "test_case_id": 22,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n1 2 3 4\n",
        "output": "1\n4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1332,
        "task_id": 621,
        "test_case_id": 23,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n1 2 3 -4\n",
        "output": "1\n4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1333,
        "task_id": 621,
        "test_case_id": 24,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n-4 2 1 2\n",
        "output": "1\n4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1334,
        "task_id": 621,
        "test_case_id": 25,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "1\n-1\n",
        "output": "1\n1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1335,
        "task_id": 621,
        "test_case_id": 26,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "2\n2 -1\n",
        "output": "1\n2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1336,
        "task_id": 621,
        "test_case_id": 27,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "2\n-100 100\n",
        "output": "1\n2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1337,
        "task_id": 621,
        "test_case_id": 28,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "3\n-100 0 -100\n",
        "output": "1\n3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1338,
        "task_id": 621,
        "test_case_id": 29,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "5\n1 2 3 -1 -1\n",
        "output": "1\n5 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1339,
        "task_id": 621,
        "test_case_id": 30,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "5\n-1 -1 2 3 4\n",
        "output": "1\n5 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1340,
        "task_id": 621,
        "test_case_id": 31,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "3\n-3 -4 -5\n",
        "output": "2\n1 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1341,
        "task_id": 621,
        "test_case_id": 32,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n-3 -4 1 -3\n",
        "output": "2\n1 3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1342,
        "task_id": 621,
        "test_case_id": 33,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "1\n-1\n",
        "output": "1\n1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1343,
        "task_id": 621,
        "test_case_id": 34,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "2\n-1 0\n",
        "output": "1\n2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1344,
        "task_id": 621,
        "test_case_id": 35,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "4\n0 0 0 0\n",
        "output": "1\n4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1345,
        "task_id": 621,
        "test_case_id": 36,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "3\n-1 -1 -1\n",
        "output": "2\n1 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1346,
        "task_id": 621,
        "test_case_id": 37,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "6\n-1 -1 0 -1 -1 -1\n",
        "output": "3\n1 3 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1347,
        "task_id": 621,
        "test_case_id": 38,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "2\n0 0\n",
        "output": "1\n2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1348,
        "task_id": 621,
        "test_case_id": 39,
        "question": "Polycarpus has been working in the analytic department of the \"F.R.A.U.D.\" company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day.\n\nPolycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.\n\nIt is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible.\n\nTherefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.\n\nWrite a program that, given sequence a_{i}, will print the minimum number of folders.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}.\n\n\n-----Output-----\n\nPrint an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder.\n\nIf there are multiple ways to sort the reports into k days, print any of them.\n\n\n-----Examples-----\nInput\n11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\n\nOutput\n3\n5 3 3 \nInput\n5\n0 -1 100 -1 0\n\nOutput\n1\n5 \n\n\n-----Note-----\n\nHere goes a way to sort the reports from the first sample into three folders:  1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 \n\nIn the second sample you can put all five reports in one folder.",
        "solutions": "[\"import re\\nimport itertools\\nfrom collections import Counter\\n\\nclass Task:\\n    a = []\\n    answer = []\\n\\t\\n    def getData(self):\\n        input()\\n        self.a = [int(x) for x in input().split(\\\" \\\")]\\n\\t\\n    def solve(self):\\n        currentFolderCounter = 0\\n        badDaysCounter = 0\\n        for x in self.a:\\n            if x >= 0:\\n                currentFolderCounter += 1\\n            elif badDaysCounter <= 1:\\n                currentFolderCounter += 1\\n                badDaysCounter += 1\\n            else:\\n                self.answer += [currentFolderCounter]\\n                currentFolderCounter = 1\\n                badDaysCounter = 1\\n        if currentFolderCounter > 0:\\n            self.answer += [currentFolderCounter]\\n\\n    def printAnswer(self):\\n        print(len(self.answer))\\n        print(re.sub('[\\\\[\\\\],]', '', str(self.answer)))\\n\\ntask = Task();\\ntask.getData();\\ntask.solve();\\ntask.printAnswer();\\n\", \"p, x, y, n, t = [], 0, 0, int(input()), list(map(int, input().split()))\\nfor i in range(n):\\n    if t[i] < 0: x += 1\\n    if x == 3:\\n        p.append(i - y)\\n        x = 1\\n        y = i\\n    \\np.append(n - y)\\nprint(len(p))\\nprint(' '.join(str(i) for i in p))\", \"def readln(): return tuple(map(int, input().split()))\\n\\nn, = readln()\\ncnt = al = 0\\nans = []\\nfor a in readln():\\n    if cnt == 2 and a < 0:\\n        ans.append(al)\\n        cnt = al = 0\\n    al += 1\\n    cnt += a < 0\\nans.append(al)\\nprint(len(ans))\\nprint(*ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = 0\\nwhile cur < n:\\n    cnt = 0\\n    size = 0\\n    while cur < n and cnt < 3:\\n        if a[cur] < 0:\\n            cnt += 1\\n        cur += 1\\n        size += 1\\n    if cnt == 3:\\n        cur -= 1\\n        size -= 1\\n    b.append(size)\\n\\nprint(len(b))\\nprint(\\\" \\\".join(map(str, b)))\", \"__author__ = 'Alex'\\nn = int(input())\\na = [int(i) for i in input().split()]\\ncnt1, cnt2 = [0] * 2\\nans = []\\nfor i in a:\\n    if i < 0:\\n        if cnt2 > 1:\\n            ans.append(cnt1)\\n            cnt1 = cnt2 = 0\\n        cnt2 += 1\\n    cnt1 += 1\\nif cnt1 > 0:\\n    ans.append(cnt1)\\nprint(len(ans))\\nprint(' '.join([str(i) for i in ans]))\", \"\\n\\nimport sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nres = 0\\nv = []\\np = 0\\nk = 0\\nfor i in an:\\n\\tif(i < 0):\\n\\t\\tif(p < 2):\\n\\t\\t\\tp += 1\\n\\t\\telse:\\n\\t\\t\\tp = 1\\n\\t\\t\\tv.append(str(k))\\n\\t\\t\\tres += 1\\n\\t\\t\\tk = 0\\n\\tk += 1\\n\\t\\nif(k != 0):\\n\\tres += 1\\n\\tv.append(str(k))\\n\\t\\nprint(res)\\nprint(\\\" \\\".join(v))\\n\", \"n = int(input())\\nfolders = []\\nloss_count = 0\\nday_count = 0\\nfor x in map(int, input().split()):\\n    if x < 0:\\n        if loss_count == 2:\\n            folders.append(day_count)\\n            loss_count = 1\\n            day_count = 0\\n        else:\\n            loss_count += 1\\n    day_count += 1\\nfolders.append(day_count)\\nprint(len(folders))\\nprint(' '.join(map(str, folders)))\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nfolders = [0]\\ncur = 0\\nloss = 0\\nfor i in range(n):\\n    if l[i] < 0 :\\n        loss += 1\\n        if loss == 3 :\\n            folders.append(0)\\n            loss = 1\\n            cur += 1\\n    #print(i,l[i],cur,loss)\\n    folders[cur] += 1\\n\\nprint(len(folders))\\nprint(*folders)\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = input()\\ns = input().split(\\\" \\\")\\nrugi, jumlah, berkas = 0, 0, []\\nfor j, i in enumerate(s):\\n    if int(i) < 0:\\n        rugi += 1\\n        if rugi == 3:\\n            rugi = 1\\n            berkas.append(str(jumlah))\\n            jumlah = 1\\n        else:\\n            jumlah += 1\\n    else:\\n        jumlah += 1\\n    if j == len(s)-1:\\n        berkas.append(str(jumlah))\\nprint(len(berkas), \\\" \\\".join(berkas), sep='\\\\n')\\n\", \"n = int(input())\\nprofit = [int(x) for x in input().split(' ')]\\n\\ndaysInFolders = [0]\\nfolders = 1\\nbadDays = 0\\n\\nfor elem in profit:\\n\\tif elem < 0:\\n\\t\\tif badDays >= 0 and badDays < 2:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\t\\telif badDays == 2:\\n\\t\\t\\tdaysInFolders.append(1)\\n\\t\\t\\tfolders += 1\\n\\t\\t\\tbadDays = 1\\n\\t\\telse:\\n\\t\\t\\tbadDays += 1\\n\\t\\t\\tdaysInFolders[-1] += 1\\n\\telse:\\n\\t\\tdaysInFolders[-1] += 1\\n\\t\\t\\nprint(folders)\\nprint(' '.join([str(x) for x in daysInFolders]))\\n\", \"N = int( input() )\\nA = list( map( int, input().split() ) )\\n\\nans = []\\nptr = 0\\nwhile ptr < N:\\n  s = 0\\n  nxt = ptr\\n  while nxt < N and s + ( A[ nxt ] < 0 ) <= 2:\\n    s += ( A[ nxt ] < 0 )\\n    nxt += 1\\n  ans.append( nxt - ptr )\\n  ptr = nxt\\n\\nprint( len( ans ) )\\nprint( * ans )\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\ncounter_negative = 0\\ncurrent = 0\\n\\nres = []\\n\\nfor a in arr:\\n    current += 1\\n    if a < 0:\\n        counter_negative += 1\\n\\n    if counter_negative == 3:\\n        res.append(current-1)\\n        current = 1\\n        counter_negative = 1\\nres.append(current)\\n\\nprint(len(res))\\nfor r in res:\\n    print(r, end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"P=print\\nI=input\\nI()\\na=b=0\\nt=[]\\nfor x in map(int,I().split()):\\n\\tif x<0:\\n\\t\\tif b==2:t+=[a];b=1;a=0\\n\\t\\telse:b+=1\\n\\ta+=1\\nif a:t+=[a]\\nP(len(t))\\nfor x in t:P(x,end=' ')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nfails = 0\\nans = []\\nfor i in range(n):\\n    if a[i] < 0 and fails == 2:\\n        ans.append(k)\\n        k = 1\\n        fails = 1\\n    else:\\n        k += 1\\n        fails += (a[i] < 0)\\nif sum(ans) < n:\\n    ans.append(k)\\nprint(len(ans))\\nprint(\\\" \\\".join(map(str, ans)))\"]",
        "difficulty": "interview",
        "input": "6\n0 0 -1 -1 -1 0\n",
        "output": "2\n3 3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/250/A"
    },
    {
        "id": 1349,
        "task_id": 638,
        "test_case_id": 1,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "7 15\n1 2 3 4 5 6 7\n",
        "output": "0 0 0 0 0 2 3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1350,
        "task_id": 638,
        "test_case_id": 2,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "5 100\n80 40 40 40 60\n",
        "output": "0 1 1 2 3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1351,
        "task_id": 638,
        "test_case_id": 3,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "1 1\n1\n",
        "output": "0 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1352,
        "task_id": 638,
        "test_case_id": 4,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "1 100\n99\n",
        "output": "0 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1353,
        "task_id": 638,
        "test_case_id": 5,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "1 100\n100\n",
        "output": "0 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1354,
        "task_id": 638,
        "test_case_id": 6,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "2 100\n100 100\n",
        "output": "0 1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1355,
        "task_id": 638,
        "test_case_id": 7,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "2 100\n1 100\n",
        "output": "0 1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1356,
        "task_id": 638,
        "test_case_id": 8,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "2 100\n1 99\n",
        "output": "0 0 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1357,
        "task_id": 638,
        "test_case_id": 9,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "3 100\n34 34 34\n",
        "output": "0 0 1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1358,
        "task_id": 638,
        "test_case_id": 10,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "10 50\n9 9 9 9 9 9 9 9 9 9\n",
        "output": "0 0 0 0 0 1 2 3 4 5 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1359,
        "task_id": 638,
        "test_case_id": 11,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "10 50\n10 10 10 10 10 10 10 10 10 10\n",
        "output": "0 0 0 0 0 1 2 3 4 5 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1360,
        "task_id": 638,
        "test_case_id": 12,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "8 2\n1 1 1 1 1 1 1 1\n",
        "output": "0 0 1 2 3 4 5 6 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1361,
        "task_id": 638,
        "test_case_id": 13,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "9 14\n3 4 3 9 1 1 9 8 9\n",
        "output": "0 0 0 2 1 1 3 4 5 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1362,
        "task_id": 638,
        "test_case_id": 14,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "100 100\n55 70 81 73 51 6 75 45 85 33 61 98 63 11 59 1 8 14 28 78 74 44 80 7 69 7 5 90 73 43 78 64 64 43 92 59 70 80 19 33 39 31 70 38 85 24 23 86 79 98 56 92 63 92 4 36 8 79 74 2 81 54 13 69 44 49 63 17 76 78 99 42 36 47 71 19 90 9 58 83 53 27 2 35 51 65 59 90 51 74 87 84 48 98 44 84 100 84 93 73\n",
        "output": "0 1 2 3 4 4 5 6 7 7 8 11 11 10 12 11 12 12 13 16 16 16 19 17 20 18 18 25 23 22 26 25 26 26 32 29 31 33 30 31 32 33 37 35 41 37 38 44 44 48 44 49 46 51 45 46 46 53 53 48 55 53 51 57 55 56 59 56 63 64 69 62 62 64 68 64 73 65 70 75 72 70 69 72 75 77 78 83 79 83 86 86 82 92 84 90 96 92 95 92 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1363,
        "task_id": 638,
        "test_case_id": 15,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100\n",
        "output": "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1364,
        "task_id": 638,
        "test_case_id": 16,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "10 13\n3 5 9 6 7 3 8 2 3 2\n",
        "output": "0 0 1 2 3 3 5 4 5 5 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1365,
        "task_id": 638,
        "test_case_id": 17,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "6 10\n5 4 8 1 7 5\n",
        "output": "0 0 2 1 3 3 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1366,
        "task_id": 638,
        "test_case_id": 18,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "9 10\n5 2 6 2 9 7 4 6 6\n",
        "output": "0 0 1 1 4 4 4 5 6 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1367,
        "task_id": 638,
        "test_case_id": 19,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "9 11\n3 8 10 2 2 9 2 1 9\n",
        "output": "0 0 2 2 2 4 3 3 7 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1368,
        "task_id": 638,
        "test_case_id": 20,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "10 10\n1 4 5 3 8 7 7 2 1 6\n",
        "output": "0 0 0 1 3 4 5 4 5 6 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1369,
        "task_id": 638,
        "test_case_id": 21,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "9 10\n8 2 2 1 3 7 1 7 9\n",
        "output": "0 0 1 1 1 3 2 5 7 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1370,
        "task_id": 638,
        "test_case_id": 22,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "100 2\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1371,
        "task_id": 638,
        "test_case_id": 23,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "10 50\n10 2 10 8 4 2 10 6 10 1\n",
        "output": "0 0 0 0 0 0 0 1 2 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1372,
        "task_id": 638,
        "test_case_id": 24,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "11 55\n3 3 7 7 10 9 8 7 7 7 6\n",
        "output": "0 0 0 0 0 0 0 0 1 2 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1373,
        "task_id": 638,
        "test_case_id": 25,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "12 60\n2 8 9 10 7 9 2 5 4 9 6 3\n",
        "output": "0 0 0 0 0 0 0 0 0 1 2 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1374,
        "task_id": 638,
        "test_case_id": 26,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "13 65\n9 4 10 7 3 10 10 6 8 9 6 9 7\n",
        "output": "0 0 0 0 0 0 0 0 1 2 2 3 4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1375,
        "task_id": 638,
        "test_case_id": 27,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "14 70\n2 8 10 1 10 6 10 6 9 4 10 10 10 9\n",
        "output": "0 0 0 0 0 0 0 0 0 0 1 2 3 4 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1376,
        "task_id": 638,
        "test_case_id": 28,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "15 75\n9 6 5 9 2 6 2 7 2 3 9 2 10 5 4\n",
        "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1377,
        "task_id": 638,
        "test_case_id": 29,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "16 80\n8 1 4 3 10 8 2 2 3 6 3 10 3 1 5 10\n",
        "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1378,
        "task_id": 638,
        "test_case_id": 30,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "17 85\n1 2 10 3 10 9 1 6 6 5 9 2 10 1 3 3 7\n",
        "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1379,
        "task_id": 638,
        "test_case_id": 31,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "18 90\n8 7 9 7 7 5 7 5 7 8 1 9 7 9 8 7 8 10\n",
        "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1380,
        "task_id": 638,
        "test_case_id": 32,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "19 95\n1 9 5 5 9 8 9 6 3 7 1 1 6 7 4 4 4 2 10\n",
        "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1381,
        "task_id": 638,
        "test_case_id": 33,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "20 100\n6 7 6 3 1 3 2 5 7 3 9 10 1 10 7 1 9 1 2 7\n",
        "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1382,
        "task_id": 638,
        "test_case_id": 34,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "100 100\n1 2 3 5 5 7 7 8 8 10 10 11 14 14 14 16 18 19 20 20 21 22 22 22 22 23 23 23 24 27 27 29 30 32 35 38 38 39 42 43 45 45 45 45 46 48 49 49 50 50 52 54 56 56 57 57 57 60 62 63 63 65 65 65 65 68 71 72 72 73 73 73 76 77 78 78 79 82 84 84 85 86 86 87 88 89 89 90 90 90 90 92 92 95 95 95 97 98 98 100\n",
        "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18 19 20 21 22 24 25 26 27 28 29 31 32 33 34 35 36 37 38 39 40 41 42 44 45 46 47 48 49 50 52 53 54 55 56 57 58 60 61 62 63 64 65 66 67 69 70 71 72 73 74 76 77 78 79 80 81 82 84 85 86 87 88 89 91 92 93 94 96 97 99 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1383,
        "task_id": 638,
        "test_case_id": 35,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "100 100\n100 99 99 98 97 96 96 95 95 90 90 89 89 85 85 84 84 82 80 80 79 79 79 76 75 75 74 73 73 73 72 72 70 69 67 66 65 65 64 64 62 61 60 60 59 58 58 55 54 54 53 53 49 48 44 38 37 36 36 34 32 32 31 28 27 27 27 25 23 21 20 19 19 19 19 19 18 18 17 17 16 16 15 13 12 11 7 7 7 6 5 5 4 2 2 2 2 2 1 1\n",
        "output": "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 52 53 54 55 56 57 58 59 59 60 61 62 63 64 65 66 66 67 68 69 69 70 71 72 73 74 75 76 77 77 78 79 79 80 80 81 81 81 82 82 82 82 82 82 83 83 83 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1384,
        "task_id": 638,
        "test_case_id": 36,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "100 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1385,
        "task_id": 638,
        "test_case_id": 37,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "100 99\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1386,
        "task_id": 638,
        "test_case_id": 38,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "100 100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1387,
        "task_id": 638,
        "test_case_id": 39,
        "question": "The only difference between easy and hard versions is constraints.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. \n\nStudents take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.\n\nThe duration of the whole exam for all students is $M$ minutes ($\\max t_i \\le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.\n\nFor each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.\n\nFor each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.\n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $M$ ($1 \\le n \\le 100$, $1 \\le M \\le 100$) — the number of students and the total duration of the exam in minutes, respectively.\n\nThe second line of the input contains $n$ integers $t_i$ ($1 \\le t_i \\le 100$) — time in minutes that $i$-th student spends to answer to a ticket.\n\nIt's guaranteed that all values of $t_i$ are not greater than $M$.\n\n\n-----Output-----\n\nPrint $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.\n\n\n-----Examples-----\nInput\n7 15\n1 2 3 4 5 6 7\n\nOutput\n0 0 0 0 0 2 3 \nInput\n5 100\n80 40 40 40 60\n\nOutput\n0 1 1 2 3 \n\n\n-----Note-----\n\nThe explanation for the example 1.\n\nPlease note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.\n\nIn order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).\n\nIn order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).",
        "solutions": "[\"from sys import stdin\\nn,m=list(map(int,stdin.readline().strip().split()))\\ns=list(map(int,stdin.readline().strip().split()))\\nans=[0 for i in range(n)]\\nsm=[0 for i in range(n)]\\nsm1=[0 for i in range(n)]\\nfor i in range(n):\\n    if i==0:\\n        sm[i]=s[i]\\n    else:\\n        sm[i]=sm[i-1]+s[i]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        sm1[i]=s[i]\\n    else:\\n        sm1[i]=sm1[i+1]+s[i]\\nfor i in range(n):\\n    if sm[i]<=m:\\n        continue\\n    x=sm[i]\\n    s2=s[0:i]\\n    s2.sort()\\n    r=0\\n    while x>m:\\n        x-=s2[-1]\\n        s2.pop()\\n        r+=1\\n    ans[i]=r\\nprint(*ans)\\n        \\n\", \"#!/usr/bin/env python\\nn, M = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    ti = sorted(t[:i])\\n    Mi = M - t[i]\\n    s = 0\\n    j = 0\\n    while j < i:\\n        s += ti[j]\\n        if s > Mi:\\n            break\\n        j += 1\\n    a.append(i - j)\\nprint(*a)\\n\", \"\\\"\\\"\\\"Sorted List\\n==============\\n:doc:`Sorted Containers<index>` is an Apache2 licensed Python sorted\\ncollections library, written in pure-Python, and fast as C-extensions. The\\n:doc:`introduction<introduction>` is the best way to get started.\\nSorted list implementations:\\n.. currentmodule:: sortedcontainers\\n* :class:`SortedList`\\n* :class:`SortedKeyList`\\n\\\"\\\"\\\"\\n# pylint: disable=too-many-lines\\n\\n\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Sequence, MutableSequence\\nfrom itertools import chain, repeat, starmap\\nfrom math import log\\nfrom operator import add, eq, ne, gt, ge, lt, le, iadd\\nfrom textwrap import dedent\\n\\n###############################################################################\\n# BEGIN Python 2/3 Shims\\n###############################################################################\\n\\nfrom functools import wraps\\nfrom sys import hexversion\\n\\nif hexversion < 0x03000000:\\n      # pylint: disable=redefined-builtin\\n      # pylint: disable=redefined-builtin\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\nelse:\\n    from functools import reduce\\n    try:\\n        from _thread import get_ident\\n    except ImportError:\\n        from _dummy_thread import get_ident\\n\\n\\ndef recursive_repr(fillvalue='...'):\\n    \\\"Decorator to make a repr function return fillvalue for a recursive call.\\\"\\n    # pylint: disable=missing-docstring\\n    # Copied from reprlib in Python 3\\n    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py\\n\\n    def decorating_function(user_function):\\n        repr_running = set()\\n\\n        @wraps(user_function)\\n        def wrapper(self):\\n            key = id(self), get_ident()\\n            if key in repr_running:\\n                return fillvalue\\n            repr_running.add(key)\\n            try:\\n                result = user_function(self)\\n            finally:\\n                repr_running.discard(key)\\n            return result\\n\\n        return wrapper\\n\\n    return decorating_function\\n\\n###############################################################################\\n# END Python 2/3 Shims\\n###############################################################################\\n\\n\\nclass SortedList(MutableSequence):\\n    \\\"\\\"\\\"Sorted list is a sorted mutable sequence.\\n    Sorted list values are maintained in sorted order.\\n    Sorted list values must be comparable. The total ordering of values must\\n    not change while they are stored in the sorted list.\\n    Methods for adding values:\\n    * :func:`SortedList.add`\\n    * :func:`SortedList.update`\\n    * :func:`SortedList.__add__`\\n    * :func:`SortedList.__iadd__`\\n    * :func:`SortedList.__mul__`\\n    * :func:`SortedList.__imul__`\\n    Methods for removing values:\\n    * :func:`SortedList.clear`\\n    * :func:`SortedList.discard`\\n    * :func:`SortedList.remove`\\n    * :func:`SortedList.pop`\\n    * :func:`SortedList.__delitem__`\\n    Methods for looking up values:\\n    * :func:`SortedList.bisect_left`\\n    * :func:`SortedList.bisect_right`\\n    * :func:`SortedList.count`\\n    * :func:`SortedList.index`\\n    * :func:`SortedList.__contains__`\\n    * :func:`SortedList.__getitem__`\\n    Methods for iterating values:\\n    * :func:`SortedList.irange`\\n    * :func:`SortedList.islice`\\n    * :func:`SortedList.__iter__`\\n    * :func:`SortedList.__reversed__`\\n    Methods for miscellany:\\n    * :func:`SortedList.copy`\\n    * :func:`SortedList.__len__`\\n    * :func:`SortedList.__repr__`\\n    * :func:`SortedList._check`\\n    * :func:`SortedList._reset`\\n    Sorted lists use lexicographical ordering semantics when compared to other\\n    sequences.\\n    Some methods of mutable sequences are not supported and will raise\\n    not-implemented error.\\n    \\\"\\\"\\\"\\n    DEFAULT_LOAD_FACTOR = 1000\\n\\n\\n    def __init__(self, iterable=None, key=None):\\n        \\\"\\\"\\\"Initialize sorted list instance.\\n        Optional `iterable` argument provides an initial iterable of values to\\n        initialize the sorted list.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList()\\n        >>> sl\\n        SortedList([])\\n        >>> sl = SortedList([3, 1, 2, 5, 4])\\n        >>> sl\\n        SortedList([1, 2, 3, 4, 5])\\n        :param iterable: initial values (optional)\\n        \\\"\\\"\\\"\\n        assert key is None\\n        self._len = 0\\n        self._load = self.DEFAULT_LOAD_FACTOR\\n        self._lists = []\\n        self._maxes = []\\n        self._index = []\\n        self._offset = 0\\n\\n        if iterable is not None:\\n            self._update(iterable)\\n\\n\\n    def __new__(cls, iterable=None, key=None):\\n        \\\"\\\"\\\"Create new sorted list or sorted-key list instance.\\n        Optional `key`-function argument will return an instance of subtype\\n        :class:`SortedKeyList`.\\n        >>> sl = SortedList()\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> sl = SortedList(key=lambda x: -x)\\n        >>> isinstance(sl, SortedList)\\n        True\\n        >>> isinstance(sl, SortedKeyList)\\n        True\\n        :param iterable: initial values (optional)\\n        :param key: function used to extract comparison key (optional)\\n        :return: sorted list or sorted-key list instance\\n        \\\"\\\"\\\"\\n        # pylint: disable=unused-argument\\n        if key is None:\\n            return object.__new__(cls)\\n        else:\\n            if cls is SortedList:\\n                return object.__new__(SortedKeyList)\\n            else:\\n                raise TypeError('inherit SortedKeyList for key argument')\\n\\n\\n    @property\\n    def key(self):\\n        \\\"\\\"\\\"Function used to extract comparison key from values.\\n        Sorted list compares values directly so the key function is none.\\n        \\\"\\\"\\\"\\n        return None\\n\\n\\n    def _reset(self, load):\\n        \\\"\\\"\\\"Reset sorted list load factor.\\n        The `load` specifies the load-factor of the list. The default load\\n        factor of 1000 works well for lists from tens to tens-of-millions of\\n        values. Good practice is to use a value that is the cube root of the\\n        list size. With billions of elements, the best load factor depends on\\n        your usage. It's best to leave the load factor at the default until you\\n        start benchmarking.\\n        See :doc:`implementation` and :doc:`performance-scale` for more\\n        information.\\n        Runtime complexity: `O(n)`\\n        :param int load: load-factor for sorted list sublists\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        self._clear()\\n        self._load = load\\n        self._update(values)\\n\\n\\n    def clear(self):\\n        \\\"\\\"\\\"Remove all values from sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        self._len = 0\\n        del self._lists[:]\\n        del self._maxes[:]\\n        del self._index[:]\\n        self._offset = 0\\n\\n    _clear = clear\\n\\n\\n    def add(self, value):\\n        \\\"\\\"\\\"Add `value` to sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.add(3)\\n        >>> sl.add(1)\\n        >>> sl.add(2)\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param value: value to add to sorted list\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n\\n        if _maxes:\\n            pos = bisect_right(_maxes, value)\\n\\n            if pos == len(_maxes):\\n                pos -= 1\\n                _lists[pos].append(value)\\n                _maxes[pos] = value\\n            else:\\n                insort(_lists[pos], value)\\n\\n            self._expand(pos)\\n        else:\\n            _lists.append([value])\\n            _maxes.append(value)\\n\\n        self._len += 1\\n\\n\\n    def _expand(self, pos):\\n        \\\"\\\"\\\"Split sublists with length greater than double the load-factor.\\n        Updates the index when the sublist length is less than double the load\\n        level. This requires incrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        \\\"\\\"\\\"\\n        _load = self._load\\n        _lists = self._lists\\n        _index = self._index\\n\\n        if len(_lists[pos]) > (_load << 1):\\n            _maxes = self._maxes\\n\\n            _lists_pos = _lists[pos]\\n            half = _lists_pos[_load:]\\n            del _lists_pos[_load:]\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            _lists.insert(pos + 1, half)\\n            _maxes.insert(pos + 1, half[-1])\\n\\n            del _index[:]\\n        else:\\n            if _index:\\n                child = self._offset + pos\\n                while child:\\n                    _index[child] += 1\\n                    child = (child - 1) >> 1\\n                _index[0] += 1\\n\\n\\n    def update(self, iterable):\\n        \\\"\\\"\\\"Update sorted list by adding all values from `iterable`.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList()\\n        >>> sl.update([3, 1, 2])\\n        >>> sl\\n        SortedList([1, 2, 3])\\n        :param iterable: iterable of values to add\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        values = sorted(iterable)\\n\\n        if _maxes:\\n            if len(values) * 4 >= self._len:\\n                values.extend(chain.from_iterable(_lists))\\n                values.sort()\\n                self._clear()\\n            else:\\n                _add = self.add\\n                for val in values:\\n                    _add(val)\\n                return\\n\\n        _load = self._load\\n        _lists.extend(values[pos:(pos + _load)]\\n                      for pos in range(0, len(values), _load))\\n        _maxes.extend(sublist[-1] for sublist in _lists)\\n        self._len = len(values)\\n        del self._index[:]\\n\\n    _update = update\\n\\n\\n    def __contains__(self, value):\\n        \\\"\\\"\\\"Return true if `value` is an element of the sorted list.\\n        ``sl.__contains__(value)`` <==> ``value in sl``\\n        Runtime complexity: `O(log(n))`\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> 3 in sl\\n        True\\n        :param value: search for value in sorted list\\n        :return: true if `value` in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return False\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return False\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        return _lists[pos][idx] == value\\n\\n\\n    def discard(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list if it is a member.\\n        If `value` is not a member, do nothing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.discard(5)\\n        >>> sl.discard(0)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        :param value: `value` to discard from sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n\\n\\n    def remove(self, value):\\n        \\\"\\\"\\\"Remove `value` from sorted list; `value` must be a member.\\n        If `value` is not a member, raise ValueError.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 3, 4, 5])\\n        >>> sl.remove(5)\\n        >>> sl == [1, 2, 3, 4]\\n        True\\n        >>> sl.remove(0)\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 0 not in list\\n        :param value: `value` to remove from sorted list\\n        :raises ValueError: if `value` is not in sorted list\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx = bisect_left(_lists[pos], value)\\n\\n        if _lists[pos][idx] == value:\\n            self._delete(pos, idx)\\n        else:\\n            raise ValueError('{0!r} not in list'.format(value))\\n\\n\\n    def _delete(self, pos, idx):\\n        \\\"\\\"\\\"Delete value at the given `(pos, idx)`.\\n        Combines lists that are less than half the load level.\\n        Updates the index when the sublist length is more than half the load\\n        level. This requires decrementing the nodes in a traversal from the\\n        leaf node to the root. For an example traversal see\\n        ``SortedList._loc``.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n        _maxes = self._maxes\\n        _index = self._index\\n\\n        _lists_pos = _lists[pos]\\n\\n        del _lists_pos[idx]\\n        self._len -= 1\\n\\n        len_lists_pos = len(_lists_pos)\\n\\n        if len_lists_pos > (self._load >> 1):\\n            _maxes[pos] = _lists_pos[-1]\\n\\n            if _index:\\n                child = self._offset + pos\\n                while child > 0:\\n                    _index[child] -= 1\\n                    child = (child - 1) >> 1\\n                _index[0] -= 1\\n        elif len(_lists) > 1:\\n            if not pos:\\n                pos += 1\\n\\n            prev = pos - 1\\n            _lists[prev].extend(_lists[pos])\\n            _maxes[prev] = _lists[prev][-1]\\n\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n            self._expand(prev)\\n        elif len_lists_pos:\\n            _maxes[pos] = _lists_pos[-1]\\n        else:\\n            del _lists[pos]\\n            del _maxes[pos]\\n            del _index[:]\\n\\n\\n    def _loc(self, pos, idx):\\n        \\\"\\\"\\\"Convert an index pair (lists index, sublist index) into a single\\n        index number that corresponds to the position of the value in the\\n        sorted list.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree from a leaf node to the root. The\\n        parent of each node is easily computable at ``(pos - 1) // 2``.\\n        Left-child nodes are always at odd indices and right-child nodes are\\n        always at even indices.\\n        When traversing up from a right-child node, increment the total by the\\n        left-child node.\\n        The final index is the sum from traversal and the index in the sublist.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Converting an index pair (2, 3) into a single index involves iterating\\n        like so:\\n        1. Starting at the leaf node: offset + alpha = 3 + 2 = 5. We identify\\n           the node as a left-child node. At such nodes, we simply traverse to\\n           the parent.\\n        2. At node 9, position 2, we recognize the node as a right-child node\\n           and accumulate the left-child in our total. Total is now 5 and we\\n           traverse to the parent at position 0.\\n        3. Iteration ends at the root.\\n        The index is then the sum of the total and sublist index: 5 + 3 = 8.\\n        :param int pos: lists index\\n        :param int idx: sublist index\\n        :return: index in sorted list\\n        \\\"\\\"\\\"\\n        if not pos:\\n            return idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        total = 0\\n\\n        # Increment pos to point in the index to len(self._lists[pos]).\\n\\n        pos += self._offset\\n\\n        # Iterate until reaching the root of the index tree at pos = 0.\\n\\n        while pos:\\n\\n            # Right-child nodes are at odd indices. At such indices\\n            # account the total below the left child node.\\n\\n            if not pos & 1:\\n                total += _index[pos - 1]\\n\\n            # Advance pos to the parent node.\\n\\n            pos = (pos - 1) >> 1\\n\\n        return total + idx\\n\\n\\n    def _pos(self, idx):\\n        \\\"\\\"\\\"Convert an index into an index pair (lists index, sublist index)\\n        that can be used to access the corresponding lists position.\\n        Many queries require the index be built. Details of the index are\\n        described in ``SortedList._build_index``.\\n        Indexing requires traversing the tree to a leaf node. Each node has two\\n        children which are easily computable. Given an index, pos, the\\n        left-child is at ``pos * 2 + 1`` and the right-child is at ``pos * 2 +\\n        2``.\\n        When the index is less than the left-child, traversal moves to the\\n        left sub-tree. Otherwise, the index is decremented by the left-child\\n        and traversal moves to the right sub-tree.\\n        At a child node, the indexing pair is computed from the relative\\n        position of the child node as compared with the offset and the remaining\\n        index.\\n        For example, using the index from ``SortedList._build_index``::\\n            _index = 14 5 9 3 2 4 5\\n            _offset = 3\\n        Tree::\\n                 14\\n              5      9\\n            3   2  4   5\\n        Indexing position 8 involves iterating like so:\\n        1. Starting at the root, position 0, 8 is compared with the left-child\\n           node (5) which it is greater than. When greater the index is\\n           decremented and the position is updated to the right child node.\\n        2. At node 9 with index 3, we again compare the index to the left-child\\n           node with value 4. Because the index is the less than the left-child\\n           node, we simply traverse to the left.\\n        3. At node 4 with index 3, we recognize that we are at a leaf node and\\n           stop iterating.\\n        4. To compute the sublist index, we subtract the offset from the index\\n           of the leaf node: 5 - 3 = 2. To compute the index in the sublist, we\\n           simply use the index remaining from iteration. In this case, 3.\\n        The final index pair from our example is (2, 3) which corresponds to\\n        index 8 in the sorted list.\\n        :param int idx: index in sorted list\\n        :return: (lists index, sublist index) pair\\n        \\\"\\\"\\\"\\n        if idx < 0:\\n            last_len = len(self._lists[-1])\\n\\n            if (-idx) <= last_len:\\n                return len(self._lists) - 1, last_len + idx\\n\\n            idx += self._len\\n\\n            if idx < 0:\\n                raise IndexError('list index out of range')\\n        elif idx >= self._len:\\n            raise IndexError('list index out of range')\\n\\n        if idx < len(self._lists[0]):\\n            return 0, idx\\n\\n        _index = self._index\\n\\n        if not _index:\\n            self._build_index()\\n\\n        pos = 0\\n        child = 1\\n        len_index = len(_index)\\n\\n        while child < len_index:\\n            index_child = _index[child]\\n\\n            if idx < index_child:\\n                pos = child\\n            else:\\n                idx -= index_child\\n                pos = child + 1\\n\\n            child = (pos << 1) + 1\\n\\n        return (pos - self._offset, idx)\\n\\n\\n    def _build_index(self):\\n        \\\"\\\"\\\"Build a positional index for indexing the sorted list.\\n        Indexes are represented as binary trees in a dense array notation\\n        similar to a binary heap.\\n        For example, given a lists representation storing integers::\\n            0: [1, 2, 3]\\n            1: [4, 5]\\n            2: [6, 7, 8, 9]\\n            3: [10, 11, 12, 13, 14]\\n        The first transformation maps the sub-lists by their length. The\\n        first row of the index is the length of the sub-lists::\\n            0: [3, 2, 4, 5]\\n        Each row after that is the sum of consecutive pairs of the previous\\n        row::\\n            1: [5, 9]\\n            2: [14]\\n        Finally, the index is built by concatenating these lists together::\\n            _index = [14, 5, 9, 3, 2, 4, 5]\\n        An offset storing the start of the first row is also stored::\\n            _offset = 3\\n        When built, the index can be used for efficient indexing into the list.\\n        See the comment and notes on ``SortedList._pos`` for details.\\n        \\\"\\\"\\\"\\n        row0 = list(map(len, self._lists))\\n\\n        if len(row0) == 1:\\n            self._index[:] = row0\\n            self._offset = 0\\n            return\\n\\n        head = iter(row0)\\n        tail = iter(head)\\n        row1 = list(starmap(add, list(zip(head, tail))))\\n\\n        if len(row0) & 1:\\n            row1.append(row0[-1])\\n\\n        if len(row1) == 1:\\n            self._index[:] = row1 + row0\\n            self._offset = 1\\n            return\\n\\n        size = 2 ** (int(log(len(row1) - 1, 2)) + 1)\\n        row1.extend(repeat(0, size - len(row1)))\\n        tree = [row0, row1]\\n\\n        while len(tree[-1]) > 1:\\n            head = iter(tree[-1])\\n            tail = iter(head)\\n            row = list(starmap(add, list(zip(head, tail))))\\n            tree.append(row)\\n\\n        reduce(iadd, reversed(tree), self._index)\\n        self._offset = size * 2 - 1\\n\\n\\n    def __delitem__(self, index):\\n        \\\"\\\"\\\"Remove value at `index` from sorted list.\\n        ``sl.__delitem__(index)`` <==> ``del sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> del sl[2]\\n        >>> sl\\n        SortedList(['a', 'b', 'd', 'e'])\\n        >>> del sl[:2]\\n        >>> sl\\n        SortedList(['d', 'e'])\\n        :param index: integer or slice for indexing\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return self._clear()\\n                elif self._len <= 8 * (stop - start):\\n                    values = self._getitem(slice(None, start))\\n                    if stop < self._len:\\n                        values += self._getitem(slice(stop, None))\\n                    self._clear()\\n                    return self._update(values)\\n\\n            indices = list(range(start, stop, step))\\n\\n            # Delete items from greatest index to least so\\n            # that the indices remain valid throughout iteration.\\n\\n            if step > 0:\\n                indices = reversed(indices)\\n\\n            _pos, _delete = self._pos, self._delete\\n\\n            for index in indices:\\n                pos, idx = _pos(index)\\n                _delete(pos, idx)\\n        else:\\n            pos, idx = self._pos(index)\\n            self._delete(pos, idx)\\n\\n\\n    def __getitem__(self, index):\\n        \\\"\\\"\\\"Lookup value at `index` in sorted list.\\n        ``sl.__getitem__(index)`` <==> ``sl[index]``\\n        Supports slicing.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl[1]\\n        'b'\\n        >>> sl[-1]\\n        'e'\\n        >>> sl[2:5]\\n        ['c', 'd', 'e']\\n        :param index: integer or slice for indexing\\n        :return: value or list of values\\n        :raises IndexError: if index out of range\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if isinstance(index, slice):\\n            start, stop, step = index.indices(self._len)\\n\\n            if step == 1 and start < stop:\\n                if start == 0 and stop == self._len:\\n                    return reduce(iadd, self._lists, [])\\n\\n                start_pos, start_idx = self._pos(start)\\n\\n                if stop == self._len:\\n                    stop_pos = len(_lists) - 1\\n                    stop_idx = len(_lists[stop_pos])\\n                else:\\n                    stop_pos, stop_idx = self._pos(stop)\\n\\n                if start_pos == stop_pos:\\n                    return _lists[start_pos][start_idx:stop_idx]\\n\\n                prefix = _lists[start_pos][start_idx:]\\n                middle = _lists[(start_pos + 1):stop_pos]\\n                result = reduce(iadd, middle, prefix)\\n                result += _lists[stop_pos][:stop_idx]\\n\\n                return result\\n\\n            if step == -1 and start > stop:\\n                result = self._getitem(slice(stop + 1, start + 1))\\n                result.reverse()\\n                return result\\n\\n            # Return a list because a negative step could\\n            # reverse the order of the items and this could\\n            # be the desired behavior.\\n\\n            indices = list(range(start, stop, step))\\n            return list(self._getitem(index) for index in indices)\\n        else:\\n            if self._len:\\n                if index == 0:\\n                    return _lists[0][0]\\n                elif index == -1:\\n                    return _lists[-1][-1]\\n            else:\\n                raise IndexError('list index out of range')\\n\\n            if 0 <= index < len(_lists[0]):\\n                return _lists[0][index]\\n\\n            len_last = len(_lists[-1])\\n\\n            if -len_last < index < 0:\\n                return _lists[-1][len_last + index]\\n\\n            pos, idx = self._pos(index)\\n            return _lists[pos][idx]\\n\\n    _getitem = __getitem__\\n\\n\\n    def __setitem__(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        ``sl.__setitem__(index, value)`` <==> ``sl[index] = value``\\n        :raises NotImplementedError: use ``del sl[index]`` and\\n            ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'\\n        raise NotImplementedError(message)\\n\\n\\n    def __iter__(self):\\n        \\\"\\\"\\\"Return an iterator over the sorted list.\\n        ``sl.__iter__()`` <==> ``iter(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(self._lists)\\n\\n\\n    def __reversed__(self):\\n        \\\"\\\"\\\"Return a reverse iterator over the sorted list.\\n        ``sl.__reversed__()`` <==> ``reversed(sl)``\\n        Iterating the sorted list while adding or deleting values may raise a\\n        :exc:`RuntimeError` or fail to iterate over all values.\\n        \\\"\\\"\\\"\\n        return chain.from_iterable(list(map(reversed, reversed(self._lists))))\\n\\n\\n    def reverse(self):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Sorted list maintains values in ascending sort order. Values may not be\\n        reversed in-place.\\n        Use ``reversed(sl)`` for an iterator over values in descending sort\\n        order.\\n        Implemented to override `MutableSequence.reverse` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``reversed(sl)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``reversed(sl)`` instead')\\n\\n\\n    def islice(self, start=None, stop=None, reverse=False):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list from `start` to `stop`.\\n        The `start` and `stop` index are treated inclusive and exclusive,\\n        respectively.\\n        Both `start` and `stop` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.islice(2, 6)\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param int start: start index (inclusive)\\n        :param int stop: stop index (exclusive)\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            return iter(())\\n\\n        start, stop, _ = slice(start, stop).indices(self._len)\\n\\n        if start >= stop:\\n            return iter(())\\n\\n        _pos = self._pos\\n\\n        min_pos, min_idx = _pos(start)\\n\\n        if stop == _len:\\n            max_pos = len(self._lists) - 1\\n            max_idx = len(self._lists[-1])\\n        else:\\n            max_pos, max_idx = _pos(stop)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):\\n        \\\"\\\"\\\"Return an iterator that slices sorted list using two index pairs.\\n        The index pairs are (min_pos, min_idx) and (max_pos, max_idx), the\\n        first inclusive and the latter exclusive. See `_pos` for details on how\\n        an index is converted to an index pair.\\n        When `reverse` is `True`, values are yielded from the iterator in\\n        reverse order.\\n        \\\"\\\"\\\"\\n        _lists = self._lists\\n\\n        if min_pos > max_pos:\\n            return iter(())\\n\\n        if min_pos == max_pos:\\n            if reverse:\\n                indices = reversed(list(range(min_idx, max_idx)))\\n                return list(map(_lists[min_pos].__getitem__, indices))\\n\\n            indices = list(range(min_idx, max_idx))\\n            return list(map(_lists[min_pos].__getitem__, indices))\\n\\n        next_pos = min_pos + 1\\n\\n        if next_pos == max_pos:\\n            if reverse:\\n                min_indices = list(range(min_idx, len(_lists[min_pos])))\\n                max_indices = list(range(max_idx))\\n                return chain(\\n                    list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                    list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n                )\\n\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[min_pos].__getitem__, min_indices)),\\n                list(map(_lists[max_pos].__getitem__, max_indices)),\\n            )\\n\\n        if reverse:\\n            min_indices = list(range(min_idx, len(_lists[min_pos])))\\n            sublist_indices = list(range(next_pos, max_pos))\\n            sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))\\n            max_indices = list(range(max_idx))\\n            return chain(\\n                list(map(_lists[max_pos].__getitem__, reversed(max_indices))),\\n                chain.from_iterable(list(map(reversed, sublists))),\\n                list(map(_lists[min_pos].__getitem__, reversed(min_indices))),\\n            )\\n\\n        min_indices = list(range(min_idx, len(_lists[min_pos])))\\n        sublist_indices = list(range(next_pos, max_pos))\\n        sublists = list(map(_lists.__getitem__, sublist_indices))\\n        max_indices = list(range(max_idx))\\n        return chain(\\n            list(map(_lists[min_pos].__getitem__, min_indices)),\\n            chain.from_iterable(sublists),\\n            list(map(_lists[max_pos].__getitem__, max_indices)),\\n        )\\n\\n\\n    def irange(self, minimum=None, maximum=None, inclusive=(True, True),\\n               reverse=False):\\n        \\\"\\\"\\\"Create an iterator of values between `minimum` and `maximum`.\\n        Both `minimum` and `maximum` default to `None` which is automatically\\n        inclusive of the beginning and end of the sorted list.\\n        The argument `inclusive` is a pair of booleans that indicates whether\\n        the minimum and maximum ought to be included in the range,\\n        respectively. The default is ``(True, True)`` such that the range is\\n        inclusive of both minimum and maximum.\\n        When `reverse` is `True` the values are yielded from the iterator in\\n        reverse order; `reverse` defaults to `False`.\\n        >>> sl = SortedList('abcdefghij')\\n        >>> it = sl.irange('c', 'f')\\n        >>> list(it)\\n        ['c', 'd', 'e', 'f']\\n        :param minimum: minimum value to start iterating\\n        :param maximum: maximum value to stop iterating\\n        :param inclusive: pair of booleans\\n        :param bool reverse: yield values in reverse order\\n        :return: iterator\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return iter(())\\n\\n        _lists = self._lists\\n\\n        # Calculate the minimum (pos, idx) pair. By default this location\\n        # will be inclusive in our calculation.\\n\\n        if minimum is None:\\n            min_pos = 0\\n            min_idx = 0\\n        else:\\n            if inclusive[0]:\\n                min_pos = bisect_left(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_left(_lists[min_pos], minimum)\\n            else:\\n                min_pos = bisect_right(_maxes, minimum)\\n\\n                if min_pos == len(_maxes):\\n                    return iter(())\\n\\n                min_idx = bisect_right(_lists[min_pos], minimum)\\n\\n        # Calculate the maximum (pos, idx) pair. By default this location\\n        # will be exclusive in our calculation.\\n\\n        if maximum is None:\\n            max_pos = len(_maxes) - 1\\n            max_idx = len(_lists[max_pos])\\n        else:\\n            if inclusive[1]:\\n                max_pos = bisect_right(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_right(_lists[max_pos], maximum)\\n            else:\\n                max_pos = bisect_left(_maxes, maximum)\\n\\n                if max_pos == len(_maxes):\\n                    max_pos -= 1\\n                    max_idx = len(_lists[max_pos])\\n                else:\\n                    max_idx = bisect_left(_lists[max_pos], maximum)\\n\\n        return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)\\n\\n\\n    def __len__(self):\\n        \\\"\\\"\\\"Return the size of the sorted list.\\n        ``sl.__len__()`` <==> ``len(sl)``\\n        :return: size of sorted list\\n        \\\"\\\"\\\"\\n        return self._len\\n\\n\\n    def bisect_left(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        If the `value` is already present, the insertion point will be before\\n        (to the left of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_left(12)\\n        2\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_left(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_left(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n\\n    def bisect_right(self, value):\\n        \\\"\\\"\\\"Return an index to insert `value` in the sorted list.\\n        Similar to `bisect_left`, but if `value` is already present, the\\n        insertion point with be after (to the right of) any existing values.\\n        Similar to the `bisect` module in the standard library.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([10, 11, 12, 13, 14])\\n        >>> sl.bisect_right(12)\\n        3\\n        :param value: insertion index of value in sorted list\\n        :return: index\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos = bisect_right(_maxes, value)\\n\\n        if pos == len(_maxes):\\n            return self._len\\n\\n        idx = bisect_right(self._lists[pos], value)\\n        return self._loc(pos, idx)\\n\\n    bisect = bisect_right\\n    _bisect_right = bisect_right\\n\\n\\n    def count(self, value):\\n        \\\"\\\"\\\"Return number of occurrences of `value` in the sorted list.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList([1, 2, 2, 3, 3, 3, 4, 4, 4, 4])\\n        >>> sl.count(3)\\n        3\\n        :param value: value to count in sorted list\\n        :return: count\\n        \\\"\\\"\\\"\\n        _maxes = self._maxes\\n\\n        if not _maxes:\\n            return 0\\n\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            return 0\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n        pos_right = bisect_right(_maxes, value)\\n\\n        if pos_right == len(_maxes):\\n            return self._len - self._loc(pos_left, idx_left)\\n\\n        idx_right = bisect_right(_lists[pos_right], value)\\n\\n        if pos_left == pos_right:\\n            return idx_right - idx_left\\n\\n        right = self._loc(pos_right, idx_right)\\n        left = self._loc(pos_left, idx_left)\\n        return right - left\\n\\n\\n    def copy(self):\\n        \\\"\\\"\\\"Return a shallow copy of the sorted list.\\n        Runtime complexity: `O(n)`\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        return self.__class__(self)\\n\\n    __copy__ = copy\\n\\n\\n    def append(self, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.append` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def extend(self, values):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        Implemented to override `MutableSequence.extend` which provides an\\n        erroneous default implementation.\\n        :raises NotImplementedError: use ``sl.update(values)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.update(values)`` instead')\\n\\n\\n    def insert(self, index, value):\\n        \\\"\\\"\\\"Raise not-implemented error.\\n        :raises NotImplementedError: use ``sl.add(value)`` instead\\n        \\\"\\\"\\\"\\n        raise NotImplementedError('use ``sl.add(value)`` instead')\\n\\n\\n    def pop(self, index=-1):\\n        \\\"\\\"\\\"Remove and return value at `index` in sorted list.\\n        Raise :exc:`IndexError` if the sorted list is empty or index is out of\\n        range.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.pop()\\n        'e'\\n        >>> sl.pop(2)\\n        'c'\\n        >>> sl\\n        SortedList(['a', 'b', 'd'])\\n        :param int index: index of value (default -1)\\n        :return: value\\n        :raises IndexError: if index is out of range\\n        \\\"\\\"\\\"\\n        if not self._len:\\n            raise IndexError('pop index out of range')\\n\\n        _lists = self._lists\\n\\n        if index == 0:\\n            val = _lists[0][0]\\n            self._delete(0, 0)\\n            return val\\n\\n        if index == -1:\\n            pos = len(_lists) - 1\\n            loc = len(_lists[pos]) - 1\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        if 0 <= index < len(_lists[0]):\\n            val = _lists[0][index]\\n            self._delete(0, index)\\n            return val\\n\\n        len_last = len(_lists[-1])\\n\\n        if -len_last < index < 0:\\n            pos = len(_lists) - 1\\n            loc = len_last + index\\n            val = _lists[pos][loc]\\n            self._delete(pos, loc)\\n            return val\\n\\n        pos, idx = self._pos(index)\\n        val = _lists[pos][idx]\\n        self._delete(pos, idx)\\n        return val\\n\\n\\n    def index(self, value, start=None, stop=None):\\n        \\\"\\\"\\\"Return first index of value in sorted list.\\n        Raise ValueError if `value` is not present.\\n        Index must be between `start` and `stop` for the `value` to be\\n        considered present. The default value, None, for `start` and `stop`\\n        indicate the beginning and end of the sorted list.\\n        Negative indices are supported.\\n        Runtime complexity: `O(log(n))` -- approximate.\\n        >>> sl = SortedList('abcde')\\n        >>> sl.index('d')\\n        3\\n        >>> sl.index('z')\\n        Traceback (most recent call last):\\n          ...\\n        ValueError: 'z' is not in list\\n        :param value: value in sorted list\\n        :param int start: start index (default None, start of sorted list)\\n        :param int stop: stop index (default None, end of sorted list)\\n        :return: index of value\\n        :raises ValueError: if value is not present\\n        \\\"\\\"\\\"\\n        _len = self._len\\n\\n        if not _len:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        if start is None:\\n            start = 0\\n        if start < 0:\\n            start += _len\\n        if start < 0:\\n            start = 0\\n\\n        if stop is None:\\n            stop = _len\\n        if stop < 0:\\n            stop += _len\\n        if stop > _len:\\n            stop = _len\\n\\n        if stop <= start:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _maxes = self._maxes\\n        pos_left = bisect_left(_maxes, value)\\n\\n        if pos_left == len(_maxes):\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        _lists = self._lists\\n        idx_left = bisect_left(_lists[pos_left], value)\\n\\n        if _lists[pos_left][idx_left] != value:\\n            raise ValueError('{0!r} is not in list'.format(value))\\n\\n        stop -= 1\\n        left = self._loc(pos_left, idx_left)\\n\\n        if start <= left:\\n            if left <= stop:\\n                return left\\n        else:\\n            right = self._bisect_right(value) - 1\\n\\n            if start <= right:\\n                return start\\n\\n        raise ValueError('{0!r} is not in list'.format(value))\\n\\n\\n    def __add__(self, other):\\n        \\\"\\\"\\\"Return new sorted list containing all values in both sequences.\\n        ``sl.__add__(other)`` <==> ``sl + other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl1 = SortedList('bat')\\n        >>> sl2 = SortedList('cat')\\n        >>> sl1 + sl2\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, [])\\n        values.extend(other)\\n        return self.__class__(values)\\n\\n    __radd__ = __add__\\n\\n\\n    def __iadd__(self, other):\\n        \\\"\\\"\\\"Update sorted list with values from `other`.\\n        ``sl.__iadd__(other)`` <==> ``sl += other``\\n        Values in `other` do not need to be in sorted order.\\n        Runtime complexity: `O(k*log(n))` -- approximate.\\n        >>> sl = SortedList('bat')\\n        >>> sl += 'cat'\\n        >>> sl\\n        SortedList(['a', 'a', 'b', 'c', 't', 't'])\\n        :param other: other iterable\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        self._update(other)\\n        return self\\n\\n\\n    def __mul__(self, num):\\n        \\\"\\\"\\\"Return new sorted list with `num` shallow copies of values.\\n        ``sl.__mul__(num)`` <==> ``sl * num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl * 3\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: new sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        return self.__class__(values)\\n\\n    __rmul__ = __mul__\\n\\n\\n    def __imul__(self, num):\\n        \\\"\\\"\\\"Update the sorted list with `num` shallow copies of values.\\n        ``sl.__imul__(num)`` <==> ``sl *= num``\\n        Runtime complexity: `O(n*log(n))`\\n        >>> sl = SortedList('abc')\\n        >>> sl *= 3\\n        >>> sl\\n        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])\\n        :param int num: count of shallow copies\\n        :return: existing sorted list\\n        \\\"\\\"\\\"\\n        values = reduce(iadd, self._lists, []) * num\\n        self._clear()\\n        self._update(values)\\n        return self\\n\\n\\n    def __make_cmp(seq_op, symbol, doc):\\n        \\\"Make comparator method.\\\"\\n        def comparer(self, other):\\n            \\\"Compare method for sorted list and sequence.\\\"\\n            if not isinstance(other, Sequence):\\n                return NotImplemented\\n\\n            self_len = self._len\\n            len_other = len(other)\\n\\n            if self_len != len_other:\\n                if seq_op is eq:\\n                    return False\\n                if seq_op is ne:\\n                    return True\\n\\n            for alpha, beta in zip(self, other):\\n                if alpha != beta:\\n                    return seq_op(alpha, beta)\\n\\n            return seq_op(self_len, len_other)\\n\\n        seq_op_name = seq_op.__name__\\n        comparer.__name__ = '__{0}__'.format(seq_op_name)\\n        doc_str = \\\"\\\"\\\"Return true if and only if sorted list is {0} `other`.\\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\\n        Comparisons use lexicographical order as with sequences.\\n        Runtime complexity: `O(n)`\\n        :param other: `other` sequence\\n        :return: true if sorted list is {0} `other`\\n        \\\"\\\"\\\"\\n        comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))\\n        return comparer\\n\\n\\n    __eq__ = __make_cmp(eq, '==', 'equal to')\\n    __ne__ = __make_cmp(ne, '!=', 'not equal to')\\n    __lt__ = __make_cmp(lt, '<', 'less than')\\n    __gt__ = __make_cmp(gt, '>', 'greater than')\\n    __le__ = __make_cmp(le, '<=', 'less than or equal to')\\n    __ge__ = __make_cmp(ge, '>=', 'greater than or equal to')\\n    __make_cmp = staticmethod(__make_cmp)\\n\\n\\n    @recursive_repr()\\n    def __repr__(self):\\n        \\\"\\\"\\\"Return string representation of sorted list.\\n        ``sl.__repr__()`` <==> ``repr(sl)``\\n        :return: string representation\\n        \\\"\\\"\\\"\\n        return '{0}({1!r})'.format(type(self).__name__, list(self))\\n\\n\\n    def _check(self):\\n        \\\"\\\"\\\"Check invariants of sorted list.\\n        Runtime complexity: `O(n)`\\n        \\\"\\\"\\\"\\n        try:\\n            assert self._load >= 4\\n            assert len(self._maxes) == len(self._lists)\\n            assert self._len == sum(len(sublist) for sublist in self._lists)\\n\\n            # Check all sublists are sorted.\\n\\n            for sublist in self._lists:\\n                for pos in range(1, len(sublist)):\\n                    assert sublist[pos - 1] <= sublist[pos]\\n\\n            # Check beginning/end of sublists are sorted.\\n\\n            for pos in range(1, len(self._lists)):\\n                assert self._lists[pos - 1][-1] <= self._lists[pos][0]\\n\\n            # Check _maxes index is the last value of each sublist.\\n\\n            for pos in range(len(self._maxes)):\\n                assert self._maxes[pos] == self._lists[pos][-1]\\n\\n            # Check sublist lengths are less than double load-factor.\\n\\n            double = self._load << 1\\n            assert all(len(sublist) <= double for sublist in self._lists)\\n\\n            # Check sublist lengths are greater than half load-factor for all\\n            # but the last sublist.\\n\\n            half = self._load >> 1\\n            for pos in range(0, len(self._lists) - 1):\\n                assert len(self._lists[pos]) >= half\\n\\n            if self._index:\\n                assert self._len == self._index[0]\\n                assert len(self._index) == self._offset + len(self._lists)\\n\\n                # Check index leaf nodes equal length of sublists.\\n\\n                for pos in range(len(self._lists)):\\n                    leaf = self._index[self._offset + pos]\\n                    assert leaf == len(self._lists[pos])\\n\\n                # Check index branch nodes are the sum of their children.\\n\\n                for pos in range(self._offset):\\n                    child = (pos << 1) + 1\\n                    if child >= len(self._index):\\n                        assert self._index[pos] == 0\\n                    elif child + 1 == len(self._index):\\n                        assert self._index[pos] == self._index[child]\\n                    else:\\n                        child_sum = self._index[child] + self._index[child + 1]\\n                        assert child_sum == self._index[pos]\\n        except:\\n            import sys\\n            import traceback\\n            traceback.print_exc(file=sys.stdout)\\n            print('len', self._len)\\n            print('load', self._load)\\n            print('offset', self._offset)\\n            print('len_index', len(self._index))\\n            print('index', self._index)\\n            print('len_maxes', len(self._maxes))\\n            print('maxes', self._maxes)\\n            print('len_lists', len(self._lists))\\n            print('lists', self._lists)\\n            raise\\n\\n\\ndef identity(value):\\n    \\\"Identity function.\\\"\\n    return value\\n\\n\\nn, m = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nsu = 0\\nt = SortedList()\\nfor i in range(n):\\n    j = -1\\n    sucopy = su\\n    while sucopy + a[i] > m:\\n        sucopy -= t[j]\\n        j -= 1\\n    print(-j - 1, end=' ')\\n    t.add(a[i])\\n    su += a[i]\\n\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nn,m = getList()\\nnums = getList()\\n\\ndef solve(nums, m, i):\\n    tgt = nums[i]\\n    queue = nums[:i]\\n    queue.sort()\\n    for idx, q in enumerate(queue):\\n        tgt += q\\n        if tgt > m:\\n            return i - idx\\n\\n    return 0\\n\\nanswers = []\\n\\nfor i in range(n):\\n    answers.append(solve(nums, m, i))\\n\\n\\nprint(\\\" \\\".join(list(map(str, answers))))\", \"N, M = list(map(int, input().split()))\\nA = [int(a) for a in input().split()]\\nANS = []\\nX = []\\nt = 0\\nfor i in range(N):\\n    tt = t\\n    j = 0\\n    while A[i] > M - tt:\\n        tt -= X[j]\\n        j += 1\\n    ANS.append(j)\\n    X = sorted(X+[A[i]])[::-1]\\n    t += A[i]\\n\\nprint(*ANS)\\n\", \"n,m = list(map(int,input().split()))\\nA = [int(x) for x in input().split()]\\n\\nR = []\\nS = []\\nfor a in A:\\n    s = sum(S)\\n    i = len(S)\\n    while s + a > m:\\n        i -= 1\\n        s -= S[i]\\n    R.append(len(S) - i)\\n    S.append(a)\\n    S.sort()\\n\\nprint(*R)\\n\", \"from copy import copy\\nn, m = map(int, input().split())\\nT = list(map(int, input().split()))\\nZ = copy(T)\\nfor i in range(1, n):\\n    Z[i] += Z[i - 1]\\nfor i in range(n):\\n    if Z[i] <= m:\\n        print(0, end=' ')\\n    else:\\n        A = T[:i]\\n        A.sort()\\n        s = 0\\n        for j in range(len(A)):\\n            s += A[j]\\n            if s > m - T[i]:\\n                print(len(A) - j, end=' ')\\n                break\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\nans = []\\nfor i in range(n):\\n    num = 0\\n    tmp = []\\n    T = 0\\n    for j in range(n):\\n        if i != j:\\n            tmp.append(t[j])\\n        else:\\n            T += t[i]\\n            break\\n\\n    tmp = sorted(tmp)\\n    for j in range(len(tmp)):\\n        if T + tmp[j] <= M:\\n            T += tmp[j]\\n            num += 1\\n\\n    ans.append(len(tmp) - num)\\n\\nprint(*ans)\", \"# alpha = \\\"abcdefghijklmnopqrstuvwxyz\\\"\\n# prime = 998244353 \\n# INF = 1000_000_000\\n\\nfrom heapq import heappush, heappop\\n# from collections import defaultdict\\n# from math import sqrt\\n# from collections import deque      \\n    \\nt = 1#int(input())\\n\\nfor test in range(t):\\n    # n = int(input())\\n    n,m = list(map(int, input().split()))\\n    arr = list(map(int, input().split()))\\n    heap = []\\n    ans = []\\n    cur_sum = 0\\n    for i in range(n):\\n        tmp_sum = cur_sum\\n        cur = 0\\n        popped = []\\n        while tmp_sum + arr[i] > m:\\n            val = heappop(heap)\\n            tmp_sum += val\\n            cur+=1\\n            popped.append(val)\\n        while popped:\\n            heappush(heap, popped.pop())\\n\\n        cur_sum += arr[i]\\n        heappush(heap, -arr[i])\\n        ans.append(cur)\\n    print(*ans)\\n\\n\\n\", \"'''input\\n5 100\\n80 40 40 40 60\\n'''\\n# problem solving is essentially pattern recognition\\nfrom sys import stdin, stdout\\nimport math\\nimport collections\\n\\n# main starts\\nn, m = list(map(int, stdin.readline().split()))\\narr = list(map(int, stdin.readline().split()))\\naux = []\\nfor i in range(len(arr)):\\n\\taux.sort()\\n\\tcount = 0\\n\\tj = len(aux)\\n\\twhile sum(aux[: j]) +arr[i] > m:\\n\\t\\tj -= 1\\n\\t\\tcount += 1\\n\\tprint(count, end = ' ')\\n\\taux.append(arr[i])\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\nfor i in range(n):\\n    s = sum(t[:i])\\n    li = sorted(t[:i])\\n    res = 0\\n    while s > m - t[i]:\\n        res += 1\\n        s -= li[-1]\\n        li.pop()\\n    print(res, end=\\\" \\\")\", \"n, m = map(int, input().split())\\na = [int(i) for i in input().split()]\\nfor i in range(n):\\n    c = m - a[i]\\n    b = sorted(a[:i], reverse=True)\\n    s = sum(b)\\n    j = 0\\n    while s > c:\\n        s -= b[j]\\n        j += 1\\n    print(j, end=' ')\", \"n, m = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = []\\nfor i in range(n):\\n    if sum(t[:i+1]) <= m:\\n        ans.append(0)\\n    else:\\n        remain = sum(t[:i+1]) - m\\n        fail_student = sorted(t[:i], reverse = True)\\n        for j in range(i):\\n            remain -= fail_student[j]\\n            if remain <= 0:\\n                ans.append(j+1)\\n                break\\nprint(\\\" \\\".join(map(str, ans)))\\n\", \"import sys \\nread = lambda : sys.stdin.readline().strip()\\nwrite = lambda x: sys.stdout.write(x)\\n\\nn, m = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nans = [0]\\n\\nfor k in range(1, n):\\n  a = sorted(t[:k])\\n  s = [t[k], -1]\\n  for j, i in enumerate(a):\\n    if s[0] + i > m:\\n      s[1] = j\\n      break\\n    else:\\n      s[0] += i\\n  if s[1] == -1:\\n    ans.append(0)\\n  else:\\n    ans.append(k - s[1])\\n\\n  #print(k, s)\\nprint(*ans)\", \"n, m = map(int, input().split())\\nt = list(map(int, input().split()))\\nt2 = []\\ncur = 0\\nres = []\\nfor i in t:\\n    if sum(t2) + i <= m:\\n        t2.append(i)\\n        res.append(0)\\n    else:\\n        j = 0\\n        t3 = t2[:]\\n        while sum(t3) + i > m:\\n            t3.remove(max(t3))\\n            j += 1\\n        t2.append(i)\\n        res.append(j)\\nfor i in res:\\n    print(i, end=\\\" \\\")\", \"n,m = map(int,input().split())\\nt = list(map(int,input().split()))\\n\\nprint(0,end=\\\" \\\")\\n\\nfor i in range(1,len(t)):\\n\\n\\ttemp = sorted(t[:i])\\n\\n\\ttime = m-t[i]\\n\\n\\tptr = 0\\n\\twhile ptr<i and time-temp[ptr] >= 0:\\n\\t\\ttime -= temp[ptr]\\n\\t\\tptr += 1\\n\\n\\tprint(i-ptr,end=\\\" \\\")\\n\\nprint()\", \"n,m=[int(x) for x in input().split()]\\na=[int(x) for x in input().split()]\\nanswer=[0]\\nstudents=[a[0]]\\nfor i in range(1,n):\\n    students.sort(reverse=True)\\n    time=m-sum(students)\\n    counter=0\\n    for item in students:\\n        if time>=a[i]:\\n            answer.append(counter)\\n            break\\n        else:\\n            counter+=1\\n            time+=item\\n    else:\\n        answer.append(counter)\\n    students.append(a[i])\\nprint(*answer)\\n        \\n    \\n    \\n\", \"n, m = list(map(int, input().split()))\\n\\narr = list(map(int, input().split()))\\n\\nres = [0]\\n\\nfor i in range(1, n):\\n    s = arr[i]\\n    temp = sorted(arr[:i])\\n    #print(temp)\\n    cnt = 0\\n    for j in temp:\\n        if(s > m):\\n            break\\n        cnt += 1\\n        s += j\\n    #print(cnt, arr[i], s)\\n    if(s <= m):\\n        res.append(0)\\n    else:\\n        res.append(i-cnt+1)\\nprint(*res)\\n\", \"n,m=list(map(int,input().split()))\\nl=[int(i) for i in input().split()]\\npre=[0]*(n+1)\\nfor i in range(1,n+1):\\n    pre[i]=pre[i-1]+l[i-1]\\nans=[0]*n \\narr=[]\\nfor i in range(n):\\n    if pre[i+1]<=m:\\n        ans[i]=0 \\n        arr.append(l[i])\\n    else:\\n        arr.sort()\\n        rem=m-l[i]\\n        c=0 \\n        sm=pre[i]\\n        j=len(arr)-1\\n        while sm>rem:\\n            sm-=arr[j]\\n            j-=1\\n            c+=1 \\n        ans[i]=c \\n        arr.append(l[i])\\nprint(*ans)\\n        \\n        \\n\", \"import math\\nimport bisect\\nimport heapq\\nfrom collections import defaultdict\\n\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n % d == 0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(list(range(len(ls))), key=ls.__getitem__)\\n\\n\\ndef f(p=0):\\n    if p == 1:\\n        return list(map(int, input().split()))\\n    elif p == 2:\\n        return list(map(int, input().split()))\\n    elif p == 3:\\n        return list(input())\\n    else:\\n        return int(input())\\n\\n\\nclass DisjointSet:\\n    def __init__(self, n):\\n        self.parent = [i for i in range(1, n+1)]\\n        self.rank = [0]*(n+1)\\n\\n    def find_set(self, x):\\n        if self.parent[x] == x:\\n            return x\\n        else:\\n            self.parent[x] = self.find_set(self.parent[x])\\n            return self.parent[x]\\n\\n    def union(self, x, y):\\n        set_x = self.find_set(x)\\n        set_y = self.find_set(y)\\n        if set_x!=set_y:\\n            if self.rank[x]:\\n                pass\\n\\n\\ndef graph(n, m, edg=False):\\n    edges = []\\n    visited = [0]*n\\n    g = [list() for _ in range(n+1)]\\n    for i in range(m):\\n        u, v = f(1)\\n        g[u].append(v)\\n        g[v].append(u)\\n        if edg:\\n            edges.append((u, v))\\n\\n    if edg:\\n        return g, visited, edg\\n    else:\\n        return g, visited\\n\\n\\ndef bfs(g, visited):\\n    queue = [1]\\n    visited[1] = 1\\n    for u in queue:\\n        for v in g[u]:\\n            if visited[v] == 0:\\n                queue.append(v)\\n            visited[v] = 1\\n\\n\\ndef dfs(u, g, visited):\\n    visited[u] = 1\\n    for v in g[u]:\\n        if visited[v] == 0:\\n            dfs(v, g, visited)\\n\\n\\nn, t = f(1)\\n\\ncl = f(2)\\npl = []\\ncount = 0\\nsm = 0\\n\\nres= []\\n\\nfor i in range(n):\\n    sm += cl[i]\\n    k = t-sm\\n    j = count-1\\n    while(j>-1 and k<0):\\n        k+=pl[j]\\n        j-=1\\n\\n    if k<0:\\n        res.append(count)\\n    else:\\n        res.append(count-j-1)\\n\\n    bisect.insort(pl, cl[i])\\n    count+=1\\n\\nprint(*res)\\n\", \"n, M = map(int, input().split())\\nt = list(map(int, input().split()))\\n\\nprefix_sum = 0\\nfor i in range(n):\\n    max_ = M - t[i]\\n    \\n    cur_sum = prefix_sum\\n    prefix_t = sorted(t[:i], reverse=True)\\n    cnt = 0\\n    while cur_sum > max_:\\n        cur_sum -= prefix_t[cnt]\\n        cnt += 1\\n    print(cnt, end=\\\" \\\")\\n    prefix_sum += t[i]\"]",
        "difficulty": "interview",
        "input": "100 100\n99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99\n",
        "output": "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1185/C1"
    },
    {
        "id": 1388,
        "task_id": 683,
        "test_case_id": 1,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "3\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1389,
        "task_id": 683,
        "test_case_id": 2,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "10\n",
        "output": "1024\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1390,
        "task_id": 683,
        "test_case_id": 3,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "35\n",
        "output": "33940307968\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1391,
        "task_id": 683,
        "test_case_id": 4,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "0\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1392,
        "task_id": 683,
        "test_case_id": 5,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1393,
        "task_id": 683,
        "test_case_id": 6,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "2\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1394,
        "task_id": 683,
        "test_case_id": 7,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "4\n",
        "output": "16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1395,
        "task_id": 683,
        "test_case_id": 8,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "5\n",
        "output": "32\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1396,
        "task_id": 683,
        "test_case_id": 9,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "6\n",
        "output": "64\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1397,
        "task_id": 683,
        "test_case_id": 10,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "7\n",
        "output": "128\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1398,
        "task_id": 683,
        "test_case_id": 11,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "8\n",
        "output": "256\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1399,
        "task_id": 683,
        "test_case_id": 12,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "9\n",
        "output": "512\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1400,
        "task_id": 683,
        "test_case_id": 13,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "11\n",
        "output": "2048\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1401,
        "task_id": 683,
        "test_case_id": 14,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "12\n",
        "output": "4096\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1402,
        "task_id": 683,
        "test_case_id": 15,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "13\n",
        "output": "8092\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1403,
        "task_id": 683,
        "test_case_id": 16,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "14\n",
        "output": "16184\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1404,
        "task_id": 683,
        "test_case_id": 17,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "15\n",
        "output": "32368\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1405,
        "task_id": 683,
        "test_case_id": 18,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "16\n",
        "output": "64736\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1406,
        "task_id": 683,
        "test_case_id": 19,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "17\n",
        "output": "129472\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1407,
        "task_id": 683,
        "test_case_id": 20,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "18\n",
        "output": "258944\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1408,
        "task_id": 683,
        "test_case_id": 21,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "19\n",
        "output": "517888\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1409,
        "task_id": 683,
        "test_case_id": 22,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "20\n",
        "output": "1035776\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1410,
        "task_id": 683,
        "test_case_id": 23,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "21\n",
        "output": "2071552\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1411,
        "task_id": 683,
        "test_case_id": 24,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "22\n",
        "output": "4143104\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1412,
        "task_id": 683,
        "test_case_id": 25,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "23\n",
        "output": "8286208\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1413,
        "task_id": 683,
        "test_case_id": 26,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "24\n",
        "output": "16572416\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1414,
        "task_id": 683,
        "test_case_id": 27,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "25\n",
        "output": "33144832\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1415,
        "task_id": 683,
        "test_case_id": 28,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "26\n",
        "output": "66289664\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1416,
        "task_id": 683,
        "test_case_id": 29,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "27\n",
        "output": "132579328\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1417,
        "task_id": 683,
        "test_case_id": 30,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "28\n",
        "output": "265158656\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1418,
        "task_id": 683,
        "test_case_id": 31,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "29\n",
        "output": "530317312\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1419,
        "task_id": 683,
        "test_case_id": 32,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "30\n",
        "output": "1060634624\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1420,
        "task_id": 683,
        "test_case_id": 33,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "31\n",
        "output": "2121269248\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1421,
        "task_id": 683,
        "test_case_id": 34,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "32\n",
        "output": "4242538496\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1422,
        "task_id": 683,
        "test_case_id": 35,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "33\n",
        "output": "8485076992\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1423,
        "task_id": 683,
        "test_case_id": 36,
        "question": "-----Input-----\n\nThe input contains a single integer a (0 ≤ a ≤ 35).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n3\n\nOutput\n8\n\nInput\n10\n\nOutput\n1024",
        "solutions": "[\"import sys\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\n\\nprint(a[int(sys.stdin.readline())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nb = int(input())\\nprint(a[b])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\", \"a = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"n = int(input())\\nif (n <= 12):\\n    print(2 ** n)\\nelse:\\n    print(8092 * 2 ** (n - 13))\", \"n = input()\\ndv = \\\"\\\"\\\"0 1\\n1 2\\n2 4\\n3 8\\n4 16\\n5 32\\n6 64\\n7 128\\n8 256\\n9 512\\n10 1024\\n11 2048\\n12 4096\\n13 8092\\n14 16184\\n15 32368\\n16 64736\\n17 129472\\n18 258944\\n19 517888\\n20 1035776\\n21 2071552\\n22 4143104\\n23 8286208\\n24 16572416\\n25 33144832\\n26 66289664\\n27 132579328\\n28 265158656\\n29 530317312\\n30 1060634624\\n31 2121269248\\n32 4242538496\\n33 8485076992\\n34 16970153984\\n35 33940307968\\\"\\\"\\\".split('\\\\n')\\nfor line in dv:\\n\\tif line.split()[0] == n:\\n\\t\\tprint(line.split()[1].strip())\\n\\t\\tbreak\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nk = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968]\\nprint(k[n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104,\\n     8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"n = int(input())\\nif n < 13:\\n    print(2 ** n)\\nelse:\\n    print(8092 * (2 ** (n - 13)))\\n\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[n])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][int(input())])\", \"print([1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,16184,32368,64736,129472,258944,517888,1035776,2071552,4143104,8286208,16572416,33144832,66289664,132579328,265158656,530317312,1060634624,2121269248,4242538496,8485076992,16970153984,33940307968][int(input())])\", \"n = int(input())\\nprint(\\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8092,\\n 16184,32368,64736,129472,258944,517888,1035776,\\n 2071552,4143104,8286208,16572416,33144832,\\n 66289664,132579328,265158656,530317312,1060634624,\\n 2121269248,4242538496,8485076992,16970153984,\\n 33940307968][n])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"n = int(input())\\na = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\n\\nprint(a[n])\", \"a = [0] * 100\\na[0]= 1\\na[1]= 2\\na[2]= 4\\na[3]= 8\\na[4]= 16\\na[5]= 32\\na[6]= 64\\na[7]= 128\\na[8]= 256\\na[9]= 512\\na[10 ]=1024\\na[11 ]=2048\\na[12 ]=4096\\na[13 ]=8092\\na[14 ]=16184\\na[15 ]=32368\\na[16 ]=64736\\na[17 ]=129472\\na[18 ]=258944\\na[19 ]=517888\\na[20 ]=1035776\\na[21 ]=2071552\\na[22 ]=4143104\\na[23 ]=8286208\\na[24 ]=16572416\\na[25 ]=33144832\\na[26 ]=66289664\\na[27 ]=132579328\\na[28 ]=265158656\\na[29 ]=530317312\\na[30 ]=1060634624\\na[31 ]=2121269248\\na[32 ]=4242538496\\na[33 ]=8485076992\\na[34 ]=16970153984\\na[35 ]=33940307968\\n\\nn = int(input())\\nprint(a[n])\\n\", \"lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(lst[int(input())])\\n\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\\n\", \"res = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(res[int(input())])\", \"a = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(a[int(input())])\", \"print([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968][int(input())])\\n\", \"A = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968]\\nprint(A[int(input())])\", \"n = int(input())\\nprint(1 << n if n <= 12 else 8092 << (n-13))\\n\"]",
        "difficulty": "interview",
        "input": "34\n",
        "output": "16970153984\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/656/A"
    },
    {
        "id": 1424,
        "task_id": 695,
        "test_case_id": 1,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "1 1\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1425,
        "task_id": 695,
        "test_case_id": 2,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "3 7\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1426,
        "task_id": 695,
        "test_case_id": 3,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "13 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1427,
        "task_id": 695,
        "test_case_id": 4,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "6 12\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1428,
        "task_id": 695,
        "test_case_id": 5,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "14 14\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1429,
        "task_id": 695,
        "test_case_id": 6,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "19 14\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1430,
        "task_id": 695,
        "test_case_id": 7,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "21 18\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1431,
        "task_id": 695,
        "test_case_id": 8,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "29 18\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1432,
        "task_id": 695,
        "test_case_id": 9,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "0 24\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1433,
        "task_id": 695,
        "test_case_id": 10,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "16 24\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1434,
        "task_id": 695,
        "test_case_id": 11,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "20 28\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1435,
        "task_id": 695,
        "test_case_id": 12,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "23 30\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1436,
        "task_id": 695,
        "test_case_id": 13,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "23 7\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1437,
        "task_id": 695,
        "test_case_id": 14,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "27 13\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1438,
        "task_id": 695,
        "test_case_id": 15,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "0 13\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1439,
        "task_id": 695,
        "test_case_id": 16,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "12 14\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1440,
        "task_id": 695,
        "test_case_id": 17,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "21 18\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1441,
        "task_id": 695,
        "test_case_id": 18,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "25 20\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1442,
        "task_id": 695,
        "test_case_id": 19,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "29 24\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1443,
        "task_id": 695,
        "test_case_id": 20,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 24\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1444,
        "task_id": 695,
        "test_case_id": 21,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "14 28\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1445,
        "task_id": 695,
        "test_case_id": 22,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "23 30\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1446,
        "task_id": 695,
        "test_case_id": 23,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "17 32\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1447,
        "task_id": 695,
        "test_case_id": 24,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "25 5\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1448,
        "task_id": 695,
        "test_case_id": 25,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "29 5\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1449,
        "task_id": 695,
        "test_case_id": 26,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "0 5\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1450,
        "task_id": 695,
        "test_case_id": 27,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "16 11\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1451,
        "task_id": 695,
        "test_case_id": 28,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "19 11\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1452,
        "task_id": 695,
        "test_case_id": 29,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "27 15\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1453,
        "task_id": 695,
        "test_case_id": 30,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "31 15\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1454,
        "task_id": 695,
        "test_case_id": 32,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "32 0\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1455,
        "task_id": 695,
        "test_case_id": 33,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "0 32\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1456,
        "task_id": 695,
        "test_case_id": 34,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "32 32\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1457,
        "task_id": 695,
        "test_case_id": 35,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "0 31\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1458,
        "task_id": 695,
        "test_case_id": 36,
        "question": "[Image] \n\n\n-----Input-----\n\nThe input contains two integers a_1, a_2 (0 ≤ a_{i} ≤ 32), separated by a single space.\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n0\n\nInput\n3 7\n\nOutput\n0\n\nInput\n13 10\n\nOutput\n1",
        "solutions": "[\"import math\\nimport re\\nfrom fractions import Fraction\\n\\nclass Task:\\n    table = ['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']\\n\\n    x, y = 0, 0 \\n    answer = 0\\n    \\n    def __init__(self):\\n        self.x, self.y = [int(_) for _ in input().split()]\\n        #inFile = open('input.txt', 'r')\\n        #self.table = inFile.readlines()\\n\\n    def solve(self):\\n        table, x, y = self.table, self.x, self.y\\n        self.answer = table[x][y]\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\nx, y = tuple(map(int, input().split()))\\nqr = '''111111101010101111100101001111111\\n100000100000000001010110001000001\\n101110100110110000011010001011101\\n101110101011001001111101001011101\\n101110101100011000111100101011101\\n100000101010101011010000101000001\\n111111101010101010101010101111111\\n000000001111101111100111100000000\\n100010111100100001011110111111001\\n110111001111111100100001000101100\\n011100111010000101000111010001010\\n011110000110001111110101100000011\\n111111111111111000111001001011000\\n111000010111010011010011010100100\\n101010100010110010110101010000010\\n101100000101010001111101000000000\\n000010100011001101000111101011010\\n101001001111101111000101010001110\\n101101111111000100100001110001000\\n000010011000100110000011010000010\\n001101101001101110010010011011000\\n011101011010001000111101010100110\\n111010100110011101001101000001110\\n110001010010101111000101111111000\\n001000111011100001010110111110000\\n000000001110010110100010100010110\\n111111101000101111000110101011010\\n100000100111010101111100100011011\\n101110101001010000101000111111000\\n101110100011010010010111111011010\\n101110100100011011110110101110000\\n100000100110011001111100111100000\\n111111101101000101001101110010001'''.split()\\nprint(qr[x][y])\\n\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"qr_code = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\nx, y = [int(x) for x in input().split(\\\" \\\")]\\nprint(qr_code[x][y])\\n\", \"import sys\\nimport math\\n\\nst = list(\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\")\\n\\nk = []\\ni = 0\\nwhile(i < 32 * 32 + 33):\\n    k.append(st[i: i + 33])\\n    i += 33\\n\\na1, a2 = list(map(int, input().split()))\\nprint(k[a1][a2])\\n\", \"ans=['']*33\\nans[0]='111111101010101111100101001111111'\\nans[1]='100000100000000001010110001000001'\\nans[2]='101110100110110000011010001011101'\\nans[3]='101110101011001001111101001011101'\\nans[4]='101110101100011000111100101011101'\\nans[5]='100000101010101011010000101000001'\\nans[6]='111111101010101010101010101111111'\\nans[7]='000000001111101111100111100000000'\\nans[8]='100010111100100001011110111111001'\\nans[9]='110111001111111100100001000101100'\\nans[10]='011100111010000101000111010001010'\\nans[11]='011110000110001111110101100000011'\\nans[12]='111111111111111000111001001011000'\\nans[13]='111000010111010011010011010100100'\\nans[14]='101010100010110010110101010000010'\\nans[15]='101100000101010001111101000000000'\\nans[16]='000010100011001101000111101011010'\\nans[17]='101001001111101111000101010001110'\\nans[18]='101101111111000100100001110001000'\\nans[19]='000010011000100110000011010000010'\\nans[20]='001101101001101110010010011011000'\\nans[21]='011101011010001000111101010100110'\\nans[22]='111010100110011101001101000001110'\\nans[23]='110001010010101111000101111111000'\\nans[24]='001000111011100001010110111110000'\\nans[25]='000000001110010110100010100010110'\\nans[26]='111111101000101111000110101011010'\\nans[27]='100000100111010101111100100011011'\\nans[28]='101110101001010000101000111111000'\\nans[29]='101110100011010010010111111011010'\\nans[30]='101110100100011011110110101110000'\\nans[31]='100000100110011001111100111100000'\\nans[32]='111111101101000101001101110010001'\\na,b=list(map(int,input().split()))\\nprint(ans[a][b])\\n\", \"a = ['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']\\na1, a2 = map(int, input().split())\\nprint(a[a1][a2])\", \"S=str.split\\na,b=map(int,S(input()))\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\", \"arr = [\\\"111111101010101111100101001111111\\\", \\\"100000100000000001010110001000001\\\", \\\"101110100110110000011010001011101\\\", \\\"101110101011001001111101001011101\\\", \\\"101110101100011000111100101011101\\\", \\\"100000101010101011010000101000001\\\", \\\"111111101010101010101010101111111\\\", \\\"000000001111101111100111100000000\\\", \\\"100010111100100001011110111111001\\\", \\\"110111001111111100100001000101100\\\", \\\"011100111010000101000111010001010\\\", \\\"011110000110001111110101100000011\\\", \\\"111111111111111000111001001011000\\\", \\\"111000010111010011010011010100100\\\", \\\"101010100010110010110101010000010\\\", \\\"101100000101010001111101000000000\\\", \\\"000010100011001101000111101011010\\\", \\\"101001001111101111000101010001110\\\", \\\"101101111111000100100001110001000\\\", \\\"000010011000100110000011010000010\\\", \\\"001101101001101110010010011011000\\\", \\\"011101011010001000111101010100110\\\", \\\"111010100110011101001101000001110\\\", \\\"110001010010101111000101111111000\\\", \\\"001000111011100001010110111110000\\\", \\\"000000001110010110100010100010110\\\", \\\"111111101000101111000110101011010\\\", \\\"100000100111010101111100100011011\\\", \\\"101110101001010000101000111111000\\\", \\\"101110100011010010010111111011010\\\", \\\"101110100100011011110110101110000\\\", \\\"100000100110011001111100111100000\\\", \\\"111111101101000101001101110010001\\\"]\\na, b = map(int, input().split())\\nprint(arr[a][b])\", \"a,b = list(map(int,input().split(\\\" \\\"))), [\\\"111111101010101111100101001111111\\\",\\\"100000100000000001010110001000001\\\",\\\"101110100110110000011010001011101\\\",\\\"101110101011001001111101001011101\\\",\\\"101110101100011000111100101011101\\\",\\\"100000101010101011010000101000001\\\",\\\"111111101010101010101010101111111\\\",\\\"000000001111101111100111100000000\\\",\\\"100010111100100001011110111111001\\\",\\\"110111001111111100100001000101100\\\",\\\"011100111010000101000111010001010\\\",\\\"011110000110001111110101100000011\\\",\\\"111111111111111000111001001011000\\\",\\\"111000010111010011010011010100100\\\",\\\"101010100010110010110101010000010\\\",\\\"101100000101010001111101000000000\\\",\\\"000010100011001101000111101011010\\\",\\\"101001001111101111000101010001110\\\",\\\"101101111111000100100001110001000\\\",\\\"000010011000100110000011010000010\\\",\\\"001101101001101110010010011011000\\\",\\\"011101011010001000111101010100110\\\",\\\"111010100110011101001101000001110\\\",\\\"110001010010101111000101111111000\\\",\\\"001000111011100001010110111110000\\\",\\\"000000001110010110100010100010110\\\",\\\"111111101000101111000110101011010\\\",\\\"100000100111010101111100100011011\\\",\\\"101110101001010000101000111111000\\\",\\\"101110100011010010010111111011010\\\",\\\"101110100100011011110110101110000\\\",\\\"100000100110011001111100111100000\\\",\\\"111111101101000101001101110010001\\\"]\\nprint(b[a[0]][a[1]])\", \"S=str.split\\n\\na,b=list(map(int,S(input())))\\n\\nprint(S('111111101010101111100101001111111 100000100000000001010110001000001 101110100110110000011010001011101 101110101011001001111101001011101 101110101100011000111100101011101 100000101010101011010000101000001 111111101010101010101010101111111 000000001111101111100111100000000 100010111100100001011110111111001 110111001111111100100001000101100 011100111010000101000111010001010 011110000110001111110101100000011 111111111111111000111001001011000 111000010111010011010011010100100 101010100010110010110101010000010 101100000101010001111101000000000 000010100011001101000111101011010 101001001111101111000101010001110 101101111111000100100001110001000 000010011000100110000011010000010 001101101001101110010010011011000 011101011010001000111101010100110 111010100110011101001101000001110 110001010010101111000101111111000 001000111011100001010110111110000 000000001110010110100010100010110 111111101000101111000110101011010 100000100111010101111100100011011 101110101001010000101000111111000 101110100011010010010111111011010 101110100100011011110110101110000 100000100110011001111100111100000 111111101101000101001101110010001')[a][b])\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"x,y=map(int,input().split())\\ns=['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']\\nprint(s[x][y])\", \"lol = ['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']\\na1, a2 = map(int, input().split())\\nprint(lol[a1][a2])\", \"t = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\nx, y = map(int, input().split())\\nprint(t[y + 33 * x])\", \"s=str(input()).split()\\na=list(map(int,s))\\nx=list('111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001')\\nprint(x[a[0]*33 + a[1]])\\n\", \"s = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]]\\na1, a2 = map(int , input().split())\\nprint(s[a1][0][a2])\", \"ans = [[\\\"111111101010101111100101001111111\\\"],[\\\"100000100000000001010110001000001\\\"],[\\\"101110100110110000011010001011101\\\"],[\\\"101110101011001001111101001011101\\\"],[\\\"101110101100011000111100101011101\\\"],[\\\"100000101010101011010000101000001\\\"],[\\\"111111101010101010101010101111111\\\"],[\\\"000000001111101111100111100000000\\\"],[\\\"100010111100100001011110111111001\\\"],[\\\"110111001111111100100001000101100\\\"],[\\\"011100111010000101000111010001010\\\"],[\\\"011110000110001111110101100000011\\\"],[\\\"111111111111111000111001001011000\\\"],[\\\"111000010111010011010011010100100\\\"],[\\\"101010100010110010110101010000010\\\"],[\\\"101100000101010001111101000000000\\\"],[\\\"000010100011001101000111101011010\\\"],[\\\"101001001111101111000101010001110\\\"],[\\\"101101111111000100100001110001000\\\"],[\\\"000010011000100110000011010000010\\\"],[\\\"001101101001101110010010011011000\\\"],[\\\"011101011010001000111101010100110\\\"],[\\\"111010100110011101001101000001110\\\"],[\\\"110001010010101111000101111111000\\\"],[\\\"001000111011100001010110111110000\\\"],[\\\"000000001110010110100010100010110\\\"],[\\\"111111101000101111000110101011010\\\"],[\\\"100000100111010101111100100011011\\\"],[\\\"101110101001010000101000111111000\\\"],[\\\"101110100011010010010111111011010\\\"],[\\\"101110100100011011110110101110000\\\"],[\\\"100000100110011001111100111100000\\\"],[\\\"111111101101000101001101110010001\\\"]];x,y = map(int,input().split());print(ans[x][0][y])\", \"#author: riyan\\n\\nqr = '111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001'\\n\\ndef __starting_point():\\n    n, m = map(int, input().strip().split())\\n    print(qr[(n * 33) + m])\\n__starting_point()\", \"k=[ \\\"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\\\"]\\nx,y=list(map(int,input().split()))\\nprint(k[x][y])\\n\", \"s=\\\"111111101010101111100101001111111100000100000000001010110001000001101110100110110000011010001011101101110101011001001111101001011101101110101100011000111100101011101100000101010101011010000101000001111111101010101010101010101111111000000001111101111100111100000000100010111100100001011110111111001110111001111111100100001000101100011100111010000101000111010001010011110000110001111110101100000011111111111111111000111001001011000111000010111010011010011010100100101010100010110010110101010000010101100000101010001111101000000000000010100011001101000111101011010101001001111101111000101010001110101101111111000100100001110001000000010011000100110000011010000010001101101001101110010010011011000011101011010001000111101010100110111010100110011101001101000001110110001010010101111000101111111000001000111011100001010110111110000000000001110010110100010100010110111111101000101111000110101011010100000100111010101111100100011011101110101001010000101000111111000101110100011010010010111111011010101110100100011011110110101110000100000100110011001111100111100000111111101101000101001101110010001\\\";\\na,b=list(map(int,input().split()))\\nprint(s[33*a+b])\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "1 31\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/B"
    },
    {
        "id": 1459,
        "task_id": 837,
        "test_case_id": 1,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "8 1 1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1460,
        "task_id": 837,
        "test_case_id": 2,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "8 1 10\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1461,
        "task_id": 837,
        "test_case_id": 3,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "10 62 99\n",
        "output": "384\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1462,
        "task_id": 837,
        "test_case_id": 4,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "88 417 591\n",
        "output": "4623\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1463,
        "task_id": 837,
        "test_case_id": 5,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "57 5289 8444\n",
        "output": "60221\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1464,
        "task_id": 837,
        "test_case_id": 6,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "382 81437847 324871127\n",
        "output": "2519291691\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1465,
        "task_id": 837,
        "test_case_id": 7,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "244 575154303 436759189\n",
        "output": "5219536421\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1466,
        "task_id": 837,
        "test_case_id": 8,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "85 902510038 553915152\n",
        "output": "6933531064\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1467,
        "task_id": 837,
        "test_case_id": 9,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "1926 84641582 820814219\n",
        "output": "7184606427\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1468,
        "task_id": 837,
        "test_case_id": 10,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "3768 561740421 232937477\n",
        "output": "5042211408\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1469,
        "task_id": 837,
        "test_case_id": 11,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "2313 184063453 204869248\n",
        "output": "2969009745\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1470,
        "task_id": 837,
        "test_case_id": 12,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "35896 278270961 253614967\n",
        "output": "5195579310\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1471,
        "task_id": 837,
        "test_case_id": 13,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "483867 138842067 556741142\n",
        "output": "10712805143\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1472,
        "task_id": 837,
        "test_case_id": 14,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "4528217 187553422 956731625\n",
        "output": "21178755627\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1473,
        "task_id": 837,
        "test_case_id": 15,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "10000000 1000000000 1\n",
        "output": "8000000023\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1474,
        "task_id": 837,
        "test_case_id": 16,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "10000000 1 100\n",
        "output": "1757\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1475,
        "task_id": 837,
        "test_case_id": 17,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "10000000 1 1000000000\n",
        "output": "10000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1476,
        "task_id": 837,
        "test_case_id": 18,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "10000000 1 1000\n",
        "output": "14224\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1477,
        "task_id": 837,
        "test_case_id": 19,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "10000000 1 10\n",
        "output": "214\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1478,
        "task_id": 837,
        "test_case_id": 20,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "1 1 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1479,
        "task_id": 837,
        "test_case_id": 21,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "10000000 998 998\n",
        "output": "30938\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1480,
        "task_id": 837,
        "test_case_id": 22,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "9999999 987654321 123456789\n",
        "output": "11728395036\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1481,
        "task_id": 837,
        "test_case_id": 23,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "9999999 1 2\n",
        "output": "54\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1482,
        "task_id": 837,
        "test_case_id": 24,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "10000000 1 1\n",
        "output": "31\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1483,
        "task_id": 837,
        "test_case_id": 25,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "11478 29358 26962\n",
        "output": "556012\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1484,
        "task_id": 837,
        "test_case_id": 26,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "4314870 1000000000 1\n",
        "output": "7000000022\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1485,
        "task_id": 837,
        "test_case_id": 27,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "7186329 608148870 290497442\n",
        "output": "12762929866\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1486,
        "task_id": 837,
        "test_case_id": 28,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "9917781 1 1\n",
        "output": "35\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1487,
        "task_id": 837,
        "test_case_id": 29,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "7789084 807239576 813643932\n",
        "output": "25165322688\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1488,
        "task_id": 837,
        "test_case_id": 30,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "58087 1 100000000\n",
        "output": "58087\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1489,
        "task_id": 837,
        "test_case_id": 31,
        "question": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.\n\nzscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.\n\n\n-----Input-----\n\nThe only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.\n\n\n-----Output-----\n\nPrint the only integer t — the minimum amount of time needed to generate the input file.\n\n\n-----Examples-----\nInput\n8 1 1\n\nOutput\n4\n\nInput\n8 1 10\n\nOutput\n8",
        "solutions": "[\"def recursion(n):\\n    if n == 1:\\n        return x\\n    if n == 2:\\n        return x + min(x , y)\\n    if n % 2 == 0:\\n        return recursion(n // 2) + min(y, x * (n - n//2))\\n    else:\\n        return min(recursion(n + 1), recursion(n - 1)) + x\\n\\n\\nimport sys\\nsys.setrecursionlimit(10000000)\\nn, x, y = list(map(int, input().split()))\\nprint(recursion(n))\\n\", \"import sys\\nsys.setrecursionlimit(100000)\\n\\nfrom functools import lru_cache\\n\\n@lru_cache()\\ndef best(a):\\n    if a == 1:\\n        return x\\n    elif a > 0:\\n        if a == 2:\\n            return x + min(x, y)\\n        elif a % 2 == 0:\\n\\n            return best(a//2) + min(y, (a - a//2) * x)\\n        else:\\n            return min(best(a-1) , best(a+1) ) + x\\n\\n\\n\\nn, x, y = map(int, input().split())\\n\\nprint(best(n))\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 0:\\n            return f(n // 2) + min(y, x * (n - n // 2))\\n        else:\\n            return min(f(n + 1), f(n - 1)) + x\\n\\nn, x, y = map(int, input().split())\\n\\nprint(f(n))\", \"def main():\\n    def f(t):\\n        if t & 1:\\n            return x if t == 1 else min(f(t - 1), f(t + 1)) + x\\n        else:\\n            u = x * t\\n            return f(t // 2) + y if y * 2 < u else u\\n\\n    n, x, y = list(map(int, input().split()))\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def main():\\n    def f(t):\\n        u = cache.get(t)\\n        if u is None:\\n            if t & 1:\\n                u = min(f(t - 1), f(t + 1)) + x\\n            else:\\n                u = x * t\\n                if y * 2 < u:\\n                    u = f(t // 2) + y\\n            cache[t] = u\\n        return u\\n\\n    n, x, y = list(map(int, input().split()))\\n    cache = {1: x}\\n    print(f(n))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, a, b = input().split(' ')\\nn = int(n)\\na = int(a)\\nb = int(b)\\ntk = tk2 = dk = dk2 = hg = hg2 = tag = tag2 = k1 = k2 = 0\\nkg = n\\nwhile kg >= 2:\\n    if kg % 2 != 0:\\n        tag = 1\\n        if tag == 1 and (kg-kg//2-1)*a < b:\\n            break\\n        hg2 = kg\\n        hg = (kg+1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg-hg//2-1)*a < b:\\n                break\\n            if tag2 == 0 and (hg-hg//2)*a < b:\\n                break\\n            if hg % 2 != 0:\\n                tk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            tk += 1\\n        t0 = b*tk + a*hg + a*tk2\\n        tag2 = 0\\n        hg = (hg2 - 1)//2\\n        while hg >= 2:\\n            if hg % 2 != 0:\\n                tag2 = 1\\n            if tag2 == 1 and (hg - hg//2 - 1) * a < b:\\n                break\\n            if tag2 == 0 and (hg - hg//2) * a < b:\\n                break\\n            if hg % 2 != 0:\\n                dk2 += 1\\n            hg //= 2\\n            tag2 = 0\\n            dk += 1\\n        t1 = b*dk + a*hg + a*dk2\\n        if t0 <= t1:\\n            kg += 1\\n        else:\\n            kg -= 1\\n        tk = tk2 = dk = dk2 = hg2 = 0\\n    if tag == 1:\\n        k2 += 1\\n    if (kg-kg//2)*a <= b:\\n        break\\n    kg //= 2\\n    tag = 0\\n    k1 += 1\\nt = b*k1 + k2*a + kg*a\\nprint(t)\\n\", \"def fi(n):\\n    if n == 1:\\n        return x\\n    elif n == 2:\\n        return x + min(x, y)\\n    else:\\n        if n % 2 == 1:\\n            return min(fi(n-1), fi(n+1)) + x\\n        else:\\n            return fi(n//2) + min(y, x * (n//2))\\n        \\nn,x,y = map(int, input().split())\\nprint(fi(n))\", \"__author__ = 'Think'\\nn, x, y=[int(i) for i in input().split()]\\ndef worth(num):\\n\\tif num%2==0:\\n\\t\\tdub=y\\n\\t\\talt=x*(num//2)\\n\\telse:\\n\\t\\tdub=y+x\\n\\t\\talt=x*((num//2)+1)\\n\\treturn dub<alt, dub, alt\\n\\ntime=0\\nwhile n>0:\\n\\tparity=n%2\\n\\tshould_double, dub, alt=worth(n)\\n\\tif should_double:\\n\\t\\ttime+=dub\\n\\t\\tif parity==0:\\n\\t\\t\\t# print(\\\"Doubled, even,\\\", n, n//2, time)\\n\\t\\t\\tn=n//2\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\thalf=n//2\\n\\t\\t\\tif half%2==0:\\n\\t\\t\\t\\t# print(\\\"Doubled, 1 mod 4,\\\", n, half, time)\\n\\t\\t\\t\\tn=half\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif ((half//2+1)*x+y)<half*x:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, continued\\\", n, half+1, time)\\n\\t\\t\\t\\t\\tn=half+1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t# print(\\\"Doubled, 3 mod 4, end\\\", n, half, time)\\n\\t\\t\\t\\t\\ttime+=half*x\\n\\t\\t\\t\\t\\tbreak\\n\\telse:\\n\\t\\t# print(\\\"Haven't doubled, \\\", n, time)\\n\\t\\ttime+=n*x\\n\\t\\tbreak\\n\\nprint(time)\\n\\n\\n\\n\\n\", \"#import sys\\n#sys.stdin = open('in', 'r')\\n#n = int(input())\\n#a = [int(x) for x in input().split()]\\n\\nn,x,y = list(map(int, input().split()))\\nimport heapq\\nh = []\\nd = {}\\nheapq.heappush(h, (0, n))\\n\\n\\nr = -1\\nwhile r == -1:\\n    xh,nh = heapq.heappop(h)\\n    if nh not in d:\\n        d[nh] = xh\\n        if nh == 1:\\n            r = xh + x\\n        elif nh * x < y:\\n            r = xh + nh*x\\n        else:\\n            if (nh - 1) not in d:\\n                heapq.heappush(h, (xh + x, nh - 1))\\n            if nh & 1 == 0 and (nh // 2) not in d and y < (nh//2)*x:\\n                heapq.heappush(h, (xh + y, nh // 2))\\n            if (nh + 1) not in d:\\n                heapq.heappush(h, (xh + x, nh + 1))\\n            \\n            \\n\\nprint(r)\\n\", \"import sys\\nsys.setrecursionlimit(1000000)\\n\\ndef f(dp,x,y,n):\\n    if dp[n]!=-1:\\n        return dp[n]   \\n    if n%2==1:\\n        ans=x+min(f(dp,x,y,n-1) ,f(dp,x,y,n+1))\\n    else:\\n        ans=f(dp,x,y,n//2)+min(y,x*n//2)\\n    dp[n]=ans\\n    return ans\\n\\nn,x,y=list(map(int,input().split()))\\ndp=[-1 for i in range(n+10)]\\ndp[1]=x\\nprint(f(dp,x,y,n))\\n\"]",
        "difficulty": "interview",
        "input": "9999991 2 3\n",
        "output": "88\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/710/E"
    },
    {
        "id": 1490,
        "task_id": 838,
        "test_case_id": 1,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 1\n0\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1491,
        "task_id": 838,
        "test_case_id": 2,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "2 3\n1 0 1\n0 1 0\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1492,
        "task_id": 838,
        "test_case_id": 3,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "2 2\n1 1\n1 1\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1493,
        "task_id": 838,
        "test_case_id": 4,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 10\n0 0 0 0 0 0 0 0 0 0\n",
        "output": "1023\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1494,
        "task_id": 838,
        "test_case_id": 5,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "11 1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n",
        "output": "2047\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1495,
        "task_id": 838,
        "test_case_id": 6,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "10 11\n1 1 0 1 1 0 0 0 1 0 0\n1 0 0 1 1 1 0 0 1 1 0\n0 0 1 0 1 1 0 1 0 1 1\n0 1 1 1 0 1 0 1 0 0 0\n1 1 1 1 1 1 1 0 1 0 0\n1 1 0 1 1 1 1 0 0 1 1\n1 0 1 0 1 0 0 1 1 1 0\n1 1 0 0 0 0 0 1 0 1 1\n1 1 0 1 1 1 0 0 1 1 0\n1 0 1 1 0 0 1 0 0 1 1\n",
        "output": "2444\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1496,
        "task_id": 838,
        "test_case_id": 7,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "50 1\n0\n1\n0\n1\n0\n1\n0\n1\n1\n1\n0\n0\n1\n0\n0\n1\n1\n1\n1\n0\n1\n1\n0\n1\n1\n1\n0\n1\n0\n0\n0\n1\n1\n0\n1\n1\n0\n1\n0\n1\n0\n0\n1\n0\n0\n0\n1\n1\n0\n1\n",
        "output": "142606334\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1497,
        "task_id": 838,
        "test_case_id": 8,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 50\n0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 1 1 0 1\n",
        "output": "142606334\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1498,
        "task_id": 838,
        "test_case_id": 9,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "2 20\n0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0\n",
        "output": "589853\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1499,
        "task_id": 838,
        "test_case_id": 10,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "5 5\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n",
        "output": "285\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1500,
        "task_id": 838,
        "test_case_id": 11,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "6 6\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n1 1 1 1 1 1\n",
        "output": "720\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1501,
        "task_id": 838,
        "test_case_id": 12,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "21 2\n0 1\n1 1\n0 1\n0 0\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n",
        "output": "1310745\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1502,
        "task_id": 838,
        "test_case_id": 13,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "3 15\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 1 0 1 0 0 0 0 0 1 0\n1 0 0 1 0 0 0 0 0 0 0 0 1 0 1\n",
        "output": "22587\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1503,
        "task_id": 838,
        "test_case_id": 14,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "10 11\n0 1 0 0 0 0 0 0 0 0 0\n0 1 0 1 0 0 1 0 0 0 0\n0 0 0 0 0 0 1 1 1 0 0\n0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 1 0 0 0 0 1 0\n0 0 0 0 0 0 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 1 0\n0 0 1 0 0 0 1 1 0 0 0\n0 0 0 0 0 0 0 0 1 0 0\n0 0 1 0 1 0 0 0 0 1 1\n",
        "output": "12047\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1504,
        "task_id": 838,
        "test_case_id": 15,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "14 15\n0 1 0 0 0 0 0 0 1 0 0 0 1 0 1\n0 0 0 1 1 1 1 0 1 0 0 1 1 0 0\n1 0 0 0 0 1 1 0 0 0 0 0 0 0 0\n0 1 0 0 0 1 0 1 1 0 0 1 0 0 0\n0 0 1 1 0 1 0 1 0 1 1 0 1 0 0\n0 0 0 1 1 0 0 0 0 0 1 1 0 1 0\n0 0 1 0 0 0 0 0 0 1 0 0 1 1 0\n1 1 0 0 0 1 0 0 0 0 0 0 1 1 0\n0 0 0 0 1 0 1 1 1 0 0 0 1 0 1\n1 0 1 1 0 1 0 0 1 0 0 1 1 1 0\n1 0 0 0 0 1 0 0 0 0 0 1 0 0 0\n0 0 0 1 0 1 0 0 0 0 1 0 0 0 1\n0 0 1 0 1 0 0 0 1 1 1 1 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 1 0 0 0\n",
        "output": "53166\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1505,
        "task_id": 838,
        "test_case_id": 16,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 50\n0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0\n",
        "output": "1099511628798\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1506,
        "task_id": 838,
        "test_case_id": 17,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "50 1\n0\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n0\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n0\n1\n1\n1\n1\n1\n1\n1\n0\n1\n1\n1\n1\n0\n1\n1\n1\n1\n1\n",
        "output": "35184372088862\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1507,
        "task_id": 838,
        "test_case_id": 18,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "1125899906842623\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1508,
        "task_id": 838,
        "test_case_id": 19,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "5 50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "5629499534214415\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1509,
        "task_id": 838,
        "test_case_id": 20,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "32 2\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n",
        "output": "8589934622\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1510,
        "task_id": 838,
        "test_case_id": 21,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 50\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "562949953421312\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1511,
        "task_id": 838,
        "test_case_id": 22,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "50 1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n",
        "output": "1125899906842623\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1512,
        "task_id": 838,
        "test_case_id": 23,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 49\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "562949953421311\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1513,
        "task_id": 838,
        "test_case_id": 24,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "2 50\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
        "output": "2251799813685296\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1514,
        "task_id": 838,
        "test_case_id": 25,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "3 50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "3377699720528069\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1515,
        "task_id": 838,
        "test_case_id": 26,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 50\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
        "output": "1125899906842623\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1516,
        "task_id": 838,
        "test_case_id": 27,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 40\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "1099511627775\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1517,
        "task_id": 838,
        "test_case_id": 28,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 33\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "8589934591\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1518,
        "task_id": 838,
        "test_case_id": 29,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "2 40\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
        "output": "2199023255590\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1519,
        "task_id": 838,
        "test_case_id": 30,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "1 35\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "34359738367\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1520,
        "task_id": 838,
        "test_case_id": 31,
        "question": "You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n  All cells in a set have the same color.  Every two cells in a set share row or column. \n\n\n-----Input-----\n\nThe first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.\n\nThe next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.\n\n\n-----Output-----\n\nOutput single integer  — the number of non-empty sets from the problem description.\n\n\n-----Examples-----\nInput\n1 1\n0\n\nOutput\n1\n\nInput\n2 3\n1 0 1\n0 1 0\n\nOutput\n8\n\n\n\n-----Note-----\n\nIn the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.",
        "solutions": "[\"read = lambda: map(int, input().split())\\nn, m = read()\\na = [list(read()) for i in range(n)]\\nans = n * m\\nfor i in range(n):\\n    cnt0 = a[i].count(0)\\n    cnt1 = a[i].count(1)\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nfor i in range(m):\\n    cnt0 = sum(a[j][i] == 0 for j in range(n))\\n    cnt1 = sum(a[j][i] == 1 for j in range(n))\\n    if cnt0 > 1: ans += (2 ** cnt0 - cnt0 - 1)\\n    if cnt1 > 1: ans += (2 ** cnt1 - cnt1 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\narr = [[0 for i in range(m)] for i in range(n)]\\nfor i in range(n):\\n\\tarr[i] = list(map(int, input().split()))\\nans = n * m\\nfor i in range(n):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(m):\\n\\t\\tif arr[i][j] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nfor i in range(m):\\n\\tc0 = 0\\n\\tc1 = 0\\n\\tfor j in range(n):\\n\\t\\tif arr[j][i] == 1:\\n\\t\\t\\tc1 += 1\\n\\t\\telse:\\n\\t\\t\\tc0 += 1\\n\\tans += max(0, 2 ** (c1) - c1 - 1)\\n\\tans += max(0, 2 ** (c0) - c0 - 1)\\nprint(ans)\", \"n, m = list(map(int, input().split()))\\ntbl = [list(map(int, input().split())) for _ in range(n)]\\n\\nans = 0\\nfor i in range(n):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(m):\\n        if tbl[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nfor i in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for j in range(n):\\n        if tbl[j][i] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    ans += 2**c0 - 1\\n    ans += 2**c1 - 1\\nans -= n * m\\nprint(ans)\\n\", \"3\\n\\nn, m = [int(i) for i in input().split()]\\na = [[int(i) for i in input().split()] for j in range(n)]\\ns = n * m\\nfor i in range(n):\\n\\tblack = sum(a[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = m - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nb = [[a[i][j] for i in range(n)] for j in range(m)]\\nfor i in range(m):\\n\\tblack = sum(b[i])\\n\\tif black > 1:\\n\\t\\ts += 2 ** black - black - 1\\n\\twhite = n - black\\n\\tif white > 1:\\n\\t\\ts += 2 ** white - white - 1\\n\\nprint(s)\", \"n, m = list(map(int, input().split()))\\nd = [list(map(int, input().split())) for i in range(n)]\\n\\nans = 0\\nfor p in d:\\n    x = sum(p)\\n    ans += pow(2, x) + pow(2, m - x) - 2 - m\\n\\nfor i in range(m):\\n    x = sum(d[j][i] for j in range(n))\\n    ans += pow(2, x) + pow(2, n - x) - 2\\n\\nprint(ans)\\n\", \"def sol():\\n\\trows, cols = map(int, input().split())\\n\\ttab = [list(map(int, input().split())) for _ in range(rows)]\\n\\tres = rows * cols\\n\\tfor row in range(rows):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor col in range(cols):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tfor col in range(cols):\\n\\t\\twhite = 0\\n\\t\\tblack = 0\\n\\t\\tfor row in range(rows):\\n\\t\\t\\tif tab[row][col] == 0:\\n\\t\\t\\t\\twhite += 1\\n\\t\\t\\telse: \\n\\t\\t\\t\\tblack += 1\\n\\t\\tif white > 0:\\n\\t\\t\\tres += pow(2, white) - white - 1\\n\\t\\tif black > 0:\\n\\t\\t\\tres += pow(2, black) - black - 1\\n\\tprint(res)\\nsol()\", \"n,m = map(int, input().split())\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\n    \\nans = 0\\nfor i in range(n):\\n    l = sum([1 for e in a[i] if e == 0])\\n    nl = m - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n\\nfor i in range(m):\\n    l = 0\\n    for j in range(n):\\n        if a[j][i] == 0:\\n            l += 1\\n    nl = n - l\\n    ans += (2**l - 1 - l) + (2**nl - 1 - nl)\\n    \\nprint(ans + n*m)\", \"n,m=list(map(int,input().split()))\\nl=[]\\nfor i in range(n):\\n    l.append(list(map(int,input().split())))\\nans=0\\nfor i in range(n):\\n    r=l[i]\\n    c1=r.count(1)\\n    c2=r.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1))\\nfor i in range(m):\\n    ls=[]\\n    for j in range(n):\\n        ls.append(l[j][i])\\n    c1=ls.count(1)\\n    c2=ls.count(0)\\n    ans+=(((2**c1)-1)+((2**c2)-1)-c1-c2)\\nprint(ans)\\n\", \"n,m=list(map(int,input().split()))\\nrc=[]\\ncc=[]\\ncols=[[] for i in range(m)]\\nfor i in range(n):\\n    a=list(map(int,input().split()))\\n    for i in range(len(a)):\\n        cols[i].append(a[i])\\n    rc.append([a.count(1),a.count(0)])\\nfor i in cols:\\n    cc.append([i.count(1),i.count(0)])\\n\\ntotal=0\\nfor i in rc:\\n    total+=(2**i[0])-1+(2**i[1])-1\\nfor i in cc:\\n    total+=(2**i[0]-1-i[0])+(2**i[1]-1-i[1])\\nprint(total)\\n                \\n\", \"n,m = map(int,input().split())\\n\\ngrid = [None]*n\\n\\nfor i in range(n):\\n  grid[i] = list(map(int, input().split()))\\n\\nresult = 0\\n\\nfor i in range(n):\\n  t = sum(grid[i])\\n  result += 2**t + 2**(m-t)\\n\\nfor i in range(m):\\n  t = sum(grid[j][i] for j in range(n))\\n  result += 2**t + 2**(n-t)\\n\\nresult -= 2*(n+m) + n*m\\n\\nprint(result)\", \"from sys import stdin, stdout\\nimport random\\n\\n\\nn,m = list(map(int,stdin.readline().rstrip().split()))\\ntable = []\\nfor _ in range(n):\\n    table.append(list(map(int,stdin.readline().rstrip().split())))\\n\\ntable2 = [[0]*n for _ in range(m)]\\nfor i in range(n):\\n    for j in range(m):\\n        table2[j][i] = table[i][j]\\n\\ntotalSets = 0\\nfor i in range(n):\\n    if sum(table[i])>1:\\n        totalSets+=(2**sum(table[i]))-1-sum(table[i])\\n    if sum(table[i])<m-1:\\n        totalSets+=(2**(m-sum(table[i])))-1-(m-sum(table[i]))\\n    \\nfor i in range(m):\\n    if sum(table2[i])>1:\\n        totalSets+=(2**sum(table2[i]))-1-sum(table2[i])\\n    if sum(table2[i])<n-1:\\n        totalSets+=(2**(n-sum(table2[i])))-1-(n-sum(table2[i]))\\n\\ntotalSets+=(n*m)\\n\\nprint(totalSets)\\n\", \"n, m = map(int, input().split())\\nmat = [list(map(int, input().split())) for i in range(n)]\\nans = 0\\nfor i in range(n):\\n    w = 0\\n    b = 0\\n    for j in range(m):\\n        if mat[i][j] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nfor i in range(m):\\n    w = 0\\n    b = 0\\n    for j in range(n):\\n        if mat[j][i] == 1:\\n            w += 1\\n        else:\\n            b += 1\\n    ans += 2 ** w + 2 ** b - 2\\nprint(ans - n * m)\", \"n, m = map(int, input().split())\\ndata = [[]for i in range(n)]\\ndata2 = [[0] * n for i in range(m)]\\nfor i in range(n):\\n    data[i] = list(map(int, input().split()))\\na = 0\\nfor i in range(m):\\n    for j in range(n):\\n        data2[i][j] = data[j][i]\\nfor i in range(n):\\n    su = sum(data[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if m - su != 0:\\n        a += 2 ** (m - su) - 1\\n\\n\\nfor i in range(m):\\n    su = sum(data2[i])\\n    if su != 0:\\n        a += 2 ** su - 1\\n    if n - su != 0:\\n        a += 2 ** (n - su) - 1\\n\\nprint(a - n * m)\", \"n, m = list(map(int, input().split()))\\nA = [0] * n\\nfor i in range(n):\\n    A[i] = list(map(int, input().split()))\\n\\nres = 0\\nfor i in range(n):\\n    sum1 = sum(A[i])\\n    sum2 = m - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - 2\\nsum1 = 0\\nsum2 = 0\\nfor j in range(m):\\n    for i in range(n):\\n        sum1 += A[i][j]\\n    sum2 = n - sum1\\n    res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2\\n    sum1 = 0\\n    sum2 = 0\\nprint(res)\\n\\n\\n\\n\", \"n, m = [int(i) for i in input().split()]\\nrow_one = [0 for i in range(n)]\\ncolumn_one = [0 for i in range(m)]\\nfor i in range(n):\\n    tmp = [int(j) for j in input().split()]\\n    row_one[i] = sum(tmp)\\n    for j in range(m):\\n        column_one[j] += tmp[j]\\nrow_zero = [m - i for i in row_one]\\ncolumn_zero = [n - i for i in column_one]\\nans = 0\\nfor i in row_zero:\\n    ans += (1 << i)\\nfor i in column_zero:\\n    ans += (1 << i)\\nfor i in row_one:\\n    ans += (1 << i)\\nfor i in column_one:\\n    ans += (1 << i)\\nans = ans - 2*(m+n) - m*n\\nprint(ans)\", \"n,m=map(int,input().split())\\na=[]\\nb=[]\\nans =0 \\nfor i in range(n):   \\n    a.append(0)\\nfor i in range(m):\\n    b.append(0)\\nfor i in range(n):\\n    l=list(map(int,input().split()))\\n    for j in range(m):\\n        a[i]=a[i]+l[j]\\n        b[j]=b[j]+l[j]\\nfor i in range(n):   \\n    ans=ans+2**a[i]-1+2**(m-a[i])-1\\nfor i in range(m):\\n    ans=ans+2**b[i]-1+2**(n-b[i])-1\\nans=ans-n*m\\nprint(ans)\", \"n,m = input().split()\\nn = int(n)\\nm = int(m)\\ncnt = 0\\nb = []\\nfor i in range(n):\\n    a = [int(x) for x in input().split()]\\n    b.append(a)\\n    a = sum(a)\\n    cnt += (1<<a) + (1<<(m-a)) - 2\\nfor i in range(m):\\n    x = 0\\n    for j in range(n):\\n        x = x + b[j][i]\\n    cnt = cnt + (1<<x) + (1<<(n-x)) - 2\\n\\ncnt -= n*m\\nprint(cnt)\\n\", \"n, m = list(map(int, input().split()))\\n\\nmtx = []\\nfor _ in range(n):\\n    mtx.append(list(map(int, input().split())))\\n\\nres = 0\\nfor i in range(n):\\n    a = sum(mtx[i])\\n    b = m - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nfor j in range(m):\\n    a = sum(mtx[i][j] for i in range(n))\\n    b = n - a\\n    if a >= 1:\\n        res += 2 ** a - 1\\n    if b >= 1:\\n        res += 2 ** b - 1\\n\\nres -= n * m\\nprint(res)\\n\", \"n, m = map(int, input().split())\\na = [list(map(int, input().split())) for i in range(n)]\\ncol = [[0, 0] for i in range(m)]\\nrow = [[0, 0] for i in range(n)]\\nfor i in range(n):\\n    summa = sum(a[i])\\n    row[i] = [summa, m - summa]\\n\\nfor i in range(m):\\n    summa = 0\\n    for j in range(n):\\n        summa += a[j][i]\\n    col[i] = [summa, n - summa]\\n\\nres = 0\\nfor i in row:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nfor i in col:\\n    res += (2 ** i[0]) + (2 ** i[1]) - 2\\n\\nres -= n *m\\nprint(res)\", \"from math import factorial\\ndef c(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n    \\nn, m = map(int, input().split())\\nans = 0\\na = [list(map(int, input().split())) for i in range(n)]\\nfor i in range(n):\\n    c0, c1 = 0, 0\\n    for j in range(m):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for j in range(1, c0 + 1):\\n        ans += c(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += c(c1, j)\\nfor j in range(m):\\n    c0, c1 = 0, 0\\n    for i in range(n):\\n        if a[i][j]:\\n            c1 += 1\\n        else:\\n            c0 += 1\\n    for i in range(2, c0 + 1):\\n        ans += c(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += c(c1, i)\\nprint(ans)\", \"import sys\\nn, m = list(map(int, input().split()))\\na = []\\nfor i in range(n):\\n    a.append(list(map(int, input().split())))\\nc1 = []\\nc2 = []\\nfor i in range(n):\\n    c1.append(a[i].count(1))\\nfor i in range(m):\\n    c = 0\\n    for j in range(n):\\n        if a[j][i] == 1:\\n            c+= 1\\n    c2.append(c)\\ns = 0\\nfor i in c1:\\n    s +=2**i-2+2**(m-i)\\nfor i in c2:\\n    s +=2**i-2+2**(n-i)\\ns -=n*m\\nprint(s)\\n\", \"import math\\nsplit = lambda: list(map(int, input().split()))\\na, b = split()\\nrows = [split() for x in range(a)]\\ncolumns = [[x[y] for x in rows] for y in range(b)]\\ndef choose(p, q):\\n    n = 1\\n    for x in range(p - q + 1, p + 1):\\n        n *= x\\n    n //= math.factorial(q)\\n    return n\\ns = 0\\nfor x in rows + columns:\\n    p, q = x.count(0), x.count(1)\\n    for y in range(1, p + 1):\\n        s += choose(p, y)\\n    for y in range(1, q + 1):\\n        s += choose(q, y)\\ns -= a * b\\nprint(s)\", \"def solution():\\n    ans = 0\\n    n, m = map(int, input().split())\\n    matrix = []\\n    for i in range(n):\\n        matrix.append([int(j) for j in input().split()])\\n        \\n    for i in range(n):\\n        count = 0\\n        for j in range(m):\\n            if matrix[i][j] == 1:\\n                count += 1\\n        ans += 2**count - 1\\n        count = m - count\\n        ans += 2**count - 1\\n    \\n    for j in range(m):\\n        count = 0\\n        for i in range(n):\\n            if matrix[i][j] == 1:\\n                    count += 1\\n        \\n        if count > 1:\\n            ans += 2**count - 1 - count\\n        \\n        count = n - count\\n        if count > 1:\\n            ans += 2**count - 1 - count\\n    print(ans)\\n    \\nsolution()\", \"from math import factorial\\n\\ndef count(n, k):\\n    return factorial(n) // (factorial(k) * factorial(n - k))\\n\\nn, m = map(int, input().split())\\ntable = []\\nfor i in range(n):\\n    table.append(list(map(int, input().split())))\\nans = 0\\nfor i in range(n):\\n    c0 = table[i].count(0)\\n    c1 = table[i].count(1)\\n    for j in range(1, c0 + 1):\\n        ans += count(c0, j)\\n    for j in range(1, c1 + 1):\\n        ans += count(c1, j)\\nfor j in range(m):\\n    c0 = 0\\n    c1 = 0\\n    for i in range(n):\\n        if table[i][j] == 0:\\n            c0 += 1\\n        else:\\n            c1 += 1\\n    for i in range(2, c0 + 1):\\n        ans += count(c0, i)\\n    for i in range(2, c1 + 1):\\n        ans += count(c1, i)\\nprint(ans)\", \"n, m = map(int, input().split())\\n\\na = [list(map(int, input().split())) for _ in range(n)]\\n\\ns = 0\\n\\nfor l in a:\\n    k = sum(l)\\n    s += 2**k - 1\\n    s += 2**(m-k) - 1\\n\\nfor i in range(m):\\n    k = sum(l[i] for l in a)\\n    s += 2**k - 1 - k\\n    s += 2**(n-k) - 1 - (n-k)\\n\\nprint(s)\"]",
        "difficulty": "interview",
        "input": "50 1\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n",
        "output": "1125899906842623\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/844/B"
    },
    {
        "id": 1521,
        "task_id": 858,
        "test_case_id": 1,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "1\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1522,
        "task_id": 858,
        "test_case_id": 2,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "3\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1523,
        "task_id": 858,
        "test_case_id": 3,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "2\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1524,
        "task_id": 858,
        "test_case_id": 4,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "4\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1525,
        "task_id": 858,
        "test_case_id": 5,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "5\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1526,
        "task_id": 858,
        "test_case_id": 6,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "6\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1527,
        "task_id": 858,
        "test_case_id": 7,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "7\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1528,
        "task_id": 858,
        "test_case_id": 8,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "8\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1529,
        "task_id": 858,
        "test_case_id": 9,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "9\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1530,
        "task_id": 858,
        "test_case_id": 10,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1531,
        "task_id": 858,
        "test_case_id": 11,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "11\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1532,
        "task_id": 858,
        "test_case_id": 12,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "12\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1533,
        "task_id": 858,
        "test_case_id": 13,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "13\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1534,
        "task_id": 858,
        "test_case_id": 14,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "14\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1535,
        "task_id": 858,
        "test_case_id": 15,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "15\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1536,
        "task_id": 858,
        "test_case_id": 16,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "16\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1537,
        "task_id": 858,
        "test_case_id": 17,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "17\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1538,
        "task_id": 858,
        "test_case_id": 18,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "18\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1539,
        "task_id": 858,
        "test_case_id": 19,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "19\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1540,
        "task_id": 858,
        "test_case_id": 20,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "20\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1541,
        "task_id": 858,
        "test_case_id": 21,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "99\n",
        "output": "49\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1542,
        "task_id": 858,
        "test_case_id": 22,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "100\n",
        "output": "18\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1543,
        "task_id": 858,
        "test_case_id": 23,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "9999\n",
        "output": "4999\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1544,
        "task_id": 858,
        "test_case_id": 24,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "21736\n",
        "output": "2676\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1545,
        "task_id": 858,
        "test_case_id": 25,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "873467\n",
        "output": "436733\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1546,
        "task_id": 858,
        "test_case_id": 26,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "4124980\n",
        "output": "1013914\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1547,
        "task_id": 858,
        "test_case_id": 27,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "536870910\n",
        "output": "134217727\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1548,
        "task_id": 858,
        "test_case_id": 28,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "536870912\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1549,
        "task_id": 858,
        "test_case_id": 29,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "876543210\n",
        "output": "169836149\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1550,
        "task_id": 858,
        "test_case_id": 30,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "987654321\n",
        "output": "493827160\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1551,
        "task_id": 858,
        "test_case_id": 31,
        "question": "Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?\n\nThe brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N - 1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.\n\n\n-----Input-----\n\nThe only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 10^9).\n\n\n-----Output-----\n\nOutput one integer: the smallest number of brains in the chest which allows Heidi to merely survive.\n\n\n-----Examples-----\nInput\n1\n\nOutput\n0\n\nInput\n3\n\nOutput\n1\n\nInput\n99\n\nOutput\n49",
        "solutions": "[\"import math \\na = int(input())\\nif a%2==1:\\n    print(math.ceil((a-1)/2))\\nelse:\\n    z = 1\\n    while z*2<=a:\\n        z*=2\\n    print((a-z)//2)\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\\n\", \"from math import log2, floor\\nN = int(input())\\nif N % 2 == 0:\\n    N //= 2\\n    ans = N - 2 ** floor(log2(N))\\nelse:\\n    ans = (N+1) // 2 - 1\\nprint(ans)\", \"n = int(input())\\nif n & 1:\\n    print(n//2)\\nelse:\\n    k = 1\\n    while k <= n:\\n        k *= 2\\n    print((n - k//2)//2)\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\nelse:\\n    x = 1\\n    while (x <= n):\\n        x *= 2\\n    print((n - x // 2) // 2)\\n\\n\", \"n = int(input())\\nif (n % 2 == 1):\\n    print(n // 2)\\n    return\\ni = 1\\nwhile (i <= n):\\n    i *= 2\\ni //= 2\\nn -= i\\nprint(n // 2)\", \"import math\\n\\nN = int(input().split()[0])\\nif N % 2:\\n    print (int((N-1)/2))\\nelse:\\n    print(int((N - pow(2, int(math.log2(N))))/2))\", \"n = int(input())\\nans = -1\\nif n % 2 == 1:\\n    ans = (n - 1) // 2\\nelse:\\n    two = 1\\n    while two * 2 <= n:\\n        two *= 2\\n    ans = (n - two) // 2\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "1000000000\n",
        "output": "231564544\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/690/A2"
    },
    {
        "id": 1552,
        "task_id": 937,
        "test_case_id": 13,
        "question": "Your friend Mishka and you attend a calculus lecture. Lecture lasts n minutes. Lecturer tells a_{i} theorems during the i-th minute.\n\nMishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are given an array t of Mishka's behavior. If Mishka is asleep during the i-th minute of the lecture then t_{i} will be equal to 0, otherwise it will be equal to 1. When Mishka is awake he writes down all the theorems he is being told — a_{i} during the i-th minute. Otherwise he writes nothing.\n\nYou know some secret technique to keep Mishka awake for k minutes straight. However you can use it only once. You can start using it at the beginning of any minute between 1 and n - k + 1. If you use it on some minute i then Mishka will be awake during minutes j such that $j \\in [ i, i + k - 1 ]$ and will write down all the theorems lecturer tells.\n\nYou task is to calculate the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up.\n\n\n-----Input-----\n\nThe first line of the input contains two integer numbers n and k (1 ≤ k ≤ n ≤ 10^5) — the duration of the lecture in minutes and the number of minutes you can keep Mishka awake.\n\nThe second line of the input contains n integer numbers a_1, a_2, ... a_{n} (1 ≤ a_{i} ≤ 10^4) — the number of theorems lecturer tells during the i-th minute.\n\nThe third line of the input contains n integer numbers t_1, t_2, ... t_{n} (0 ≤ t_{i} ≤ 1) — type of Mishka's behavior at the i-th minute of the lecture.\n\n\n-----Output-----\n\nPrint only one integer — the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up.\n\n\n-----Example-----\nInput\n6 3\n1 3 5 2 5 4\n1 1 0 1 0 0\n\nOutput\n16\n\n\n\n-----Note-----\n\nIn the sample case the better way is to use the secret technique at the beginning of the third minute. Then the number of theorems Mishka will be able to write down will be equal to 16.",
        "solutions": "[\"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nmask = list(map(int, input().split()))\\n\\nresult = sum(a[i] if mask[i] == 1 else 0 for i in range(n))\\n\\nh = [a[i] if mask[i] == 0 else 0 for i in range(len(a))]\\nbest_awake = sum(h[:k])\\ncurr = best_awake\\nfor j in range(k, n):\\n    curr += h[j]\\n    curr -= h[j - k]\\n    best_awake = max(best_awake, curr)\\nprint(result + best_awake)\\n\", \"\\n\\nimport sys\\nn,k=list(map(int,input().split()))\\n\\nl=list(map(int,input().split()))\\nt=list(map(int,input().split()))\\nif(k>n):\\n    print(sum(l))\\n    return\\nbase=0\\nfor i in range(n):\\n    if(t[i]==1):\\n        base+=l[i]\\n        l[i]=0\\nmax1=0\\ncur=sum(l[:k])\\nmax1=cur\\nfor i in range(k,n):\\n    cur-=l[i-k]\\n    cur+=l[i]\\n    max1=max(cur,max1)\\nprint(max1+ base)\\n\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\ns = [0] * (n-k+1)\\nres = 0\\n\\nfor i in range(n):\\n    if t[i]== 1:\\n        res += a[i]\\n\\nfor i in range(k):\\n    if t[i]==0:\\n        s[0] += a[i]\\n\\nfor i in range(1, n-k+1):\\n    w = 0\\n    if (t[i - 1] == 0): \\n        w -= a[i - 1]\\n    if (t[i + k - 1] == 0):\\n        w += a[i + k - 1]\\n    s[i] = s[i - 1] + w\\n\\nprint(res + max(s))\", \"n,k = list(map(int,input().split()))\\n\\nA = [int(x) for x in input().split()]\\nT = [int(x) for x in input().split()]\\n\\nthe = 0\\n\\nfor i in range(n):\\n    if T[i]:\\n        the += A[i]\\n        A[i] = 0\\n\\ns = sum(A[:k])\\nboost = s\\nfor i in range(k,n):\\n    s = s - A[i-k] + A[i]\\n    boost = max(s,boost)\\n\\nprint(the+boost)\\n\", \"import atexit\\nimport io\\nimport sys\\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, k = [int(x) for x in input().split()]\\n    a = [int(x) for x in input().split()]\\n    t = [int(x) for x in input().split()]\\n    \\n    mx = 0\\n    for i in range(n):\\n        if i < k:\\n            mx += a[i]\\n        else:\\n            mx += a[i] * t[i]\\n    \\n    xx = mx\\n    for i in range(n):\\n        if i + k >= n:\\n            break\\n        xx -= a[i]\\n        xx += a[i]*t[i]\\n        xx += a[i+k]\\n        xx -= a[i+k]*t[i+k]\\n        mx =max(xx,mx)\\n        \\n    print(mx)\\n    \\n    \\n\\n    \\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\nc = list(map(int,input().split()))\\ns = 0\\nss = 0\\nfor i in range(n):\\n    if c[i] == 1:ss += a[i]\\nfor i in range(k):\\n    if c[i] == 0:\\n        s += a[i]\\nm = s\\n#print(s)\\nfor i in range(n-k):\\n    if c[i] == 0:\\n        s -= a[i]\\n    if c[i+k] == 0:\\n        s += a[i+k]\\n    m = max(m,s)\\n    #print(s)\\nprint(ss+m)\\n\", \"\\nn, m = list(map(int,input().split()))\\na = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\n\\ns = [0]*n\\nif b[0]==0:\\n\\ts[0] = a[0]\\nsu = 0\\nfor i in range(n):\\n\\tif b[i]==1:\\n\\t\\tsu+=a[i]\\nfor i in range(1,n):\\n\\tif b[i]==0:\\n\\t\\ts[i] = a[i]\\nmax_init_sum = init_sum = sum(s[:m])\\nk = m\\nfor i in range(k, n):\\n\\tinit_sum = init_sum - s[i-k] + s[i]\\n\\t#print (init_sum, s[i-k], s[k])\\n\\tmax_init_sum = max(max_init_sum, init_sum)\\nprint(max_init_sum+su)\\n\", \"n, k = map(int, input().split())\\nA = list(map(int, input().split()))\\nT = list(map(int, input().split()))\\n\\ngain = [0] * (n-k+1)\\nfor i in range(k):\\n    if T[i] == 0:\\n        gain[0] += A[i]\\n\\nfor i in range(1, n-k+1):\\n    gain[i] = gain[i-1]\\n    if T[i-1] == 0:\\n        gain[i] -= A[i-1]\\n    if T[i+k-1] == 0:\\n        gain[i] += A[i+k-1]\\n\\nsum = 0\\nfor i in range(n):\\n    if T[i] == 1:\\n        sum += A[i]\\n\\nprint(sum + max(gain))\", \"from collections import Counter\\n\\ndef main():\\n    n, k = list(map(int, input().split()))\\n    a = list(map(int, input().split()))\\n    t = list(map(int, input().split()))\\n    print(solve(n, k, a, t))\\n\\ndef solve(n, k, a, t):\\n    minsum = sum(ai for ai, ti in zip(a,t) if ti == 1)\\n    inc = sum(ai for ai, ti in zip(a[:k], t[:k]) if ti == 0)\\n    best_inc = inc\\n    for i in range(1, n - k + 1):\\n        if t[i - 1] == 0:\\n            inc -= a[i - 1]\\n        if t[i + k - 1] == 0:\\n            inc += a[i + k - 1]\\n        if inc > best_inc:\\n            best_inc = inc\\n    return minsum + best_inc\\n\\nmain()\\n\", \"R = lambda: list(map(int, input().split()))\\nn, k = R()\\na = R()\\nt = R()\\n\\ng = 0\\nfor i in range(n):\\n\\tif t[i]:\\n\\t\\tg += a[i]\\n\\nl = 0\\nfor i in range(0, k):\\n\\tif t[i] == 0:\\n\\t\\tl += a[i]\\n\\nmax_l = l\\nfor i in range(k, n):\\n\\ta_new = a_old = 0\\n\\tif t[i-k] == 0:\\n\\t\\ta_old = a[i-k]\\n\\tif t[i] == 0:\\n\\t\\ta_new = a[i]\\n\\tl += a_new - a_old\\n\\tmax_l = max(max_l, l)\\n\\t\\t\\nprint(g + max_l)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\nans = sum([a[i] for i in range(n) if t[i] == 1])\\n\\nz = [i for i in range(n) if t[i] == 0]\\nln = len(z)\\n\\nd = 0\\nnow = 0\\nleft, right = 0, -1\\nfor i in range(2 * ln):\\n    if right + 1 < ln and z[right + 1] - z[left] < k:\\n        right += 1\\n\\n        now += a[z[right]]\\n        d = max(d, now)\\n\\n    else:\\n        now -= a[z[left]]\\n\\n        left += 1\\n\\nprint(ans + d)\\n\", \"t = input().split(' ')\\nn = int(t[0])\\nk = int(t[1])\\nA = input().split(' ')\\nB = input().split(' ')\\nfor i in range(len(A)):\\n    A[i] = int(A[i])\\n    B[i] = int(B[i])\\nsm = 0\\nfor i in range(len(B)):\\n    if B[i] == 1:\\n        sm += A[i]\\nmx = 0\\nfor i in range(k):\\n    if B[i] == 0:\\n        mx += A[i]\\ncur = mx\\nfor j in range(n-k):\\n    if B[j] == 0:\\n        cur -= A[j]\\n    if B[j+k] == 0:\\n        cur += A[j+k]\\n    if cur > mx:\\n        mx = cur\\nprint(mx + sm)\\n\", \"def read_data():\\n    n, m = map(int, list(input().strip().split()))\\n    a = list(map(int, list(input().strip().split())))\\n    b = list(map(int, list(input().strip().split())))\\n    return n, m, a, b\\n\\ndef solve():\\n    val = 0\\n    for i in range(n):\\n        if b[i] == 1:\\n            val += a[i]\\n    for i in range(k):\\n        if b[i] == 0:\\n            val += a[i]\\n    i = k\\n    max = val\\n    while i < n:\\n        if b[i-k] == 0:\\n            val -= a[i-k]\\n        if b[i] == 0:\\n            val += a[i]\\n        if val > max:\\n            max = val\\n        i += 1\\n    return max\\n\\nn, k, a, b = read_data()\\nprint(solve())\", \"def potential(a):\\n    return a[0] if a[1] == 0 else 0\\n\\ndef theorems(a):\\n    return a[0] if a[1] == 1 else 0\\n\\nn, k = list(map(int, input().split()))\\nA = list(zip(\\n    list(map(int, input().split())),\\n    list(map(int, input().split())))\\n)\\n\\nawake = 0\\nfor a in A[:k]:\\n    awake += potential(a)\\n\\nbest = awake\\nfor i, a in enumerate(A[k:]):\\n    awake += potential(a)\\n    awake -= potential(A[i])\\n    if awake > best:\\n        best = awake\\n\\nalready = sum(\\n    theorems(a)\\n    for a in A\\n)\\n\\nprint(already + best)\\n\", \"n,k=list(map(int,input().split()))\\nL=list(map(int,input().split()))\\nT=list(map(int,input().split()))\\nout=0\\nfor i in range(n):\\n    if T[i]==1:\\n        out+=L[i]\\n        L[i]=0\\n\\nps=[0]*(n+1)\\nfor i in range(1,n+1):\\n    ps[i]=ps[i-1]+L[i-1]\\nx=0\\nfor i in range(n-k+1):\\n    x=max(x,ps[i+k]-ps[i])\\nprint(x+out)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nc = [0] * n\\nnum1 = 0\\nfor i in range(n):\\n    if b[i] == 0:\\n        c[i] = a[i]\\n    else:\\n        num1 += a[i]\\n\\nnum2 = 0\\ns = sum(c[:k])\\nfor i in range(n - k + 1):\\n    num2 = max(num2, num1 + s)\\n    if i != n - k:\\n        s = s - c[i] + c[i + k]\\n\\nprint(num2)\", \"n,k=[int(x) for x in input().split()[:2]]\\nan=[int(x) for x in input().split()[:n]]\\ntn=[int(x) for x in input().split()[:n]]\\n\\nfirst=0\\nfor i in range(k):\\n    first+=an[i]\\nfor i in range(k,n):\\n    first+=an[i]*tn[i]\\nans=first\\nfor i in range(1,n-k+1):\\n    new=i+k-1\\n    last=i-1\\n    if tn[last]==0:\\n        first-=an[last]\\n    if tn[new]==0:\\n        first+=an[new]\\n    ans=max(first,ans)\\nprint(ans)\", \"n, k =[int(x) for x in input().split()]\\na =[int(x) for x in input().split()] \\nbodr = [int(x) for x in input().split()] \\nsu = 0\\nfor i in range(n):\\n    if bodr[i]:\\n        su += a[i]\\n        a[i] = 0\\nsumma = sum(a[:k])\\nhead = 0\\nmaxi = summa\\nfor i in range(k, n):\\n    summa -= a[head]\\n    head += 1\\n    summa += a[i]\\n    maxi = max(summa, maxi)\\nprint(su + maxi)\", \"L = input().split();\\nn,m = list(map(int,L));\\nL = input().split();\\na = list(map(int,L));\\nL = input().split();\\nt = list(map(int,L));\\nttot = [0]*(n+5);\\nttot[0] = 0;\\nta = [0]*(n+5);\\nta[0] = 0;\\nfor i in range(n):\\n    ttot[i+1] = ttot[i] + a[i];\\n    ta[i+1] = ta[i] + a[i]*t[i];\\nMax = 0;\\nfor i in range(n-m+1):\\n    tmp = ta[i];\\n    tmp = tmp + ttot[i+m]-ttot[i];\\n    tmp = tmp + (ta[n]-ta[i+m]);\\n    if (tmp>Max):\\n        Max = tmp;\\n        pos = i+1;\\n#print(ttot, ta);\\nprint(Max);\\n\", \"import sys;\\n\\nclass MyReader:\\n#    file = null;\\n    def __init__(self):\\n        filename = \\\"file.in\\\";\\n        if self.isLocal():\\n            self.file = open(filename);\\n        self.str = [\\\"\\\"];\\n        self.ind = 1;\\n            \\n    def isLocal(self):\\n        return len(sys.argv) > 1 and sys.argv[1] == \\\"SCHULLZ\\\";\\n\\n    def nextString(self):\\n        if self.isLocal():\\n            return self.file.read();\\n        else:\\n            return input();\\n        \\n    def nextInt(self):\\n        return int(self.nextToken());\\n\\n    def nextToken(self):\\n        if (self.ind >= len(self.str)):\\n            self.ind = 0;\\n            self.str = self.nextString().split();\\n        self.ind += 1;\\n        return self.str[self.ind - 1];\\n\\n\\n\\nrdr = MyReader();\\n\\nn = rdr.nextInt();\\nk = rdr.nextInt();\\n\\na = [];\\nisAwake = [];\\nmissed = [];\\n\\nfor i in range (0, n):\\n    a.append(rdr.nextInt());\\n    \\nawaken = 0;\\n\\nfor i in range (0, n):\\n    isAwake.append(rdr.nextInt());\\n    missed.append(0);\\n    if (0 == isAwake[i]):\\n        missed[i] = a[i];\\n    else:\\n        awaken += a[i];\\n        missed[i] = 0;\\n\\ntres = 0;\\nfor i in range(0, k):\\n    tres += missed[i];\\n\\nres = tres;\\n\\nfor i in range(k, n):\\n    tres -= missed[i - k];\\n    tres += missed[i];\\n    res = max(res, tres);\\n\\n    \\nsys.stdout.write(str(res + awaken));\\n\\nsys.stdout.flush()\", \"n, k = map(int, input().split())\\na = [int(i) for i in input().split()]\\nt = [int(i) for i in input().split()]\\npref_sum = [0] * n\\npref_score = [0] * n\\nfor i in range(n):\\n    pref_sum[i] = pref_sum[i - 1] + a[i]\\n    pref_score[i] = pref_score[i - 1] + a[i] * t[i]\\nans = pref_sum[k - 1] + pref_score[n - 1] - pref_score[k - 1]\\n#print(pref_score, pref_sum)\\nfor i in range(k, n):\\n    ans = max(ans, pref_score[i - k] + pref_score[n - 1] - pref_score[i] + pref_sum[i] - pref_sum[i - k])\\nprint(ans)\", \"def invert(x):\\n    if x == 1:\\n        return 0\\n    else:\\n        return 1\\n\\nn, k = list(map(int, input().strip().split()))\\na = list(map(int, input().strip().split()))\\nt = list(map(int, input().strip().split()))\\n\\nbase = sum([a*b for a,b in zip(a,t)])\\n\\nt = list(map(invert, t))\\nt = [a*b for a,b in zip(a, t)]\\nfor i in range(1, len(t)):\\n    t[i] += t[i-1]\\n\\nrslt = t[k-1]\\nfor i in range(1, n-k+1):\\n    rslt = max(rslt, t[i+k-1] - t[i-1])\\n\\nprint(rslt+base)\\n\", \"n,k=map(int,input().split())\\na=list(map(int,input().split()))\\nb=list(map(int,input().split()))\\nsumx=0\\nsum1=0\\ns=0\\nfor i in range(n):\\n\\tif(b[i]==1):\\n\\t\\tsum1+=a[i]\\nfor i in range(k):\\n\\tif(b[i]==0):\\n\\t\\tsumx+=a[i]\\ns=sumx+sum1\\nfor i in range(k,n):\\n\\tif(b[i-k]==0):\\n\\t\\tsumx-=a[i-k]\\n\\tif(b[i]==0):\\n\\t\\tsumx+=a[i]\\n\\tif(sumx+sum1>s):\\n\\t\\ts=sumx+sum1\\nprint(s)\", \"def calculate_prefix_sum(a, t):\\n    s = [0]\\n    for a_, t_ in zip(a, t):\\n        if not t_:\\n            s += [s[-1] + a_]\\n        else:\\n            s += [s[-1]]\\n    return s\\n\\n\\ndef calculate_sum_on_range(s, a, b):\\n    assert a < b\\n    return s[min(b, len(s)-1)] - s[a]\\n\\n\\ndef calculate_sums(a, t, k):\\n    psum = calculate_prefix_sum(a, t)\\n    s = []\\n\\n    for i in range(len(a)):\\n        s.append(calculate_sum_on_range(psum, i, i+k))\\n\\n    return s\\n\\n\\ndef calculate_max(a, t, k):\\n    s = calculate_sums(a, t, k)\\n    ms = max(s)\\n    return ms\\n\\n\\ndef calculate_answer(a, t, k):\\n    ms = calculate_max(a, t, k)\\n    s = 0\\n    for a_, t_ in zip(a, t):\\n        if t_:\\n            s += a_\\n    return ms + s\\n\\n\\nr=lambda:list(map(int,input().split()))\\n_,k=r()\\nprint(calculate_answer(r(),r(),k))\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nt = list(map(int, input().split()))\\n\\ns = sum([a[i] * t[i] for i in range(n)])\\ns += sum([a[i] * (1 - t[i]) for i in range(k)])\\nans = s\\nfor i in range(n - k):\\n    s -= a[i] * (1 - t[i])\\n    s += a[i + k] * (1 - t[i + k])\\n    ans = max(ans, s)\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "2 2\n3 2\n1 0\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/961/B"
    },
    {
        "id": 1553,
        "task_id": 942,
        "test_case_id": 1,
        "question": "Chouti and his classmates are going to the university soon. To say goodbye to each other, the class has planned a big farewell party in which classmates, teachers and parents sang and danced.\n\nChouti remembered that $n$ persons took part in that party. To make the party funnier, each person wore one hat among $n$ kinds of weird hats numbered $1, 2, \\ldots n$. It is possible that several persons wore hats of the same kind. Some kinds of hats can remain unclaimed by anyone.\n\nAfter the party, the $i$-th person said that there were $a_i$ persons wearing a hat differing from his own.\n\nIt has been some days, so Chouti forgot all about others' hats, but he is curious about that. Let $b_i$ be the number of hat type the $i$-th person was wearing, Chouti wants you to find any possible $b_1, b_2, \\ldots, b_n$ that doesn't contradict with any person's statement. Because some persons might have a poor memory, there could be no solution at all.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 10^5$), the number of persons in the party.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\le a_i \\le n-1$), the statements of people.\n\n\n-----Output-----\n\nIf there is no solution, print a single line \"Impossible\".\n\nOtherwise, print \"Possible\" and then $n$ integers $b_1, b_2, \\ldots, b_n$ ($1 \\le b_i \\le n$).\n\nIf there are multiple answers, print any of them.\n\n\n-----Examples-----\nInput\n3\n0 0 0\n\nOutput\nPossible\n1 1 1 \nInput\n5\n3 3 2 2 2\n\nOutput\nPossible\n1 1 2 2 2 \nInput\n4\n0 1 2 3\n\nOutput\nImpossible\n\n\n\n-----Note-----\n\nIn the answer to the first example, all hats are the same, so every person will say that there were no persons wearing a hat different from kind $1$.\n\nIn the answer to the second example, the first and the second person wore the hat with type $1$ and all other wore a hat of type $2$.\n\nSo the first two persons will say there were three persons with hats differing from their own. Similarly, three last persons will say there were two persons wearing a hat different from their own.\n\nIn the third example, it can be shown that no solution exists.\n\nIn the first and the second example, other possible configurations are possible.",
        "solutions": "[\"input()\\nl = list(map(int, input().split()))\\nd = {}\\nd2 = {}\\nans = []\\nn = 1\\nfor i in l:\\n    i = len(l) - i\\n    if i not in d:\\n        d[i] = n\\n        n += 1\\n    if i not in d2:\\n        d2[i] = 0\\n    if d2[i] >= i:\\n        d[i] = n\\n        d2[i] = 0\\n        n += 1\\n    ans.append(d[i])\\n    d2[i] += 1\\nnums = {}\\ntot = 0\\nfor i in ans:\\n    tot += 1\\n    if i not in nums:\\n        nums[i] = 0\\n    nums[i] += 1\\nfor i in range(len(ans)):\\n    if tot - nums[ans[i]] != l[i]:\\n        print(\\\"Impossible\\\")\\n        return\\nprint(\\\"Possible\\\")\\nprint(\\\" \\\".join(map(str, ans)))\\n\\n\", \"import math\\n\\ndef __starting_point():\\n\\n\\tn = int(input())\\n\\tarr = [int(x) for x  in input().split()]\\n\\n\\n\\tans  = []\\n\\td = {}\\n\\tc = {}\\n\\tb = [0]*n\\n\\tind  = 0 \\n\\tfor i in range(n) : \\n\\t\\tif arr[i] in list(d.keys()) : \\n\\t\\t\\tif d[arr[i]]== 0 :\\n\\t\\t\\t\\tind+=1\\n\\t\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\t\\tb[i]=ind\\n\\t\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\t\\t\\telse :\\n\\t\\t\\t\\td[arr[i]]-=1\\n\\t\\t\\t\\tb[i]=c[arr[i]]\\n\\t\\telse : \\n\\t\\t\\tind+=1\\n\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\tb[i]=ind\\n\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\tans = True\\n\\tfor i in d : \\n\\t\\tif d[i]!=0:\\n\\t\\t\\tans =False\\n\\tif ans : \\n\\t\\tprint (\\\"Possible\\\")\\n\\t\\tprint(*b)\\n\\telse : \\n\\t\\tprint(\\\"Impossible\\\")\\n\\n\\n\\n\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nt = 0\\nd1 = {}\\nuse1 = {}\\nuse = {}\\nfor x in a:\\n\\tif x in d1:\\n\\t\\tif use1[x] == n - x:\\n\\t\\t\\tt += (n - x)\\n\\t\\t\\tuse1[x] = 0\\n\\t\\tuse1[x] += 1\\n\\telse:\\n\\t\\td1[x] = 0\\n\\t\\tt += (n - x)\\n\\t\\tuse1[x] = 1\\n\\nif n != t:\\n\\tprint(\\\"Impossible\\\")\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\td = {}\\n\\tcv = 1\\n\\tfor x in a:\\n\\t\\tif x in d:\\n\\t\\t\\tif use[d[x]] == n - x:\\n\\t\\t\\t\\td[x] = cv\\n\\t\\t\\t\\tcv += 1\\n\\t\\t\\t\\tuse[d[x]] = 0\\n\\t\\t\\tuse[d[x]] += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\\t\\telse:\\n\\t\\t\\td[x] = cv\\n\\t\\t\\tuse[d[x]] = 1\\n\\t\\t\\tcv += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\", \"import sys\\nfrom math import *\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef main():\\n\\tn = mint()\\n\\ta = [None]*n\\n\\tr = [None]*n\\n\\tj = 0\\n\\tfor i in mints():\\n\\t\\ta[j] = (n-i, j)\\n\\t\\tj+=1\\n\\ta.sort()\\n\\tj = 1\\n\\ti = 0\\n\\twhile i < n:\\n\\t\\tcnt = a[i][0]\\n\\t\\tfor k in range(i,i+cnt):\\n\\t\\t\\tif k >= n or a[k][0] != cnt:\\n\\t\\t\\t\\tprint(\\\"Impossible\\\")\\n\\t\\t\\t\\treturn\\n\\t\\t\\tr[a[k][1]] = j\\n\\t\\tj+=1\\n\\t\\ti+=cnt\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*r)\\n\\nmain()\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = [n-x for x in a]\\n\\ngroups = {}\\nfor i, x in enumerate(a):\\n\\tif x not in groups:\\n\\t\\tgroups[x] = []\\n\\tgroups[x].append(i)\\n\\nhats = [0] * n\\ncurrent_hat = 1\\n\\nfor count, ids in list(groups.items()):\\n\\tif len(ids)%count != 0:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\treturn\\n\\n\\tfor g in range(len(ids)//count):\\n\\t\\tfor _id in ids[count*g:count*(g+1)]:\\n\\t\\t\\thats[_id] = current_hat\\n\\t\\tcurrent_hat += 1\\n\\nprint(\\\"Possible\\\")\\nprint(*hats)\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\n\\nLIST=[[] for i in range(n+1)]\\n\\nfor i in range(n):\\n    LIST[n-A[i]].append(i)\\n\\nANSLIST=[None]*(n+1)\\nh=1\\nfor i in range(1,n+1):\\n    if len(LIST[i])%i!=0:\\n        print(\\\"Impossible\\\")\\n        return\\n\\n    else:\\n        j=0\\n        while j<len(LIST[i]):\\n            ANSLIST[LIST[i][j]]=h\\n            j+=1\\n            if j%i==0:\\n                h+=1\\n\\nprint(\\\"Possible\\\")\\nfor a in ANSLIST[:-1]:\\n    print(a,end=\\\" \\\")\\n\\n\\n\", \"n = int(input())\\nb = list(map(int, input().split()))\\na = [[b[i], i] for i in range(n)]\\na.sort()\\n\\nans = [0] * n\\n\\ncur = 0\\nnum = 1\\nwhile cur < n:\\n\\tnec = a[cur][0]\\n\\tng = False\\n\\tfor i in range(n-nec):\\n\\t\\tif cur+i >= n:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telif a[cur+i][0] != a[cur][0]:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telse:\\n\\t\\t\\tans[a[cur+i][1]] = num \\n\\n\\tif ng:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\tbreak\\n\\n\\tnum += 1\\n\\tcur += n-nec\\n\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*ans)\", \"n=int(input())\\na=list(map(int,input().split()))\\ncounts=[0]*n\\ndone=False\\nfor i in range(n):\\n    counts[a[i]]+=1\\nfor i in range(n):\\n    if counts[i]%(n-i)!=0:\\n        print(\\\"Impossible\\\")\\n        done=True\\n        break\\n    else:\\n        counts[i]//=(n-i)\\ncountsum=[counts[0]]\\nfor i in range(n-1):\\n    countsum.append(countsum[-1]+counts[i+1])\\nb=[]\\nseen=[0]*n\\nfor i in range(n):\\n    b.append(countsum[a[i]]-seen[a[i]]//(n-a[i]))\\n    seen[a[i]]+=1\\nout=\\\"\\\"\\nfor i in range(n):\\n    out+=str(b[i])+\\\" \\\"\\nif not done:\\n    print(\\\"Possible\\\")\\n    print(out[:-1])\", \"'''input\\n6\\n3 3 3 3 3 3\\n5\\n3 3 2 2 2\\n4\\n0 1 2 3\\n\\n\\n'''\\nn = int(input())\\na = list(map(int, input().split()))\\ns = [0] * (n + 1)\\nv = [0] * (n + 1)\\nr = [0] * (n + 1)\\nb = [0] * n\\nm = 0\\nfor i in range(n):\\n\\ta[i] = n - a[i]\\n\\ts[a[i]] += 1\\nfor i in range(n):\\n\\tif r[a[i]] == 0:\\n\\t\\tm += 1\\n\\t\\tv[a[i]] = m\\n\\t\\tr[a[i]] = a[i]\\n\\tb[i] = v[a[i]]\\n\\tr[a[i]] -= 1\\n\\t# print(b[i])\\nif any(x for x in r):\\n\\tprint(\\\"Impossible\\\")\\n\\treturn\\nprint(\\\"Possible\\\")\\nprint(*b)\\n\", \"from collections import Counter as C\\nn = int(input())\\nl = [*map(lambda x: n - int(x), input().split())]\\nc = C(l)\\nd = {}\\n# print(c)\\ntry:\\n    for k, v in c.items():\\n        if v % k == 0:\\n            d[k] = v//k\\n        else:\\n            raise ValueError()\\n    print('Possible')\\n    d_ = {}\\n    curr = 0\\n    for e in l:\\n        # print(d, d_)\\n        if e in d_:\\n            if d_[e][1] >= e:\\n                curr += 1\\n                d_[e] = [curr, 1]\\n            else:\\n                d_[e][1] += 1\\n        else:\\n            curr += 1\\n            d_[e] = [curr, 1]\\n        print(d_[e][0], end=' ')\\nexcept:\\n    print('Impossible')\", \"from collections import Counter\\n\\nn = int(input())\\na = tuple((n - int(x) for x in input().split()))\\na1 = [[] for _ in range(n + 2)]\\n''' :type: list[list[int]] '''\\nb = [1] * n\\nfor i in range(n):\\n\\ta1[a[i]].append(i)\\ni = 1\\nm = 1\\nfor k in range(1, n + 1):\\n\\tfor j in a1[k]:\\n\\t\\tb[j] = i\\n\\t\\tif m == k:\\n\\t\\t\\tm = 1\\n\\t\\t\\ti += 1\\n\\t\\telse:\\n\\t\\t\\tm += 1\\n\\tif m != 1:\\n\\t\\tprint('Impossible')\\n\\t\\tbreak\\nelse:\\n\\tprint('Possible')\\n\\tprint(*b)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = [0] * n\\nfor i in range(n):\\n    b[i] = n - a[i]\\ncnt = [[] for i in range(n + 1)]\\nfor i in range(n):\\n    cnt[b[i]].append(i)\\nf = True\\nfor i in range(1, n + 1):\\n    if len(cnt[i]) % i != 0:\\n        f = False\\n        break\\nif not f:\\n    print(\\\"Impossible\\\")\\nelse:\\n    t = 1\\n    ans = [0] * n\\n    for i in range(1, n + 1):\\n        x = cnt[i]\\n        if len(x) != 0:\\n            y = 0\\n            for j in x:\\n                ans[j] = t\\n                y += 1\\n                if y == i:\\n                    t += 1\\n                    y = 0\\n    print(\\\"Possible\\\")\\n    print(*ans)\", \"n = int(input())\\na = [(n - int(x)) for x in input().split()]\\nb = [0] * n\\nfh = 1\\ni = 0\\nhd = dict()\\nwhile i < n:\\n    if a[i] == 1:\\n        b[i] = fh\\n        fh += 1\\n    elif a[i] in hd:\\n        b[i] = hd[a[i]][0]\\n        hd[a[i]][1] -= 1\\n        if hd[a[i]][1] == 0:\\n            del hd[a[i]]\\n    else:\\n        b[i] = fh\\n        hd[a[i]] = [fh, a[i]-1]\\n        fh += 1\\n    i += 1\\nif len(hd) != 0:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"num = int(input())\\nnums = input()\\nstatement = [int(i) for i in nums.split()]\\n\\nlog = {}\\ngroup_num = {}\\nanchor = 1\\ntotal = num\\nstatus = 'Possible'\\nans = []\\nfor i, s in enumerate(statement):\\n    if s not in log or group_num[s] == 0:\\n        log[s] = anchor\\n        anchor += 1\\n        group_num[s] = num - s\\n        total -= group_num[s]\\n        if total < 0:\\n            status = 'Impossible'\\n            break\\n    ans.append(log[s])\\n    group_num[s] -= 1\\n\\nprint(status)\\nif status == 'Possible':\\n    for i in range(num - 1):\\n        print(ans[i], end=' ')\\n    print(ans[num - 1])\", \"n = int(input())\\naa = list(map(int, input().split()))\\n\\n\\ndef cal():\\n    ncol = [0] * (n + 1)\\n    ansmap = [0] * n\\n    ans = [0] * n\\n    colcnt = [0] * (n + 1)\\n    colmap = [0] * (n + 1)\\n    icol = 0\\n    for i, a in enumerate(aa):\\n        ncol[n - a] += 1\\n        ansmap[i] = n - a\\n\\n    for i, col in enumerate(ncol[1:], 1):\\n        if col % i:\\n            return\\n\\n    for i, col in enumerate(ansmap):\\n        if not colcnt[col] % col:\\n            icol += 1\\n            colmap[col] = icol\\n\\n        ans[i] = colmap[col]\\n        colcnt[col] += 1\\n\\n    return ans\\n\\n\\nans = cal()\\nif ans:\\n    print('Possible')\\n    print(' '.join(map(str, ans)))\\nelse:\\n    print('Impossible')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nif 0 in a:\\n    if len(set(a)) > 1:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        print(*[1]*n)\\nelif not all(q < n for q in a):\\n    print('Impossible')\\nelse:\\n    s = {}\\n    answer = [0 for q in range(n)]\\n    for q in range(len(a)):\\n        if a[q] in s:\\n            s[a[q]].append(q)\\n        else:\\n            s[a[q]] = [q]\\n    q2 = 0\\n    for q in s:\\n        if len(s[q]) % (n-q) != 0:\\n            print('Impossible')\\n            break\\n        for q1 in range(len(s[q])):\\n            if q1 % (n-q) == 0:\\n                q2 += 1\\n            answer[s[q][q1]] = q2\\n    else:\\n        print('Possible')\\n        print(*answer)\\n\", \"n = int(input())\\na = [int(s) for s in input().split()]\\nb = [-1 for i in range(n)]\\nm = {}\\nnextnum = 1\\nfor i in range(n):\\n    # print(m)\\n    if b[i] == -1:\\n        if m.get(a[i]) and m[a[i]][1] > 0:\\n            b[i] = m[a[i]][0]\\n            m[a[i]][1] -= 1\\n            if m[a[i]][1] == 0:\\n                m.pop(a[i])\\n        else:\\n            z = n-a[i]-1\\n            b[i] = nextnum\\n            if z:\\n                m[a[i]] = [nextnum, z]\\n            nextnum += 1\\n\\nif m:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"n = int(input())\\n\\ncl = list(map(int, input().split()))\\n\\npos = {}\\ncolor = 0\\nres = []\\n\\nfor x in cl:\\n  if x in pos.keys():\\n    if pos[x][0]!=0:\\n      res.append(pos[x][1])\\n      pos[x][0]-=1\\n    else:\\n      color+=1\\n      res.append(color)\\n      pos[x] = [n-x-1, color]\\n  else:\\n    color+=1\\n    res.append(color)\\n    pos.update({x:[n-x-1, color]})\\n\\nfor x in pos.keys():\\n  if pos[x][0]!=0:\\n    print(\\\"Impossible\\\")\\n    return\\n\\nprint(\\\"Possible\\\")\\nprint(*res)\", \"n=int(input())\\narr=list(map(int,input().split()))\\nansarr=[0]*n\\nflag=0\\ndict1={}\\ndict2={}\\nfor i in range(n):\\n    try:\\n        dict1[arr[i]].append(i)\\n    except:\\n        KeyError\\n        dict1[arr[i]]=[i]\\n        dict2[arr[i]]=0\\n\\ntempcount=0\\nfor i in dict1.keys():\\n    count=0\\n    while(dict2[i]<len(dict1[i])):\\n        if(dict2[i]+n-i>len(dict1[i])):\\n            flag=1\\n            break\\n        else:\\n            tempcount+=n-i\\n            dict2[i]+=n-i\\nif(tempcount!=n):\\n    flag=1\\nif(flag==1):\\n    print('Impossible')\\nelse:\\n    count=0\\n    val=1\\n    for i in dict1.keys():\\n        for j in range(0,len(dict1[i]),n-i):\\n            for k in range(n-int(i)):\\n                ansarr[dict1[i][j+k]]=val\\n            val+=1\\n    print('Possible')\\n    print(*ansarr)\", \"#!/usr/bin/env python3\\nimport sys\\ndef __starting_point():\\n    n = int(input())\\n    a = {}\\n    a_s = input().split()\\n    for i in range(n):\\n        x = n - int(a_s[i])\\n        a[x] = a.get(x, 0) + 1\\n        a_s[i] = x\\n    for i in a:\\n        if (i < 1) or (i > n):\\n            print(\\\"Impossible\\\")\\n            return\\n        if a[i] % i != 0:\\n            print(\\\"Impossible\\\")\\n            return\\n    print(\\\"Possible\\\")\\n    used = 0\\n    col = {}\\n    num = {}\\n    b = []\\n    for x in a_s:\\n        if x not in col or num[x] == x:\\n            used += 1\\n            col[x] = used\\n            num[x] = 1\\n            b.append(used)\\n        else:\\n            num[x] += 1\\n            b.append(col[x])\\n    print(\\\" \\\".join(map(str, b)))\\n\\n__starting_point()\", \"n = int(input())\\na = [int(element) for element in input().split(' ')]\\nb = dict()\\nfor i in range(n):\\n    try:\\n        b[a[i]] += 1\\n    except:\\n        b[a[i]] = 1\\nc = [(b[k] % (n-k)) == 0 for k in list(b.keys())]\\nd = [b[k] for k in a]\\n\\nif all(c):\\n    print(\\\"Possible\\\")\\n    types = dict()\\n    hat = 1\\n    for k in list(b.keys()):\\n        pergroup = n-k\\n        groups = b[k] // pergroup\\n        hatsgroup = list()\\n        for i in range(groups):\\n            for j in range(pergroup):\\n                hatsgroup.append(hat)\\n            hat += 1\\n        types[k] = hatsgroup\\n    hats = list()\\n    for i in range(n):\\n        hats.append(types[a[i]].pop())\\n    print(' '.join(str(e) for e in hats))\\n\\nelse:\\n    print(\\\"Impossible\\\")\\n\", \"import math\\n\\n\\ndef hats(n, arr):\\n    processed = [False] * n\\n    hats = [None] * n\\n    cur_hat = 0\\n    for i, diff_count in enumerate(arr):\\n        if processed[i]: continue\\n        cur_hat += 1\\n        hats[i] = cur_hat\\n        processed[i] = True\\n        same_count = n - diff_count - 1\\n        if not same_count: continue\\n        for j in range(i+1, n):\\n            if arr[j] == diff_count:\\n                same_count -= 1\\n                processed[j] = True\\n                hats[j] = cur_hat\\n            if not same_count:\\n                break\\n        if same_count:\\n            print('Impossible')\\n            return\\n    print('Possible')\\n    print(' '.join(list(map(str, hats))))\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    answers = list(map(int, input().strip().split()))\\n    hats(n, answers)\\n\\n__starting_point()\", \"n=int(input())\\na=list(map(int,input().split()))\\nd={}\\nl=[[] for i in range(n+1)]\\nfor i in range(n):\\n    d[a[i]]=d.get(a[i],0)+1\\n    l[n-a[i]].append(i+1)\\nb=list(d.keys())\\nc=[]\\nfor i in b:\\n    c.append([d[i]//(n-i),n-i])\\nk=0\\nfor i in c:\\n    k+=i[0]*i[1]\\nif k!=n:\\n    print('Impossible')\\nelse:\\n    print('Possible')\\n    co=1\\n    ans=[0]*(n+1)\\n    for i in c:\\n        for j in range(i[0]):\\n            for k in range(i[1]):\\n                x=l[i[1]].pop()\\n                ans[x]=co\\n            co+=1\\n    print(*ans[1:])\", \"n = int(input())\\nL = [n-int(x) for x in input().split()]\\nD = {}\\nfor i in L:\\n    if i in D:\\n        D[i] += 1\\n    else:\\n        D[i] = 1\\ns = 0\\ncheck = True\\nfor i in D.keys():\\n    if D[i]%i != 0:\\n        check = False\\n        break\\n    else:\\n        s += D[i]\\nif s != n:\\n    print('Impossible')\\n\\nelse:\\n    if check == False:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        small = 1\\n        D2 = {}\\n        for i in D:\\n            D2[i] = list(range(small,small+(D[i]//i)))*i\\n            small += D[i]//i\\n        for i in L:\\n            print(D2[i][-1],end = ' ')\\n            D2[i].pop()\"]",
        "difficulty": "interview",
        "input": "3\n0 0 0\n",
        "output": "Possible\n1 1 1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1081/B"
    },
    {
        "id": 1554,
        "task_id": 942,
        "test_case_id": 8,
        "question": "Chouti and his classmates are going to the university soon. To say goodbye to each other, the class has planned a big farewell party in which classmates, teachers and parents sang and danced.\n\nChouti remembered that $n$ persons took part in that party. To make the party funnier, each person wore one hat among $n$ kinds of weird hats numbered $1, 2, \\ldots n$. It is possible that several persons wore hats of the same kind. Some kinds of hats can remain unclaimed by anyone.\n\nAfter the party, the $i$-th person said that there were $a_i$ persons wearing a hat differing from his own.\n\nIt has been some days, so Chouti forgot all about others' hats, but he is curious about that. Let $b_i$ be the number of hat type the $i$-th person was wearing, Chouti wants you to find any possible $b_1, b_2, \\ldots, b_n$ that doesn't contradict with any person's statement. Because some persons might have a poor memory, there could be no solution at all.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 10^5$), the number of persons in the party.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\le a_i \\le n-1$), the statements of people.\n\n\n-----Output-----\n\nIf there is no solution, print a single line \"Impossible\".\n\nOtherwise, print \"Possible\" and then $n$ integers $b_1, b_2, \\ldots, b_n$ ($1 \\le b_i \\le n$).\n\nIf there are multiple answers, print any of them.\n\n\n-----Examples-----\nInput\n3\n0 0 0\n\nOutput\nPossible\n1 1 1 \nInput\n5\n3 3 2 2 2\n\nOutput\nPossible\n1 1 2 2 2 \nInput\n4\n0 1 2 3\n\nOutput\nImpossible\n\n\n\n-----Note-----\n\nIn the answer to the first example, all hats are the same, so every person will say that there were no persons wearing a hat different from kind $1$.\n\nIn the answer to the second example, the first and the second person wore the hat with type $1$ and all other wore a hat of type $2$.\n\nSo the first two persons will say there were three persons with hats differing from their own. Similarly, three last persons will say there were two persons wearing a hat different from their own.\n\nIn the third example, it can be shown that no solution exists.\n\nIn the first and the second example, other possible configurations are possible.",
        "solutions": "[\"input()\\nl = list(map(int, input().split()))\\nd = {}\\nd2 = {}\\nans = []\\nn = 1\\nfor i in l:\\n    i = len(l) - i\\n    if i not in d:\\n        d[i] = n\\n        n += 1\\n    if i not in d2:\\n        d2[i] = 0\\n    if d2[i] >= i:\\n        d[i] = n\\n        d2[i] = 0\\n        n += 1\\n    ans.append(d[i])\\n    d2[i] += 1\\nnums = {}\\ntot = 0\\nfor i in ans:\\n    tot += 1\\n    if i not in nums:\\n        nums[i] = 0\\n    nums[i] += 1\\nfor i in range(len(ans)):\\n    if tot - nums[ans[i]] != l[i]:\\n        print(\\\"Impossible\\\")\\n        return\\nprint(\\\"Possible\\\")\\nprint(\\\" \\\".join(map(str, ans)))\\n\\n\", \"import math\\n\\ndef __starting_point():\\n\\n\\tn = int(input())\\n\\tarr = [int(x) for x  in input().split()]\\n\\n\\n\\tans  = []\\n\\td = {}\\n\\tc = {}\\n\\tb = [0]*n\\n\\tind  = 0 \\n\\tfor i in range(n) : \\n\\t\\tif arr[i] in list(d.keys()) : \\n\\t\\t\\tif d[arr[i]]== 0 :\\n\\t\\t\\t\\tind+=1\\n\\t\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\t\\tb[i]=ind\\n\\t\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\t\\t\\telse :\\n\\t\\t\\t\\td[arr[i]]-=1\\n\\t\\t\\t\\tb[i]=c[arr[i]]\\n\\t\\telse : \\n\\t\\t\\tind+=1\\n\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\tb[i]=ind\\n\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\tans = True\\n\\tfor i in d : \\n\\t\\tif d[i]!=0:\\n\\t\\t\\tans =False\\n\\tif ans : \\n\\t\\tprint (\\\"Possible\\\")\\n\\t\\tprint(*b)\\n\\telse : \\n\\t\\tprint(\\\"Impossible\\\")\\n\\n\\n\\n\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nt = 0\\nd1 = {}\\nuse1 = {}\\nuse = {}\\nfor x in a:\\n\\tif x in d1:\\n\\t\\tif use1[x] == n - x:\\n\\t\\t\\tt += (n - x)\\n\\t\\t\\tuse1[x] = 0\\n\\t\\tuse1[x] += 1\\n\\telse:\\n\\t\\td1[x] = 0\\n\\t\\tt += (n - x)\\n\\t\\tuse1[x] = 1\\n\\nif n != t:\\n\\tprint(\\\"Impossible\\\")\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\td = {}\\n\\tcv = 1\\n\\tfor x in a:\\n\\t\\tif x in d:\\n\\t\\t\\tif use[d[x]] == n - x:\\n\\t\\t\\t\\td[x] = cv\\n\\t\\t\\t\\tcv += 1\\n\\t\\t\\t\\tuse[d[x]] = 0\\n\\t\\t\\tuse[d[x]] += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\\t\\telse:\\n\\t\\t\\td[x] = cv\\n\\t\\t\\tuse[d[x]] = 1\\n\\t\\t\\tcv += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\", \"import sys\\nfrom math import *\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef main():\\n\\tn = mint()\\n\\ta = [None]*n\\n\\tr = [None]*n\\n\\tj = 0\\n\\tfor i in mints():\\n\\t\\ta[j] = (n-i, j)\\n\\t\\tj+=1\\n\\ta.sort()\\n\\tj = 1\\n\\ti = 0\\n\\twhile i < n:\\n\\t\\tcnt = a[i][0]\\n\\t\\tfor k in range(i,i+cnt):\\n\\t\\t\\tif k >= n or a[k][0] != cnt:\\n\\t\\t\\t\\tprint(\\\"Impossible\\\")\\n\\t\\t\\t\\treturn\\n\\t\\t\\tr[a[k][1]] = j\\n\\t\\tj+=1\\n\\t\\ti+=cnt\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*r)\\n\\nmain()\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = [n-x for x in a]\\n\\ngroups = {}\\nfor i, x in enumerate(a):\\n\\tif x not in groups:\\n\\t\\tgroups[x] = []\\n\\tgroups[x].append(i)\\n\\nhats = [0] * n\\ncurrent_hat = 1\\n\\nfor count, ids in list(groups.items()):\\n\\tif len(ids)%count != 0:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\treturn\\n\\n\\tfor g in range(len(ids)//count):\\n\\t\\tfor _id in ids[count*g:count*(g+1)]:\\n\\t\\t\\thats[_id] = current_hat\\n\\t\\tcurrent_hat += 1\\n\\nprint(\\\"Possible\\\")\\nprint(*hats)\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\n\\nLIST=[[] for i in range(n+1)]\\n\\nfor i in range(n):\\n    LIST[n-A[i]].append(i)\\n\\nANSLIST=[None]*(n+1)\\nh=1\\nfor i in range(1,n+1):\\n    if len(LIST[i])%i!=0:\\n        print(\\\"Impossible\\\")\\n        return\\n\\n    else:\\n        j=0\\n        while j<len(LIST[i]):\\n            ANSLIST[LIST[i][j]]=h\\n            j+=1\\n            if j%i==0:\\n                h+=1\\n\\nprint(\\\"Possible\\\")\\nfor a in ANSLIST[:-1]:\\n    print(a,end=\\\" \\\")\\n\\n\\n\", \"n = int(input())\\nb = list(map(int, input().split()))\\na = [[b[i], i] for i in range(n)]\\na.sort()\\n\\nans = [0] * n\\n\\ncur = 0\\nnum = 1\\nwhile cur < n:\\n\\tnec = a[cur][0]\\n\\tng = False\\n\\tfor i in range(n-nec):\\n\\t\\tif cur+i >= n:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telif a[cur+i][0] != a[cur][0]:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telse:\\n\\t\\t\\tans[a[cur+i][1]] = num \\n\\n\\tif ng:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\tbreak\\n\\n\\tnum += 1\\n\\tcur += n-nec\\n\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*ans)\", \"n=int(input())\\na=list(map(int,input().split()))\\ncounts=[0]*n\\ndone=False\\nfor i in range(n):\\n    counts[a[i]]+=1\\nfor i in range(n):\\n    if counts[i]%(n-i)!=0:\\n        print(\\\"Impossible\\\")\\n        done=True\\n        break\\n    else:\\n        counts[i]//=(n-i)\\ncountsum=[counts[0]]\\nfor i in range(n-1):\\n    countsum.append(countsum[-1]+counts[i+1])\\nb=[]\\nseen=[0]*n\\nfor i in range(n):\\n    b.append(countsum[a[i]]-seen[a[i]]//(n-a[i]))\\n    seen[a[i]]+=1\\nout=\\\"\\\"\\nfor i in range(n):\\n    out+=str(b[i])+\\\" \\\"\\nif not done:\\n    print(\\\"Possible\\\")\\n    print(out[:-1])\", \"'''input\\n6\\n3 3 3 3 3 3\\n5\\n3 3 2 2 2\\n4\\n0 1 2 3\\n\\n\\n'''\\nn = int(input())\\na = list(map(int, input().split()))\\ns = [0] * (n + 1)\\nv = [0] * (n + 1)\\nr = [0] * (n + 1)\\nb = [0] * n\\nm = 0\\nfor i in range(n):\\n\\ta[i] = n - a[i]\\n\\ts[a[i]] += 1\\nfor i in range(n):\\n\\tif r[a[i]] == 0:\\n\\t\\tm += 1\\n\\t\\tv[a[i]] = m\\n\\t\\tr[a[i]] = a[i]\\n\\tb[i] = v[a[i]]\\n\\tr[a[i]] -= 1\\n\\t# print(b[i])\\nif any(x for x in r):\\n\\tprint(\\\"Impossible\\\")\\n\\treturn\\nprint(\\\"Possible\\\")\\nprint(*b)\\n\", \"from collections import Counter as C\\nn = int(input())\\nl = [*map(lambda x: n - int(x), input().split())]\\nc = C(l)\\nd = {}\\n# print(c)\\ntry:\\n    for k, v in c.items():\\n        if v % k == 0:\\n            d[k] = v//k\\n        else:\\n            raise ValueError()\\n    print('Possible')\\n    d_ = {}\\n    curr = 0\\n    for e in l:\\n        # print(d, d_)\\n        if e in d_:\\n            if d_[e][1] >= e:\\n                curr += 1\\n                d_[e] = [curr, 1]\\n            else:\\n                d_[e][1] += 1\\n        else:\\n            curr += 1\\n            d_[e] = [curr, 1]\\n        print(d_[e][0], end=' ')\\nexcept:\\n    print('Impossible')\", \"from collections import Counter\\n\\nn = int(input())\\na = tuple((n - int(x) for x in input().split()))\\na1 = [[] for _ in range(n + 2)]\\n''' :type: list[list[int]] '''\\nb = [1] * n\\nfor i in range(n):\\n\\ta1[a[i]].append(i)\\ni = 1\\nm = 1\\nfor k in range(1, n + 1):\\n\\tfor j in a1[k]:\\n\\t\\tb[j] = i\\n\\t\\tif m == k:\\n\\t\\t\\tm = 1\\n\\t\\t\\ti += 1\\n\\t\\telse:\\n\\t\\t\\tm += 1\\n\\tif m != 1:\\n\\t\\tprint('Impossible')\\n\\t\\tbreak\\nelse:\\n\\tprint('Possible')\\n\\tprint(*b)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = [0] * n\\nfor i in range(n):\\n    b[i] = n - a[i]\\ncnt = [[] for i in range(n + 1)]\\nfor i in range(n):\\n    cnt[b[i]].append(i)\\nf = True\\nfor i in range(1, n + 1):\\n    if len(cnt[i]) % i != 0:\\n        f = False\\n        break\\nif not f:\\n    print(\\\"Impossible\\\")\\nelse:\\n    t = 1\\n    ans = [0] * n\\n    for i in range(1, n + 1):\\n        x = cnt[i]\\n        if len(x) != 0:\\n            y = 0\\n            for j in x:\\n                ans[j] = t\\n                y += 1\\n                if y == i:\\n                    t += 1\\n                    y = 0\\n    print(\\\"Possible\\\")\\n    print(*ans)\", \"n = int(input())\\na = [(n - int(x)) for x in input().split()]\\nb = [0] * n\\nfh = 1\\ni = 0\\nhd = dict()\\nwhile i < n:\\n    if a[i] == 1:\\n        b[i] = fh\\n        fh += 1\\n    elif a[i] in hd:\\n        b[i] = hd[a[i]][0]\\n        hd[a[i]][1] -= 1\\n        if hd[a[i]][1] == 0:\\n            del hd[a[i]]\\n    else:\\n        b[i] = fh\\n        hd[a[i]] = [fh, a[i]-1]\\n        fh += 1\\n    i += 1\\nif len(hd) != 0:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"num = int(input())\\nnums = input()\\nstatement = [int(i) for i in nums.split()]\\n\\nlog = {}\\ngroup_num = {}\\nanchor = 1\\ntotal = num\\nstatus = 'Possible'\\nans = []\\nfor i, s in enumerate(statement):\\n    if s not in log or group_num[s] == 0:\\n        log[s] = anchor\\n        anchor += 1\\n        group_num[s] = num - s\\n        total -= group_num[s]\\n        if total < 0:\\n            status = 'Impossible'\\n            break\\n    ans.append(log[s])\\n    group_num[s] -= 1\\n\\nprint(status)\\nif status == 'Possible':\\n    for i in range(num - 1):\\n        print(ans[i], end=' ')\\n    print(ans[num - 1])\", \"n = int(input())\\naa = list(map(int, input().split()))\\n\\n\\ndef cal():\\n    ncol = [0] * (n + 1)\\n    ansmap = [0] * n\\n    ans = [0] * n\\n    colcnt = [0] * (n + 1)\\n    colmap = [0] * (n + 1)\\n    icol = 0\\n    for i, a in enumerate(aa):\\n        ncol[n - a] += 1\\n        ansmap[i] = n - a\\n\\n    for i, col in enumerate(ncol[1:], 1):\\n        if col % i:\\n            return\\n\\n    for i, col in enumerate(ansmap):\\n        if not colcnt[col] % col:\\n            icol += 1\\n            colmap[col] = icol\\n\\n        ans[i] = colmap[col]\\n        colcnt[col] += 1\\n\\n    return ans\\n\\n\\nans = cal()\\nif ans:\\n    print('Possible')\\n    print(' '.join(map(str, ans)))\\nelse:\\n    print('Impossible')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nif 0 in a:\\n    if len(set(a)) > 1:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        print(*[1]*n)\\nelif not all(q < n for q in a):\\n    print('Impossible')\\nelse:\\n    s = {}\\n    answer = [0 for q in range(n)]\\n    for q in range(len(a)):\\n        if a[q] in s:\\n            s[a[q]].append(q)\\n        else:\\n            s[a[q]] = [q]\\n    q2 = 0\\n    for q in s:\\n        if len(s[q]) % (n-q) != 0:\\n            print('Impossible')\\n            break\\n        for q1 in range(len(s[q])):\\n            if q1 % (n-q) == 0:\\n                q2 += 1\\n            answer[s[q][q1]] = q2\\n    else:\\n        print('Possible')\\n        print(*answer)\\n\", \"n = int(input())\\na = [int(s) for s in input().split()]\\nb = [-1 for i in range(n)]\\nm = {}\\nnextnum = 1\\nfor i in range(n):\\n    # print(m)\\n    if b[i] == -1:\\n        if m.get(a[i]) and m[a[i]][1] > 0:\\n            b[i] = m[a[i]][0]\\n            m[a[i]][1] -= 1\\n            if m[a[i]][1] == 0:\\n                m.pop(a[i])\\n        else:\\n            z = n-a[i]-1\\n            b[i] = nextnum\\n            if z:\\n                m[a[i]] = [nextnum, z]\\n            nextnum += 1\\n\\nif m:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"n = int(input())\\n\\ncl = list(map(int, input().split()))\\n\\npos = {}\\ncolor = 0\\nres = []\\n\\nfor x in cl:\\n  if x in pos.keys():\\n    if pos[x][0]!=0:\\n      res.append(pos[x][1])\\n      pos[x][0]-=1\\n    else:\\n      color+=1\\n      res.append(color)\\n      pos[x] = [n-x-1, color]\\n  else:\\n    color+=1\\n    res.append(color)\\n    pos.update({x:[n-x-1, color]})\\n\\nfor x in pos.keys():\\n  if pos[x][0]!=0:\\n    print(\\\"Impossible\\\")\\n    return\\n\\nprint(\\\"Possible\\\")\\nprint(*res)\", \"n=int(input())\\narr=list(map(int,input().split()))\\nansarr=[0]*n\\nflag=0\\ndict1={}\\ndict2={}\\nfor i in range(n):\\n    try:\\n        dict1[arr[i]].append(i)\\n    except:\\n        KeyError\\n        dict1[arr[i]]=[i]\\n        dict2[arr[i]]=0\\n\\ntempcount=0\\nfor i in dict1.keys():\\n    count=0\\n    while(dict2[i]<len(dict1[i])):\\n        if(dict2[i]+n-i>len(dict1[i])):\\n            flag=1\\n            break\\n        else:\\n            tempcount+=n-i\\n            dict2[i]+=n-i\\nif(tempcount!=n):\\n    flag=1\\nif(flag==1):\\n    print('Impossible')\\nelse:\\n    count=0\\n    val=1\\n    for i in dict1.keys():\\n        for j in range(0,len(dict1[i]),n-i):\\n            for k in range(n-int(i)):\\n                ansarr[dict1[i][j+k]]=val\\n            val+=1\\n    print('Possible')\\n    print(*ansarr)\", \"#!/usr/bin/env python3\\nimport sys\\ndef __starting_point():\\n    n = int(input())\\n    a = {}\\n    a_s = input().split()\\n    for i in range(n):\\n        x = n - int(a_s[i])\\n        a[x] = a.get(x, 0) + 1\\n        a_s[i] = x\\n    for i in a:\\n        if (i < 1) or (i > n):\\n            print(\\\"Impossible\\\")\\n            return\\n        if a[i] % i != 0:\\n            print(\\\"Impossible\\\")\\n            return\\n    print(\\\"Possible\\\")\\n    used = 0\\n    col = {}\\n    num = {}\\n    b = []\\n    for x in a_s:\\n        if x not in col or num[x] == x:\\n            used += 1\\n            col[x] = used\\n            num[x] = 1\\n            b.append(used)\\n        else:\\n            num[x] += 1\\n            b.append(col[x])\\n    print(\\\" \\\".join(map(str, b)))\\n\\n__starting_point()\", \"n = int(input())\\na = [int(element) for element in input().split(' ')]\\nb = dict()\\nfor i in range(n):\\n    try:\\n        b[a[i]] += 1\\n    except:\\n        b[a[i]] = 1\\nc = [(b[k] % (n-k)) == 0 for k in list(b.keys())]\\nd = [b[k] for k in a]\\n\\nif all(c):\\n    print(\\\"Possible\\\")\\n    types = dict()\\n    hat = 1\\n    for k in list(b.keys()):\\n        pergroup = n-k\\n        groups = b[k] // pergroup\\n        hatsgroup = list()\\n        for i in range(groups):\\n            for j in range(pergroup):\\n                hatsgroup.append(hat)\\n            hat += 1\\n        types[k] = hatsgroup\\n    hats = list()\\n    for i in range(n):\\n        hats.append(types[a[i]].pop())\\n    print(' '.join(str(e) for e in hats))\\n\\nelse:\\n    print(\\\"Impossible\\\")\\n\", \"import math\\n\\n\\ndef hats(n, arr):\\n    processed = [False] * n\\n    hats = [None] * n\\n    cur_hat = 0\\n    for i, diff_count in enumerate(arr):\\n        if processed[i]: continue\\n        cur_hat += 1\\n        hats[i] = cur_hat\\n        processed[i] = True\\n        same_count = n - diff_count - 1\\n        if not same_count: continue\\n        for j in range(i+1, n):\\n            if arr[j] == diff_count:\\n                same_count -= 1\\n                processed[j] = True\\n                hats[j] = cur_hat\\n            if not same_count:\\n                break\\n        if same_count:\\n            print('Impossible')\\n            return\\n    print('Possible')\\n    print(' '.join(list(map(str, hats))))\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    answers = list(map(int, input().strip().split()))\\n    hats(n, answers)\\n\\n__starting_point()\", \"n=int(input())\\na=list(map(int,input().split()))\\nd={}\\nl=[[] for i in range(n+1)]\\nfor i in range(n):\\n    d[a[i]]=d.get(a[i],0)+1\\n    l[n-a[i]].append(i+1)\\nb=list(d.keys())\\nc=[]\\nfor i in b:\\n    c.append([d[i]//(n-i),n-i])\\nk=0\\nfor i in c:\\n    k+=i[0]*i[1]\\nif k!=n:\\n    print('Impossible')\\nelse:\\n    print('Possible')\\n    co=1\\n    ans=[0]*(n+1)\\n    for i in c:\\n        for j in range(i[0]):\\n            for k in range(i[1]):\\n                x=l[i[1]].pop()\\n                ans[x]=co\\n            co+=1\\n    print(*ans[1:])\", \"n = int(input())\\nL = [n-int(x) for x in input().split()]\\nD = {}\\nfor i in L:\\n    if i in D:\\n        D[i] += 1\\n    else:\\n        D[i] = 1\\ns = 0\\ncheck = True\\nfor i in D.keys():\\n    if D[i]%i != 0:\\n        check = False\\n        break\\n    else:\\n        s += D[i]\\nif s != n:\\n    print('Impossible')\\n\\nelse:\\n    if check == False:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        small = 1\\n        D2 = {}\\n        for i in D:\\n            D2[i] = list(range(small,small+(D[i]//i)))*i\\n            small += D[i]//i\\n        for i in L:\\n            print(D2[i][-1],end = ' ')\\n            D2[i].pop()\"]",
        "difficulty": "interview",
        "input": "4\n2 2 2 2\n",
        "output": "Possible\n1 1 2 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1081/B"
    },
    {
        "id": 1555,
        "task_id": 942,
        "test_case_id": 10,
        "question": "Chouti and his classmates are going to the university soon. To say goodbye to each other, the class has planned a big farewell party in which classmates, teachers and parents sang and danced.\n\nChouti remembered that $n$ persons took part in that party. To make the party funnier, each person wore one hat among $n$ kinds of weird hats numbered $1, 2, \\ldots n$. It is possible that several persons wore hats of the same kind. Some kinds of hats can remain unclaimed by anyone.\n\nAfter the party, the $i$-th person said that there were $a_i$ persons wearing a hat differing from his own.\n\nIt has been some days, so Chouti forgot all about others' hats, but he is curious about that. Let $b_i$ be the number of hat type the $i$-th person was wearing, Chouti wants you to find any possible $b_1, b_2, \\ldots, b_n$ that doesn't contradict with any person's statement. Because some persons might have a poor memory, there could be no solution at all.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 10^5$), the number of persons in the party.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\le a_i \\le n-1$), the statements of people.\n\n\n-----Output-----\n\nIf there is no solution, print a single line \"Impossible\".\n\nOtherwise, print \"Possible\" and then $n$ integers $b_1, b_2, \\ldots, b_n$ ($1 \\le b_i \\le n$).\n\nIf there are multiple answers, print any of them.\n\n\n-----Examples-----\nInput\n3\n0 0 0\n\nOutput\nPossible\n1 1 1 \nInput\n5\n3 3 2 2 2\n\nOutput\nPossible\n1 1 2 2 2 \nInput\n4\n0 1 2 3\n\nOutput\nImpossible\n\n\n\n-----Note-----\n\nIn the answer to the first example, all hats are the same, so every person will say that there were no persons wearing a hat different from kind $1$.\n\nIn the answer to the second example, the first and the second person wore the hat with type $1$ and all other wore a hat of type $2$.\n\nSo the first two persons will say there were three persons with hats differing from their own. Similarly, three last persons will say there were two persons wearing a hat different from their own.\n\nIn the third example, it can be shown that no solution exists.\n\nIn the first and the second example, other possible configurations are possible.",
        "solutions": "[\"input()\\nl = list(map(int, input().split()))\\nd = {}\\nd2 = {}\\nans = []\\nn = 1\\nfor i in l:\\n    i = len(l) - i\\n    if i not in d:\\n        d[i] = n\\n        n += 1\\n    if i not in d2:\\n        d2[i] = 0\\n    if d2[i] >= i:\\n        d[i] = n\\n        d2[i] = 0\\n        n += 1\\n    ans.append(d[i])\\n    d2[i] += 1\\nnums = {}\\ntot = 0\\nfor i in ans:\\n    tot += 1\\n    if i not in nums:\\n        nums[i] = 0\\n    nums[i] += 1\\nfor i in range(len(ans)):\\n    if tot - nums[ans[i]] != l[i]:\\n        print(\\\"Impossible\\\")\\n        return\\nprint(\\\"Possible\\\")\\nprint(\\\" \\\".join(map(str, ans)))\\n\\n\", \"import math\\n\\ndef __starting_point():\\n\\n\\tn = int(input())\\n\\tarr = [int(x) for x  in input().split()]\\n\\n\\n\\tans  = []\\n\\td = {}\\n\\tc = {}\\n\\tb = [0]*n\\n\\tind  = 0 \\n\\tfor i in range(n) : \\n\\t\\tif arr[i] in list(d.keys()) : \\n\\t\\t\\tif d[arr[i]]== 0 :\\n\\t\\t\\t\\tind+=1\\n\\t\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\t\\tb[i]=ind\\n\\t\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\t\\t\\telse :\\n\\t\\t\\t\\td[arr[i]]-=1\\n\\t\\t\\t\\tb[i]=c[arr[i]]\\n\\t\\telse : \\n\\t\\t\\tind+=1\\n\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\tb[i]=ind\\n\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\tans = True\\n\\tfor i in d : \\n\\t\\tif d[i]!=0:\\n\\t\\t\\tans =False\\n\\tif ans : \\n\\t\\tprint (\\\"Possible\\\")\\n\\t\\tprint(*b)\\n\\telse : \\n\\t\\tprint(\\\"Impossible\\\")\\n\\n\\n\\n\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nt = 0\\nd1 = {}\\nuse1 = {}\\nuse = {}\\nfor x in a:\\n\\tif x in d1:\\n\\t\\tif use1[x] == n - x:\\n\\t\\t\\tt += (n - x)\\n\\t\\t\\tuse1[x] = 0\\n\\t\\tuse1[x] += 1\\n\\telse:\\n\\t\\td1[x] = 0\\n\\t\\tt += (n - x)\\n\\t\\tuse1[x] = 1\\n\\nif n != t:\\n\\tprint(\\\"Impossible\\\")\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\td = {}\\n\\tcv = 1\\n\\tfor x in a:\\n\\t\\tif x in d:\\n\\t\\t\\tif use[d[x]] == n - x:\\n\\t\\t\\t\\td[x] = cv\\n\\t\\t\\t\\tcv += 1\\n\\t\\t\\t\\tuse[d[x]] = 0\\n\\t\\t\\tuse[d[x]] += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\\t\\telse:\\n\\t\\t\\td[x] = cv\\n\\t\\t\\tuse[d[x]] = 1\\n\\t\\t\\tcv += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\", \"import sys\\nfrom math import *\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef main():\\n\\tn = mint()\\n\\ta = [None]*n\\n\\tr = [None]*n\\n\\tj = 0\\n\\tfor i in mints():\\n\\t\\ta[j] = (n-i, j)\\n\\t\\tj+=1\\n\\ta.sort()\\n\\tj = 1\\n\\ti = 0\\n\\twhile i < n:\\n\\t\\tcnt = a[i][0]\\n\\t\\tfor k in range(i,i+cnt):\\n\\t\\t\\tif k >= n or a[k][0] != cnt:\\n\\t\\t\\t\\tprint(\\\"Impossible\\\")\\n\\t\\t\\t\\treturn\\n\\t\\t\\tr[a[k][1]] = j\\n\\t\\tj+=1\\n\\t\\ti+=cnt\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*r)\\n\\nmain()\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = [n-x for x in a]\\n\\ngroups = {}\\nfor i, x in enumerate(a):\\n\\tif x not in groups:\\n\\t\\tgroups[x] = []\\n\\tgroups[x].append(i)\\n\\nhats = [0] * n\\ncurrent_hat = 1\\n\\nfor count, ids in list(groups.items()):\\n\\tif len(ids)%count != 0:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\treturn\\n\\n\\tfor g in range(len(ids)//count):\\n\\t\\tfor _id in ids[count*g:count*(g+1)]:\\n\\t\\t\\thats[_id] = current_hat\\n\\t\\tcurrent_hat += 1\\n\\nprint(\\\"Possible\\\")\\nprint(*hats)\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\n\\nLIST=[[] for i in range(n+1)]\\n\\nfor i in range(n):\\n    LIST[n-A[i]].append(i)\\n\\nANSLIST=[None]*(n+1)\\nh=1\\nfor i in range(1,n+1):\\n    if len(LIST[i])%i!=0:\\n        print(\\\"Impossible\\\")\\n        return\\n\\n    else:\\n        j=0\\n        while j<len(LIST[i]):\\n            ANSLIST[LIST[i][j]]=h\\n            j+=1\\n            if j%i==0:\\n                h+=1\\n\\nprint(\\\"Possible\\\")\\nfor a in ANSLIST[:-1]:\\n    print(a,end=\\\" \\\")\\n\\n\\n\", \"n = int(input())\\nb = list(map(int, input().split()))\\na = [[b[i], i] for i in range(n)]\\na.sort()\\n\\nans = [0] * n\\n\\ncur = 0\\nnum = 1\\nwhile cur < n:\\n\\tnec = a[cur][0]\\n\\tng = False\\n\\tfor i in range(n-nec):\\n\\t\\tif cur+i >= n:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telif a[cur+i][0] != a[cur][0]:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telse:\\n\\t\\t\\tans[a[cur+i][1]] = num \\n\\n\\tif ng:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\tbreak\\n\\n\\tnum += 1\\n\\tcur += n-nec\\n\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*ans)\", \"n=int(input())\\na=list(map(int,input().split()))\\ncounts=[0]*n\\ndone=False\\nfor i in range(n):\\n    counts[a[i]]+=1\\nfor i in range(n):\\n    if counts[i]%(n-i)!=0:\\n        print(\\\"Impossible\\\")\\n        done=True\\n        break\\n    else:\\n        counts[i]//=(n-i)\\ncountsum=[counts[0]]\\nfor i in range(n-1):\\n    countsum.append(countsum[-1]+counts[i+1])\\nb=[]\\nseen=[0]*n\\nfor i in range(n):\\n    b.append(countsum[a[i]]-seen[a[i]]//(n-a[i]))\\n    seen[a[i]]+=1\\nout=\\\"\\\"\\nfor i in range(n):\\n    out+=str(b[i])+\\\" \\\"\\nif not done:\\n    print(\\\"Possible\\\")\\n    print(out[:-1])\", \"'''input\\n6\\n3 3 3 3 3 3\\n5\\n3 3 2 2 2\\n4\\n0 1 2 3\\n\\n\\n'''\\nn = int(input())\\na = list(map(int, input().split()))\\ns = [0] * (n + 1)\\nv = [0] * (n + 1)\\nr = [0] * (n + 1)\\nb = [0] * n\\nm = 0\\nfor i in range(n):\\n\\ta[i] = n - a[i]\\n\\ts[a[i]] += 1\\nfor i in range(n):\\n\\tif r[a[i]] == 0:\\n\\t\\tm += 1\\n\\t\\tv[a[i]] = m\\n\\t\\tr[a[i]] = a[i]\\n\\tb[i] = v[a[i]]\\n\\tr[a[i]] -= 1\\n\\t# print(b[i])\\nif any(x for x in r):\\n\\tprint(\\\"Impossible\\\")\\n\\treturn\\nprint(\\\"Possible\\\")\\nprint(*b)\\n\", \"from collections import Counter as C\\nn = int(input())\\nl = [*map(lambda x: n - int(x), input().split())]\\nc = C(l)\\nd = {}\\n# print(c)\\ntry:\\n    for k, v in c.items():\\n        if v % k == 0:\\n            d[k] = v//k\\n        else:\\n            raise ValueError()\\n    print('Possible')\\n    d_ = {}\\n    curr = 0\\n    for e in l:\\n        # print(d, d_)\\n        if e in d_:\\n            if d_[e][1] >= e:\\n                curr += 1\\n                d_[e] = [curr, 1]\\n            else:\\n                d_[e][1] += 1\\n        else:\\n            curr += 1\\n            d_[e] = [curr, 1]\\n        print(d_[e][0], end=' ')\\nexcept:\\n    print('Impossible')\", \"from collections import Counter\\n\\nn = int(input())\\na = tuple((n - int(x) for x in input().split()))\\na1 = [[] for _ in range(n + 2)]\\n''' :type: list[list[int]] '''\\nb = [1] * n\\nfor i in range(n):\\n\\ta1[a[i]].append(i)\\ni = 1\\nm = 1\\nfor k in range(1, n + 1):\\n\\tfor j in a1[k]:\\n\\t\\tb[j] = i\\n\\t\\tif m == k:\\n\\t\\t\\tm = 1\\n\\t\\t\\ti += 1\\n\\t\\telse:\\n\\t\\t\\tm += 1\\n\\tif m != 1:\\n\\t\\tprint('Impossible')\\n\\t\\tbreak\\nelse:\\n\\tprint('Possible')\\n\\tprint(*b)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = [0] * n\\nfor i in range(n):\\n    b[i] = n - a[i]\\ncnt = [[] for i in range(n + 1)]\\nfor i in range(n):\\n    cnt[b[i]].append(i)\\nf = True\\nfor i in range(1, n + 1):\\n    if len(cnt[i]) % i != 0:\\n        f = False\\n        break\\nif not f:\\n    print(\\\"Impossible\\\")\\nelse:\\n    t = 1\\n    ans = [0] * n\\n    for i in range(1, n + 1):\\n        x = cnt[i]\\n        if len(x) != 0:\\n            y = 0\\n            for j in x:\\n                ans[j] = t\\n                y += 1\\n                if y == i:\\n                    t += 1\\n                    y = 0\\n    print(\\\"Possible\\\")\\n    print(*ans)\", \"n = int(input())\\na = [(n - int(x)) for x in input().split()]\\nb = [0] * n\\nfh = 1\\ni = 0\\nhd = dict()\\nwhile i < n:\\n    if a[i] == 1:\\n        b[i] = fh\\n        fh += 1\\n    elif a[i] in hd:\\n        b[i] = hd[a[i]][0]\\n        hd[a[i]][1] -= 1\\n        if hd[a[i]][1] == 0:\\n            del hd[a[i]]\\n    else:\\n        b[i] = fh\\n        hd[a[i]] = [fh, a[i]-1]\\n        fh += 1\\n    i += 1\\nif len(hd) != 0:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"num = int(input())\\nnums = input()\\nstatement = [int(i) for i in nums.split()]\\n\\nlog = {}\\ngroup_num = {}\\nanchor = 1\\ntotal = num\\nstatus = 'Possible'\\nans = []\\nfor i, s in enumerate(statement):\\n    if s not in log or group_num[s] == 0:\\n        log[s] = anchor\\n        anchor += 1\\n        group_num[s] = num - s\\n        total -= group_num[s]\\n        if total < 0:\\n            status = 'Impossible'\\n            break\\n    ans.append(log[s])\\n    group_num[s] -= 1\\n\\nprint(status)\\nif status == 'Possible':\\n    for i in range(num - 1):\\n        print(ans[i], end=' ')\\n    print(ans[num - 1])\", \"n = int(input())\\naa = list(map(int, input().split()))\\n\\n\\ndef cal():\\n    ncol = [0] * (n + 1)\\n    ansmap = [0] * n\\n    ans = [0] * n\\n    colcnt = [0] * (n + 1)\\n    colmap = [0] * (n + 1)\\n    icol = 0\\n    for i, a in enumerate(aa):\\n        ncol[n - a] += 1\\n        ansmap[i] = n - a\\n\\n    for i, col in enumerate(ncol[1:], 1):\\n        if col % i:\\n            return\\n\\n    for i, col in enumerate(ansmap):\\n        if not colcnt[col] % col:\\n            icol += 1\\n            colmap[col] = icol\\n\\n        ans[i] = colmap[col]\\n        colcnt[col] += 1\\n\\n    return ans\\n\\n\\nans = cal()\\nif ans:\\n    print('Possible')\\n    print(' '.join(map(str, ans)))\\nelse:\\n    print('Impossible')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nif 0 in a:\\n    if len(set(a)) > 1:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        print(*[1]*n)\\nelif not all(q < n for q in a):\\n    print('Impossible')\\nelse:\\n    s = {}\\n    answer = [0 for q in range(n)]\\n    for q in range(len(a)):\\n        if a[q] in s:\\n            s[a[q]].append(q)\\n        else:\\n            s[a[q]] = [q]\\n    q2 = 0\\n    for q in s:\\n        if len(s[q]) % (n-q) != 0:\\n            print('Impossible')\\n            break\\n        for q1 in range(len(s[q])):\\n            if q1 % (n-q) == 0:\\n                q2 += 1\\n            answer[s[q][q1]] = q2\\n    else:\\n        print('Possible')\\n        print(*answer)\\n\", \"n = int(input())\\na = [int(s) for s in input().split()]\\nb = [-1 for i in range(n)]\\nm = {}\\nnextnum = 1\\nfor i in range(n):\\n    # print(m)\\n    if b[i] == -1:\\n        if m.get(a[i]) and m[a[i]][1] > 0:\\n            b[i] = m[a[i]][0]\\n            m[a[i]][1] -= 1\\n            if m[a[i]][1] == 0:\\n                m.pop(a[i])\\n        else:\\n            z = n-a[i]-1\\n            b[i] = nextnum\\n            if z:\\n                m[a[i]] = [nextnum, z]\\n            nextnum += 1\\n\\nif m:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"n = int(input())\\n\\ncl = list(map(int, input().split()))\\n\\npos = {}\\ncolor = 0\\nres = []\\n\\nfor x in cl:\\n  if x in pos.keys():\\n    if pos[x][0]!=0:\\n      res.append(pos[x][1])\\n      pos[x][0]-=1\\n    else:\\n      color+=1\\n      res.append(color)\\n      pos[x] = [n-x-1, color]\\n  else:\\n    color+=1\\n    res.append(color)\\n    pos.update({x:[n-x-1, color]})\\n\\nfor x in pos.keys():\\n  if pos[x][0]!=0:\\n    print(\\\"Impossible\\\")\\n    return\\n\\nprint(\\\"Possible\\\")\\nprint(*res)\", \"n=int(input())\\narr=list(map(int,input().split()))\\nansarr=[0]*n\\nflag=0\\ndict1={}\\ndict2={}\\nfor i in range(n):\\n    try:\\n        dict1[arr[i]].append(i)\\n    except:\\n        KeyError\\n        dict1[arr[i]]=[i]\\n        dict2[arr[i]]=0\\n\\ntempcount=0\\nfor i in dict1.keys():\\n    count=0\\n    while(dict2[i]<len(dict1[i])):\\n        if(dict2[i]+n-i>len(dict1[i])):\\n            flag=1\\n            break\\n        else:\\n            tempcount+=n-i\\n            dict2[i]+=n-i\\nif(tempcount!=n):\\n    flag=1\\nif(flag==1):\\n    print('Impossible')\\nelse:\\n    count=0\\n    val=1\\n    for i in dict1.keys():\\n        for j in range(0,len(dict1[i]),n-i):\\n            for k in range(n-int(i)):\\n                ansarr[dict1[i][j+k]]=val\\n            val+=1\\n    print('Possible')\\n    print(*ansarr)\", \"#!/usr/bin/env python3\\nimport sys\\ndef __starting_point():\\n    n = int(input())\\n    a = {}\\n    a_s = input().split()\\n    for i in range(n):\\n        x = n - int(a_s[i])\\n        a[x] = a.get(x, 0) + 1\\n        a_s[i] = x\\n    for i in a:\\n        if (i < 1) or (i > n):\\n            print(\\\"Impossible\\\")\\n            return\\n        if a[i] % i != 0:\\n            print(\\\"Impossible\\\")\\n            return\\n    print(\\\"Possible\\\")\\n    used = 0\\n    col = {}\\n    num = {}\\n    b = []\\n    for x in a_s:\\n        if x not in col or num[x] == x:\\n            used += 1\\n            col[x] = used\\n            num[x] = 1\\n            b.append(used)\\n        else:\\n            num[x] += 1\\n            b.append(col[x])\\n    print(\\\" \\\".join(map(str, b)))\\n\\n__starting_point()\", \"n = int(input())\\na = [int(element) for element in input().split(' ')]\\nb = dict()\\nfor i in range(n):\\n    try:\\n        b[a[i]] += 1\\n    except:\\n        b[a[i]] = 1\\nc = [(b[k] % (n-k)) == 0 for k in list(b.keys())]\\nd = [b[k] for k in a]\\n\\nif all(c):\\n    print(\\\"Possible\\\")\\n    types = dict()\\n    hat = 1\\n    for k in list(b.keys()):\\n        pergroup = n-k\\n        groups = b[k] // pergroup\\n        hatsgroup = list()\\n        for i in range(groups):\\n            for j in range(pergroup):\\n                hatsgroup.append(hat)\\n            hat += 1\\n        types[k] = hatsgroup\\n    hats = list()\\n    for i in range(n):\\n        hats.append(types[a[i]].pop())\\n    print(' '.join(str(e) for e in hats))\\n\\nelse:\\n    print(\\\"Impossible\\\")\\n\", \"import math\\n\\n\\ndef hats(n, arr):\\n    processed = [False] * n\\n    hats = [None] * n\\n    cur_hat = 0\\n    for i, diff_count in enumerate(arr):\\n        if processed[i]: continue\\n        cur_hat += 1\\n        hats[i] = cur_hat\\n        processed[i] = True\\n        same_count = n - diff_count - 1\\n        if not same_count: continue\\n        for j in range(i+1, n):\\n            if arr[j] == diff_count:\\n                same_count -= 1\\n                processed[j] = True\\n                hats[j] = cur_hat\\n            if not same_count:\\n                break\\n        if same_count:\\n            print('Impossible')\\n            return\\n    print('Possible')\\n    print(' '.join(list(map(str, hats))))\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    answers = list(map(int, input().strip().split()))\\n    hats(n, answers)\\n\\n__starting_point()\", \"n=int(input())\\na=list(map(int,input().split()))\\nd={}\\nl=[[] for i in range(n+1)]\\nfor i in range(n):\\n    d[a[i]]=d.get(a[i],0)+1\\n    l[n-a[i]].append(i+1)\\nb=list(d.keys())\\nc=[]\\nfor i in b:\\n    c.append([d[i]//(n-i),n-i])\\nk=0\\nfor i in c:\\n    k+=i[0]*i[1]\\nif k!=n:\\n    print('Impossible')\\nelse:\\n    print('Possible')\\n    co=1\\n    ans=[0]*(n+1)\\n    for i in c:\\n        for j in range(i[0]):\\n            for k in range(i[1]):\\n                x=l[i[1]].pop()\\n                ans[x]=co\\n            co+=1\\n    print(*ans[1:])\", \"n = int(input())\\nL = [n-int(x) for x in input().split()]\\nD = {}\\nfor i in L:\\n    if i in D:\\n        D[i] += 1\\n    else:\\n        D[i] = 1\\ns = 0\\ncheck = True\\nfor i in D.keys():\\n    if D[i]%i != 0:\\n        check = False\\n        break\\n    else:\\n        s += D[i]\\nif s != n:\\n    print('Impossible')\\n\\nelse:\\n    if check == False:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        small = 1\\n        D2 = {}\\n        for i in D:\\n            D2[i] = list(range(small,small+(D[i]//i)))*i\\n            small += D[i]//i\\n        for i in L:\\n            print(D2[i][-1],end = ' ')\\n            D2[i].pop()\"]",
        "difficulty": "interview",
        "input": "1\n0\n",
        "output": "Possible\n1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1081/B"
    },
    {
        "id": 1556,
        "task_id": 942,
        "test_case_id": 13,
        "question": "Chouti and his classmates are going to the university soon. To say goodbye to each other, the class has planned a big farewell party in which classmates, teachers and parents sang and danced.\n\nChouti remembered that $n$ persons took part in that party. To make the party funnier, each person wore one hat among $n$ kinds of weird hats numbered $1, 2, \\ldots n$. It is possible that several persons wore hats of the same kind. Some kinds of hats can remain unclaimed by anyone.\n\nAfter the party, the $i$-th person said that there were $a_i$ persons wearing a hat differing from his own.\n\nIt has been some days, so Chouti forgot all about others' hats, but he is curious about that. Let $b_i$ be the number of hat type the $i$-th person was wearing, Chouti wants you to find any possible $b_1, b_2, \\ldots, b_n$ that doesn't contradict with any person's statement. Because some persons might have a poor memory, there could be no solution at all.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 10^5$), the number of persons in the party.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\le a_i \\le n-1$), the statements of people.\n\n\n-----Output-----\n\nIf there is no solution, print a single line \"Impossible\".\n\nOtherwise, print \"Possible\" and then $n$ integers $b_1, b_2, \\ldots, b_n$ ($1 \\le b_i \\le n$).\n\nIf there are multiple answers, print any of them.\n\n\n-----Examples-----\nInput\n3\n0 0 0\n\nOutput\nPossible\n1 1 1 \nInput\n5\n3 3 2 2 2\n\nOutput\nPossible\n1 1 2 2 2 \nInput\n4\n0 1 2 3\n\nOutput\nImpossible\n\n\n\n-----Note-----\n\nIn the answer to the first example, all hats are the same, so every person will say that there were no persons wearing a hat different from kind $1$.\n\nIn the answer to the second example, the first and the second person wore the hat with type $1$ and all other wore a hat of type $2$.\n\nSo the first two persons will say there were three persons with hats differing from their own. Similarly, three last persons will say there were two persons wearing a hat different from their own.\n\nIn the third example, it can be shown that no solution exists.\n\nIn the first and the second example, other possible configurations are possible.",
        "solutions": "[\"input()\\nl = list(map(int, input().split()))\\nd = {}\\nd2 = {}\\nans = []\\nn = 1\\nfor i in l:\\n    i = len(l) - i\\n    if i not in d:\\n        d[i] = n\\n        n += 1\\n    if i not in d2:\\n        d2[i] = 0\\n    if d2[i] >= i:\\n        d[i] = n\\n        d2[i] = 0\\n        n += 1\\n    ans.append(d[i])\\n    d2[i] += 1\\nnums = {}\\ntot = 0\\nfor i in ans:\\n    tot += 1\\n    if i not in nums:\\n        nums[i] = 0\\n    nums[i] += 1\\nfor i in range(len(ans)):\\n    if tot - nums[ans[i]] != l[i]:\\n        print(\\\"Impossible\\\")\\n        return\\nprint(\\\"Possible\\\")\\nprint(\\\" \\\".join(map(str, ans)))\\n\\n\", \"import math\\n\\ndef __starting_point():\\n\\n\\tn = int(input())\\n\\tarr = [int(x) for x  in input().split()]\\n\\n\\n\\tans  = []\\n\\td = {}\\n\\tc = {}\\n\\tb = [0]*n\\n\\tind  = 0 \\n\\tfor i in range(n) : \\n\\t\\tif arr[i] in list(d.keys()) : \\n\\t\\t\\tif d[arr[i]]== 0 :\\n\\t\\t\\t\\tind+=1\\n\\t\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\t\\tb[i]=ind\\n\\t\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\t\\t\\telse :\\n\\t\\t\\t\\td[arr[i]]-=1\\n\\t\\t\\t\\tb[i]=c[arr[i]]\\n\\t\\telse : \\n\\t\\t\\tind+=1\\n\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\tb[i]=ind\\n\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\tans = True\\n\\tfor i in d : \\n\\t\\tif d[i]!=0:\\n\\t\\t\\tans =False\\n\\tif ans : \\n\\t\\tprint (\\\"Possible\\\")\\n\\t\\tprint(*b)\\n\\telse : \\n\\t\\tprint(\\\"Impossible\\\")\\n\\n\\n\\n\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nt = 0\\nd1 = {}\\nuse1 = {}\\nuse = {}\\nfor x in a:\\n\\tif x in d1:\\n\\t\\tif use1[x] == n - x:\\n\\t\\t\\tt += (n - x)\\n\\t\\t\\tuse1[x] = 0\\n\\t\\tuse1[x] += 1\\n\\telse:\\n\\t\\td1[x] = 0\\n\\t\\tt += (n - x)\\n\\t\\tuse1[x] = 1\\n\\nif n != t:\\n\\tprint(\\\"Impossible\\\")\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\td = {}\\n\\tcv = 1\\n\\tfor x in a:\\n\\t\\tif x in d:\\n\\t\\t\\tif use[d[x]] == n - x:\\n\\t\\t\\t\\td[x] = cv\\n\\t\\t\\t\\tcv += 1\\n\\t\\t\\t\\tuse[d[x]] = 0\\n\\t\\t\\tuse[d[x]] += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\\t\\telse:\\n\\t\\t\\td[x] = cv\\n\\t\\t\\tuse[d[x]] = 1\\n\\t\\t\\tcv += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\", \"import sys\\nfrom math import *\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef main():\\n\\tn = mint()\\n\\ta = [None]*n\\n\\tr = [None]*n\\n\\tj = 0\\n\\tfor i in mints():\\n\\t\\ta[j] = (n-i, j)\\n\\t\\tj+=1\\n\\ta.sort()\\n\\tj = 1\\n\\ti = 0\\n\\twhile i < n:\\n\\t\\tcnt = a[i][0]\\n\\t\\tfor k in range(i,i+cnt):\\n\\t\\t\\tif k >= n or a[k][0] != cnt:\\n\\t\\t\\t\\tprint(\\\"Impossible\\\")\\n\\t\\t\\t\\treturn\\n\\t\\t\\tr[a[k][1]] = j\\n\\t\\tj+=1\\n\\t\\ti+=cnt\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*r)\\n\\nmain()\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = [n-x for x in a]\\n\\ngroups = {}\\nfor i, x in enumerate(a):\\n\\tif x not in groups:\\n\\t\\tgroups[x] = []\\n\\tgroups[x].append(i)\\n\\nhats = [0] * n\\ncurrent_hat = 1\\n\\nfor count, ids in list(groups.items()):\\n\\tif len(ids)%count != 0:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\treturn\\n\\n\\tfor g in range(len(ids)//count):\\n\\t\\tfor _id in ids[count*g:count*(g+1)]:\\n\\t\\t\\thats[_id] = current_hat\\n\\t\\tcurrent_hat += 1\\n\\nprint(\\\"Possible\\\")\\nprint(*hats)\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\n\\nLIST=[[] for i in range(n+1)]\\n\\nfor i in range(n):\\n    LIST[n-A[i]].append(i)\\n\\nANSLIST=[None]*(n+1)\\nh=1\\nfor i in range(1,n+1):\\n    if len(LIST[i])%i!=0:\\n        print(\\\"Impossible\\\")\\n        return\\n\\n    else:\\n        j=0\\n        while j<len(LIST[i]):\\n            ANSLIST[LIST[i][j]]=h\\n            j+=1\\n            if j%i==0:\\n                h+=1\\n\\nprint(\\\"Possible\\\")\\nfor a in ANSLIST[:-1]:\\n    print(a,end=\\\" \\\")\\n\\n\\n\", \"n = int(input())\\nb = list(map(int, input().split()))\\na = [[b[i], i] for i in range(n)]\\na.sort()\\n\\nans = [0] * n\\n\\ncur = 0\\nnum = 1\\nwhile cur < n:\\n\\tnec = a[cur][0]\\n\\tng = False\\n\\tfor i in range(n-nec):\\n\\t\\tif cur+i >= n:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telif a[cur+i][0] != a[cur][0]:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telse:\\n\\t\\t\\tans[a[cur+i][1]] = num \\n\\n\\tif ng:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\tbreak\\n\\n\\tnum += 1\\n\\tcur += n-nec\\n\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*ans)\", \"n=int(input())\\na=list(map(int,input().split()))\\ncounts=[0]*n\\ndone=False\\nfor i in range(n):\\n    counts[a[i]]+=1\\nfor i in range(n):\\n    if counts[i]%(n-i)!=0:\\n        print(\\\"Impossible\\\")\\n        done=True\\n        break\\n    else:\\n        counts[i]//=(n-i)\\ncountsum=[counts[0]]\\nfor i in range(n-1):\\n    countsum.append(countsum[-1]+counts[i+1])\\nb=[]\\nseen=[0]*n\\nfor i in range(n):\\n    b.append(countsum[a[i]]-seen[a[i]]//(n-a[i]))\\n    seen[a[i]]+=1\\nout=\\\"\\\"\\nfor i in range(n):\\n    out+=str(b[i])+\\\" \\\"\\nif not done:\\n    print(\\\"Possible\\\")\\n    print(out[:-1])\", \"'''input\\n6\\n3 3 3 3 3 3\\n5\\n3 3 2 2 2\\n4\\n0 1 2 3\\n\\n\\n'''\\nn = int(input())\\na = list(map(int, input().split()))\\ns = [0] * (n + 1)\\nv = [0] * (n + 1)\\nr = [0] * (n + 1)\\nb = [0] * n\\nm = 0\\nfor i in range(n):\\n\\ta[i] = n - a[i]\\n\\ts[a[i]] += 1\\nfor i in range(n):\\n\\tif r[a[i]] == 0:\\n\\t\\tm += 1\\n\\t\\tv[a[i]] = m\\n\\t\\tr[a[i]] = a[i]\\n\\tb[i] = v[a[i]]\\n\\tr[a[i]] -= 1\\n\\t# print(b[i])\\nif any(x for x in r):\\n\\tprint(\\\"Impossible\\\")\\n\\treturn\\nprint(\\\"Possible\\\")\\nprint(*b)\\n\", \"from collections import Counter as C\\nn = int(input())\\nl = [*map(lambda x: n - int(x), input().split())]\\nc = C(l)\\nd = {}\\n# print(c)\\ntry:\\n    for k, v in c.items():\\n        if v % k == 0:\\n            d[k] = v//k\\n        else:\\n            raise ValueError()\\n    print('Possible')\\n    d_ = {}\\n    curr = 0\\n    for e in l:\\n        # print(d, d_)\\n        if e in d_:\\n            if d_[e][1] >= e:\\n                curr += 1\\n                d_[e] = [curr, 1]\\n            else:\\n                d_[e][1] += 1\\n        else:\\n            curr += 1\\n            d_[e] = [curr, 1]\\n        print(d_[e][0], end=' ')\\nexcept:\\n    print('Impossible')\", \"from collections import Counter\\n\\nn = int(input())\\na = tuple((n - int(x) for x in input().split()))\\na1 = [[] for _ in range(n + 2)]\\n''' :type: list[list[int]] '''\\nb = [1] * n\\nfor i in range(n):\\n\\ta1[a[i]].append(i)\\ni = 1\\nm = 1\\nfor k in range(1, n + 1):\\n\\tfor j in a1[k]:\\n\\t\\tb[j] = i\\n\\t\\tif m == k:\\n\\t\\t\\tm = 1\\n\\t\\t\\ti += 1\\n\\t\\telse:\\n\\t\\t\\tm += 1\\n\\tif m != 1:\\n\\t\\tprint('Impossible')\\n\\t\\tbreak\\nelse:\\n\\tprint('Possible')\\n\\tprint(*b)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = [0] * n\\nfor i in range(n):\\n    b[i] = n - a[i]\\ncnt = [[] for i in range(n + 1)]\\nfor i in range(n):\\n    cnt[b[i]].append(i)\\nf = True\\nfor i in range(1, n + 1):\\n    if len(cnt[i]) % i != 0:\\n        f = False\\n        break\\nif not f:\\n    print(\\\"Impossible\\\")\\nelse:\\n    t = 1\\n    ans = [0] * n\\n    for i in range(1, n + 1):\\n        x = cnt[i]\\n        if len(x) != 0:\\n            y = 0\\n            for j in x:\\n                ans[j] = t\\n                y += 1\\n                if y == i:\\n                    t += 1\\n                    y = 0\\n    print(\\\"Possible\\\")\\n    print(*ans)\", \"n = int(input())\\na = [(n - int(x)) for x in input().split()]\\nb = [0] * n\\nfh = 1\\ni = 0\\nhd = dict()\\nwhile i < n:\\n    if a[i] == 1:\\n        b[i] = fh\\n        fh += 1\\n    elif a[i] in hd:\\n        b[i] = hd[a[i]][0]\\n        hd[a[i]][1] -= 1\\n        if hd[a[i]][1] == 0:\\n            del hd[a[i]]\\n    else:\\n        b[i] = fh\\n        hd[a[i]] = [fh, a[i]-1]\\n        fh += 1\\n    i += 1\\nif len(hd) != 0:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"num = int(input())\\nnums = input()\\nstatement = [int(i) for i in nums.split()]\\n\\nlog = {}\\ngroup_num = {}\\nanchor = 1\\ntotal = num\\nstatus = 'Possible'\\nans = []\\nfor i, s in enumerate(statement):\\n    if s not in log or group_num[s] == 0:\\n        log[s] = anchor\\n        anchor += 1\\n        group_num[s] = num - s\\n        total -= group_num[s]\\n        if total < 0:\\n            status = 'Impossible'\\n            break\\n    ans.append(log[s])\\n    group_num[s] -= 1\\n\\nprint(status)\\nif status == 'Possible':\\n    for i in range(num - 1):\\n        print(ans[i], end=' ')\\n    print(ans[num - 1])\", \"n = int(input())\\naa = list(map(int, input().split()))\\n\\n\\ndef cal():\\n    ncol = [0] * (n + 1)\\n    ansmap = [0] * n\\n    ans = [0] * n\\n    colcnt = [0] * (n + 1)\\n    colmap = [0] * (n + 1)\\n    icol = 0\\n    for i, a in enumerate(aa):\\n        ncol[n - a] += 1\\n        ansmap[i] = n - a\\n\\n    for i, col in enumerate(ncol[1:], 1):\\n        if col % i:\\n            return\\n\\n    for i, col in enumerate(ansmap):\\n        if not colcnt[col] % col:\\n            icol += 1\\n            colmap[col] = icol\\n\\n        ans[i] = colmap[col]\\n        colcnt[col] += 1\\n\\n    return ans\\n\\n\\nans = cal()\\nif ans:\\n    print('Possible')\\n    print(' '.join(map(str, ans)))\\nelse:\\n    print('Impossible')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nif 0 in a:\\n    if len(set(a)) > 1:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        print(*[1]*n)\\nelif not all(q < n for q in a):\\n    print('Impossible')\\nelse:\\n    s = {}\\n    answer = [0 for q in range(n)]\\n    for q in range(len(a)):\\n        if a[q] in s:\\n            s[a[q]].append(q)\\n        else:\\n            s[a[q]] = [q]\\n    q2 = 0\\n    for q in s:\\n        if len(s[q]) % (n-q) != 0:\\n            print('Impossible')\\n            break\\n        for q1 in range(len(s[q])):\\n            if q1 % (n-q) == 0:\\n                q2 += 1\\n            answer[s[q][q1]] = q2\\n    else:\\n        print('Possible')\\n        print(*answer)\\n\", \"n = int(input())\\na = [int(s) for s in input().split()]\\nb = [-1 for i in range(n)]\\nm = {}\\nnextnum = 1\\nfor i in range(n):\\n    # print(m)\\n    if b[i] == -1:\\n        if m.get(a[i]) and m[a[i]][1] > 0:\\n            b[i] = m[a[i]][0]\\n            m[a[i]][1] -= 1\\n            if m[a[i]][1] == 0:\\n                m.pop(a[i])\\n        else:\\n            z = n-a[i]-1\\n            b[i] = nextnum\\n            if z:\\n                m[a[i]] = [nextnum, z]\\n            nextnum += 1\\n\\nif m:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"n = int(input())\\n\\ncl = list(map(int, input().split()))\\n\\npos = {}\\ncolor = 0\\nres = []\\n\\nfor x in cl:\\n  if x in pos.keys():\\n    if pos[x][0]!=0:\\n      res.append(pos[x][1])\\n      pos[x][0]-=1\\n    else:\\n      color+=1\\n      res.append(color)\\n      pos[x] = [n-x-1, color]\\n  else:\\n    color+=1\\n    res.append(color)\\n    pos.update({x:[n-x-1, color]})\\n\\nfor x in pos.keys():\\n  if pos[x][0]!=0:\\n    print(\\\"Impossible\\\")\\n    return\\n\\nprint(\\\"Possible\\\")\\nprint(*res)\", \"n=int(input())\\narr=list(map(int,input().split()))\\nansarr=[0]*n\\nflag=0\\ndict1={}\\ndict2={}\\nfor i in range(n):\\n    try:\\n        dict1[arr[i]].append(i)\\n    except:\\n        KeyError\\n        dict1[arr[i]]=[i]\\n        dict2[arr[i]]=0\\n\\ntempcount=0\\nfor i in dict1.keys():\\n    count=0\\n    while(dict2[i]<len(dict1[i])):\\n        if(dict2[i]+n-i>len(dict1[i])):\\n            flag=1\\n            break\\n        else:\\n            tempcount+=n-i\\n            dict2[i]+=n-i\\nif(tempcount!=n):\\n    flag=1\\nif(flag==1):\\n    print('Impossible')\\nelse:\\n    count=0\\n    val=1\\n    for i in dict1.keys():\\n        for j in range(0,len(dict1[i]),n-i):\\n            for k in range(n-int(i)):\\n                ansarr[dict1[i][j+k]]=val\\n            val+=1\\n    print('Possible')\\n    print(*ansarr)\", \"#!/usr/bin/env python3\\nimport sys\\ndef __starting_point():\\n    n = int(input())\\n    a = {}\\n    a_s = input().split()\\n    for i in range(n):\\n        x = n - int(a_s[i])\\n        a[x] = a.get(x, 0) + 1\\n        a_s[i] = x\\n    for i in a:\\n        if (i < 1) or (i > n):\\n            print(\\\"Impossible\\\")\\n            return\\n        if a[i] % i != 0:\\n            print(\\\"Impossible\\\")\\n            return\\n    print(\\\"Possible\\\")\\n    used = 0\\n    col = {}\\n    num = {}\\n    b = []\\n    for x in a_s:\\n        if x not in col or num[x] == x:\\n            used += 1\\n            col[x] = used\\n            num[x] = 1\\n            b.append(used)\\n        else:\\n            num[x] += 1\\n            b.append(col[x])\\n    print(\\\" \\\".join(map(str, b)))\\n\\n__starting_point()\", \"n = int(input())\\na = [int(element) for element in input().split(' ')]\\nb = dict()\\nfor i in range(n):\\n    try:\\n        b[a[i]] += 1\\n    except:\\n        b[a[i]] = 1\\nc = [(b[k] % (n-k)) == 0 for k in list(b.keys())]\\nd = [b[k] for k in a]\\n\\nif all(c):\\n    print(\\\"Possible\\\")\\n    types = dict()\\n    hat = 1\\n    for k in list(b.keys()):\\n        pergroup = n-k\\n        groups = b[k] // pergroup\\n        hatsgroup = list()\\n        for i in range(groups):\\n            for j in range(pergroup):\\n                hatsgroup.append(hat)\\n            hat += 1\\n        types[k] = hatsgroup\\n    hats = list()\\n    for i in range(n):\\n        hats.append(types[a[i]].pop())\\n    print(' '.join(str(e) for e in hats))\\n\\nelse:\\n    print(\\\"Impossible\\\")\\n\", \"import math\\n\\n\\ndef hats(n, arr):\\n    processed = [False] * n\\n    hats = [None] * n\\n    cur_hat = 0\\n    for i, diff_count in enumerate(arr):\\n        if processed[i]: continue\\n        cur_hat += 1\\n        hats[i] = cur_hat\\n        processed[i] = True\\n        same_count = n - diff_count - 1\\n        if not same_count: continue\\n        for j in range(i+1, n):\\n            if arr[j] == diff_count:\\n                same_count -= 1\\n                processed[j] = True\\n                hats[j] = cur_hat\\n            if not same_count:\\n                break\\n        if same_count:\\n            print('Impossible')\\n            return\\n    print('Possible')\\n    print(' '.join(list(map(str, hats))))\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    answers = list(map(int, input().strip().split()))\\n    hats(n, answers)\\n\\n__starting_point()\", \"n=int(input())\\na=list(map(int,input().split()))\\nd={}\\nl=[[] for i in range(n+1)]\\nfor i in range(n):\\n    d[a[i]]=d.get(a[i],0)+1\\n    l[n-a[i]].append(i+1)\\nb=list(d.keys())\\nc=[]\\nfor i in b:\\n    c.append([d[i]//(n-i),n-i])\\nk=0\\nfor i in c:\\n    k+=i[0]*i[1]\\nif k!=n:\\n    print('Impossible')\\nelse:\\n    print('Possible')\\n    co=1\\n    ans=[0]*(n+1)\\n    for i in c:\\n        for j in range(i[0]):\\n            for k in range(i[1]):\\n                x=l[i[1]].pop()\\n                ans[x]=co\\n            co+=1\\n    print(*ans[1:])\", \"n = int(input())\\nL = [n-int(x) for x in input().split()]\\nD = {}\\nfor i in L:\\n    if i in D:\\n        D[i] += 1\\n    else:\\n        D[i] = 1\\ns = 0\\ncheck = True\\nfor i in D.keys():\\n    if D[i]%i != 0:\\n        check = False\\n        break\\n    else:\\n        s += D[i]\\nif s != n:\\n    print('Impossible')\\n\\nelse:\\n    if check == False:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        small = 1\\n        D2 = {}\\n        for i in D:\\n            D2[i] = list(range(small,small+(D[i]//i)))*i\\n            small += D[i]//i\\n        for i in L:\\n            print(D2[i][-1],end = ' ')\\n            D2[i].pop()\"]",
        "difficulty": "interview",
        "input": "2\n1 1\n",
        "output": "Possible\n1 2 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1081/B"
    },
    {
        "id": 1557,
        "task_id": 942,
        "test_case_id": 15,
        "question": "Chouti and his classmates are going to the university soon. To say goodbye to each other, the class has planned a big farewell party in which classmates, teachers and parents sang and danced.\n\nChouti remembered that $n$ persons took part in that party. To make the party funnier, each person wore one hat among $n$ kinds of weird hats numbered $1, 2, \\ldots n$. It is possible that several persons wore hats of the same kind. Some kinds of hats can remain unclaimed by anyone.\n\nAfter the party, the $i$-th person said that there were $a_i$ persons wearing a hat differing from his own.\n\nIt has been some days, so Chouti forgot all about others' hats, but he is curious about that. Let $b_i$ be the number of hat type the $i$-th person was wearing, Chouti wants you to find any possible $b_1, b_2, \\ldots, b_n$ that doesn't contradict with any person's statement. Because some persons might have a poor memory, there could be no solution at all.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 10^5$), the number of persons in the party.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\le a_i \\le n-1$), the statements of people.\n\n\n-----Output-----\n\nIf there is no solution, print a single line \"Impossible\".\n\nOtherwise, print \"Possible\" and then $n$ integers $b_1, b_2, \\ldots, b_n$ ($1 \\le b_i \\le n$).\n\nIf there are multiple answers, print any of them.\n\n\n-----Examples-----\nInput\n3\n0 0 0\n\nOutput\nPossible\n1 1 1 \nInput\n5\n3 3 2 2 2\n\nOutput\nPossible\n1 1 2 2 2 \nInput\n4\n0 1 2 3\n\nOutput\nImpossible\n\n\n\n-----Note-----\n\nIn the answer to the first example, all hats are the same, so every person will say that there were no persons wearing a hat different from kind $1$.\n\nIn the answer to the second example, the first and the second person wore the hat with type $1$ and all other wore a hat of type $2$.\n\nSo the first two persons will say there were three persons with hats differing from their own. Similarly, three last persons will say there were two persons wearing a hat different from their own.\n\nIn the third example, it can be shown that no solution exists.\n\nIn the first and the second example, other possible configurations are possible.",
        "solutions": "[\"input()\\nl = list(map(int, input().split()))\\nd = {}\\nd2 = {}\\nans = []\\nn = 1\\nfor i in l:\\n    i = len(l) - i\\n    if i not in d:\\n        d[i] = n\\n        n += 1\\n    if i not in d2:\\n        d2[i] = 0\\n    if d2[i] >= i:\\n        d[i] = n\\n        d2[i] = 0\\n        n += 1\\n    ans.append(d[i])\\n    d2[i] += 1\\nnums = {}\\ntot = 0\\nfor i in ans:\\n    tot += 1\\n    if i not in nums:\\n        nums[i] = 0\\n    nums[i] += 1\\nfor i in range(len(ans)):\\n    if tot - nums[ans[i]] != l[i]:\\n        print(\\\"Impossible\\\")\\n        return\\nprint(\\\"Possible\\\")\\nprint(\\\" \\\".join(map(str, ans)))\\n\\n\", \"import math\\n\\ndef __starting_point():\\n\\n\\tn = int(input())\\n\\tarr = [int(x) for x  in input().split()]\\n\\n\\n\\tans  = []\\n\\td = {}\\n\\tc = {}\\n\\tb = [0]*n\\n\\tind  = 0 \\n\\tfor i in range(n) : \\n\\t\\tif arr[i] in list(d.keys()) : \\n\\t\\t\\tif d[arr[i]]== 0 :\\n\\t\\t\\t\\tind+=1\\n\\t\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\t\\tb[i]=ind\\n\\t\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\t\\t\\telse :\\n\\t\\t\\t\\td[arr[i]]-=1\\n\\t\\t\\t\\tb[i]=c[arr[i]]\\n\\t\\telse : \\n\\t\\t\\tind+=1\\n\\t\\t\\tc[arr[i]]=ind\\n\\t\\t\\tb[i]=ind\\n\\t\\t\\td[arr[i]]=n-arr[i]-1\\n\\tans = True\\n\\tfor i in d : \\n\\t\\tif d[i]!=0:\\n\\t\\t\\tans =False\\n\\tif ans : \\n\\t\\tprint (\\\"Possible\\\")\\n\\t\\tprint(*b)\\n\\telse : \\n\\t\\tprint(\\\"Impossible\\\")\\n\\n\\n\\n\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nt = 0\\nd1 = {}\\nuse1 = {}\\nuse = {}\\nfor x in a:\\n\\tif x in d1:\\n\\t\\tif use1[x] == n - x:\\n\\t\\t\\tt += (n - x)\\n\\t\\t\\tuse1[x] = 0\\n\\t\\tuse1[x] += 1\\n\\telse:\\n\\t\\td1[x] = 0\\n\\t\\tt += (n - x)\\n\\t\\tuse1[x] = 1\\n\\nif n != t:\\n\\tprint(\\\"Impossible\\\")\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\td = {}\\n\\tcv = 1\\n\\tfor x in a:\\n\\t\\tif x in d:\\n\\t\\t\\tif use[d[x]] == n - x:\\n\\t\\t\\t\\td[x] = cv\\n\\t\\t\\t\\tcv += 1\\n\\t\\t\\t\\tuse[d[x]] = 0\\n\\t\\t\\tuse[d[x]] += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\\t\\telse:\\n\\t\\t\\td[x] = cv\\n\\t\\t\\tuse[d[x]] = 1\\n\\t\\t\\tcv += 1\\n\\t\\t\\tprint(d[x], end = ' ')\\n\", \"import sys\\nfrom math import *\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef main():\\n\\tn = mint()\\n\\ta = [None]*n\\n\\tr = [None]*n\\n\\tj = 0\\n\\tfor i in mints():\\n\\t\\ta[j] = (n-i, j)\\n\\t\\tj+=1\\n\\ta.sort()\\n\\tj = 1\\n\\ti = 0\\n\\twhile i < n:\\n\\t\\tcnt = a[i][0]\\n\\t\\tfor k in range(i,i+cnt):\\n\\t\\t\\tif k >= n or a[k][0] != cnt:\\n\\t\\t\\t\\tprint(\\\"Impossible\\\")\\n\\t\\t\\t\\treturn\\n\\t\\t\\tr[a[k][1]] = j\\n\\t\\tj+=1\\n\\t\\ti+=cnt\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*r)\\n\\nmain()\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = [n-x for x in a]\\n\\ngroups = {}\\nfor i, x in enumerate(a):\\n\\tif x not in groups:\\n\\t\\tgroups[x] = []\\n\\tgroups[x].append(i)\\n\\nhats = [0] * n\\ncurrent_hat = 1\\n\\nfor count, ids in list(groups.items()):\\n\\tif len(ids)%count != 0:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\treturn\\n\\n\\tfor g in range(len(ids)//count):\\n\\t\\tfor _id in ids[count*g:count*(g+1)]:\\n\\t\\t\\thats[_id] = current_hat\\n\\t\\tcurrent_hat += 1\\n\\nprint(\\\"Possible\\\")\\nprint(*hats)\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\n\\nLIST=[[] for i in range(n+1)]\\n\\nfor i in range(n):\\n    LIST[n-A[i]].append(i)\\n\\nANSLIST=[None]*(n+1)\\nh=1\\nfor i in range(1,n+1):\\n    if len(LIST[i])%i!=0:\\n        print(\\\"Impossible\\\")\\n        return\\n\\n    else:\\n        j=0\\n        while j<len(LIST[i]):\\n            ANSLIST[LIST[i][j]]=h\\n            j+=1\\n            if j%i==0:\\n                h+=1\\n\\nprint(\\\"Possible\\\")\\nfor a in ANSLIST[:-1]:\\n    print(a,end=\\\" \\\")\\n\\n\\n\", \"n = int(input())\\nb = list(map(int, input().split()))\\na = [[b[i], i] for i in range(n)]\\na.sort()\\n\\nans = [0] * n\\n\\ncur = 0\\nnum = 1\\nwhile cur < n:\\n\\tnec = a[cur][0]\\n\\tng = False\\n\\tfor i in range(n-nec):\\n\\t\\tif cur+i >= n:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telif a[cur+i][0] != a[cur][0]:\\n\\t\\t\\tng = True\\n\\t\\t\\tbreak\\n\\t\\telse:\\n\\t\\t\\tans[a[cur+i][1]] = num \\n\\n\\tif ng:\\n\\t\\tprint(\\\"Impossible\\\")\\n\\t\\tbreak\\n\\n\\tnum += 1\\n\\tcur += n-nec\\n\\nelse:\\n\\tprint(\\\"Possible\\\")\\n\\tprint(*ans)\", \"n=int(input())\\na=list(map(int,input().split()))\\ncounts=[0]*n\\ndone=False\\nfor i in range(n):\\n    counts[a[i]]+=1\\nfor i in range(n):\\n    if counts[i]%(n-i)!=0:\\n        print(\\\"Impossible\\\")\\n        done=True\\n        break\\n    else:\\n        counts[i]//=(n-i)\\ncountsum=[counts[0]]\\nfor i in range(n-1):\\n    countsum.append(countsum[-1]+counts[i+1])\\nb=[]\\nseen=[0]*n\\nfor i in range(n):\\n    b.append(countsum[a[i]]-seen[a[i]]//(n-a[i]))\\n    seen[a[i]]+=1\\nout=\\\"\\\"\\nfor i in range(n):\\n    out+=str(b[i])+\\\" \\\"\\nif not done:\\n    print(\\\"Possible\\\")\\n    print(out[:-1])\", \"'''input\\n6\\n3 3 3 3 3 3\\n5\\n3 3 2 2 2\\n4\\n0 1 2 3\\n\\n\\n'''\\nn = int(input())\\na = list(map(int, input().split()))\\ns = [0] * (n + 1)\\nv = [0] * (n + 1)\\nr = [0] * (n + 1)\\nb = [0] * n\\nm = 0\\nfor i in range(n):\\n\\ta[i] = n - a[i]\\n\\ts[a[i]] += 1\\nfor i in range(n):\\n\\tif r[a[i]] == 0:\\n\\t\\tm += 1\\n\\t\\tv[a[i]] = m\\n\\t\\tr[a[i]] = a[i]\\n\\tb[i] = v[a[i]]\\n\\tr[a[i]] -= 1\\n\\t# print(b[i])\\nif any(x for x in r):\\n\\tprint(\\\"Impossible\\\")\\n\\treturn\\nprint(\\\"Possible\\\")\\nprint(*b)\\n\", \"from collections import Counter as C\\nn = int(input())\\nl = [*map(lambda x: n - int(x), input().split())]\\nc = C(l)\\nd = {}\\n# print(c)\\ntry:\\n    for k, v in c.items():\\n        if v % k == 0:\\n            d[k] = v//k\\n        else:\\n            raise ValueError()\\n    print('Possible')\\n    d_ = {}\\n    curr = 0\\n    for e in l:\\n        # print(d, d_)\\n        if e in d_:\\n            if d_[e][1] >= e:\\n                curr += 1\\n                d_[e] = [curr, 1]\\n            else:\\n                d_[e][1] += 1\\n        else:\\n            curr += 1\\n            d_[e] = [curr, 1]\\n        print(d_[e][0], end=' ')\\nexcept:\\n    print('Impossible')\", \"from collections import Counter\\n\\nn = int(input())\\na = tuple((n - int(x) for x in input().split()))\\na1 = [[] for _ in range(n + 2)]\\n''' :type: list[list[int]] '''\\nb = [1] * n\\nfor i in range(n):\\n\\ta1[a[i]].append(i)\\ni = 1\\nm = 1\\nfor k in range(1, n + 1):\\n\\tfor j in a1[k]:\\n\\t\\tb[j] = i\\n\\t\\tif m == k:\\n\\t\\t\\tm = 1\\n\\t\\t\\ti += 1\\n\\t\\telse:\\n\\t\\t\\tm += 1\\n\\tif m != 1:\\n\\t\\tprint('Impossible')\\n\\t\\tbreak\\nelse:\\n\\tprint('Possible')\\n\\tprint(*b)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = [0] * n\\nfor i in range(n):\\n    b[i] = n - a[i]\\ncnt = [[] for i in range(n + 1)]\\nfor i in range(n):\\n    cnt[b[i]].append(i)\\nf = True\\nfor i in range(1, n + 1):\\n    if len(cnt[i]) % i != 0:\\n        f = False\\n        break\\nif not f:\\n    print(\\\"Impossible\\\")\\nelse:\\n    t = 1\\n    ans = [0] * n\\n    for i in range(1, n + 1):\\n        x = cnt[i]\\n        if len(x) != 0:\\n            y = 0\\n            for j in x:\\n                ans[j] = t\\n                y += 1\\n                if y == i:\\n                    t += 1\\n                    y = 0\\n    print(\\\"Possible\\\")\\n    print(*ans)\", \"n = int(input())\\na = [(n - int(x)) for x in input().split()]\\nb = [0] * n\\nfh = 1\\ni = 0\\nhd = dict()\\nwhile i < n:\\n    if a[i] == 1:\\n        b[i] = fh\\n        fh += 1\\n    elif a[i] in hd:\\n        b[i] = hd[a[i]][0]\\n        hd[a[i]][1] -= 1\\n        if hd[a[i]][1] == 0:\\n            del hd[a[i]]\\n    else:\\n        b[i] = fh\\n        hd[a[i]] = [fh, a[i]-1]\\n        fh += 1\\n    i += 1\\nif len(hd) != 0:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"num = int(input())\\nnums = input()\\nstatement = [int(i) for i in nums.split()]\\n\\nlog = {}\\ngroup_num = {}\\nanchor = 1\\ntotal = num\\nstatus = 'Possible'\\nans = []\\nfor i, s in enumerate(statement):\\n    if s not in log or group_num[s] == 0:\\n        log[s] = anchor\\n        anchor += 1\\n        group_num[s] = num - s\\n        total -= group_num[s]\\n        if total < 0:\\n            status = 'Impossible'\\n            break\\n    ans.append(log[s])\\n    group_num[s] -= 1\\n\\nprint(status)\\nif status == 'Possible':\\n    for i in range(num - 1):\\n        print(ans[i], end=' ')\\n    print(ans[num - 1])\", \"n = int(input())\\naa = list(map(int, input().split()))\\n\\n\\ndef cal():\\n    ncol = [0] * (n + 1)\\n    ansmap = [0] * n\\n    ans = [0] * n\\n    colcnt = [0] * (n + 1)\\n    colmap = [0] * (n + 1)\\n    icol = 0\\n    for i, a in enumerate(aa):\\n        ncol[n - a] += 1\\n        ansmap[i] = n - a\\n\\n    for i, col in enumerate(ncol[1:], 1):\\n        if col % i:\\n            return\\n\\n    for i, col in enumerate(ansmap):\\n        if not colcnt[col] % col:\\n            icol += 1\\n            colmap[col] = icol\\n\\n        ans[i] = colmap[col]\\n        colcnt[col] += 1\\n\\n    return ans\\n\\n\\nans = cal()\\nif ans:\\n    print('Possible')\\n    print(' '.join(map(str, ans)))\\nelse:\\n    print('Impossible')\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nif 0 in a:\\n    if len(set(a)) > 1:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        print(*[1]*n)\\nelif not all(q < n for q in a):\\n    print('Impossible')\\nelse:\\n    s = {}\\n    answer = [0 for q in range(n)]\\n    for q in range(len(a)):\\n        if a[q] in s:\\n            s[a[q]].append(q)\\n        else:\\n            s[a[q]] = [q]\\n    q2 = 0\\n    for q in s:\\n        if len(s[q]) % (n-q) != 0:\\n            print('Impossible')\\n            break\\n        for q1 in range(len(s[q])):\\n            if q1 % (n-q) == 0:\\n                q2 += 1\\n            answer[s[q][q1]] = q2\\n    else:\\n        print('Possible')\\n        print(*answer)\\n\", \"n = int(input())\\na = [int(s) for s in input().split()]\\nb = [-1 for i in range(n)]\\nm = {}\\nnextnum = 1\\nfor i in range(n):\\n    # print(m)\\n    if b[i] == -1:\\n        if m.get(a[i]) and m[a[i]][1] > 0:\\n            b[i] = m[a[i]][0]\\n            m[a[i]][1] -= 1\\n            if m[a[i]][1] == 0:\\n                m.pop(a[i])\\n        else:\\n            z = n-a[i]-1\\n            b[i] = nextnum\\n            if z:\\n                m[a[i]] = [nextnum, z]\\n            nextnum += 1\\n\\nif m:\\n    print(\\\"Impossible\\\")\\nelse:\\n    print(\\\"Possible\\\")\\n    print(*b)\\n\", \"n = int(input())\\n\\ncl = list(map(int, input().split()))\\n\\npos = {}\\ncolor = 0\\nres = []\\n\\nfor x in cl:\\n  if x in pos.keys():\\n    if pos[x][0]!=0:\\n      res.append(pos[x][1])\\n      pos[x][0]-=1\\n    else:\\n      color+=1\\n      res.append(color)\\n      pos[x] = [n-x-1, color]\\n  else:\\n    color+=1\\n    res.append(color)\\n    pos.update({x:[n-x-1, color]})\\n\\nfor x in pos.keys():\\n  if pos[x][0]!=0:\\n    print(\\\"Impossible\\\")\\n    return\\n\\nprint(\\\"Possible\\\")\\nprint(*res)\", \"n=int(input())\\narr=list(map(int,input().split()))\\nansarr=[0]*n\\nflag=0\\ndict1={}\\ndict2={}\\nfor i in range(n):\\n    try:\\n        dict1[arr[i]].append(i)\\n    except:\\n        KeyError\\n        dict1[arr[i]]=[i]\\n        dict2[arr[i]]=0\\n\\ntempcount=0\\nfor i in dict1.keys():\\n    count=0\\n    while(dict2[i]<len(dict1[i])):\\n        if(dict2[i]+n-i>len(dict1[i])):\\n            flag=1\\n            break\\n        else:\\n            tempcount+=n-i\\n            dict2[i]+=n-i\\nif(tempcount!=n):\\n    flag=1\\nif(flag==1):\\n    print('Impossible')\\nelse:\\n    count=0\\n    val=1\\n    for i in dict1.keys():\\n        for j in range(0,len(dict1[i]),n-i):\\n            for k in range(n-int(i)):\\n                ansarr[dict1[i][j+k]]=val\\n            val+=1\\n    print('Possible')\\n    print(*ansarr)\", \"#!/usr/bin/env python3\\nimport sys\\ndef __starting_point():\\n    n = int(input())\\n    a = {}\\n    a_s = input().split()\\n    for i in range(n):\\n        x = n - int(a_s[i])\\n        a[x] = a.get(x, 0) + 1\\n        a_s[i] = x\\n    for i in a:\\n        if (i < 1) or (i > n):\\n            print(\\\"Impossible\\\")\\n            return\\n        if a[i] % i != 0:\\n            print(\\\"Impossible\\\")\\n            return\\n    print(\\\"Possible\\\")\\n    used = 0\\n    col = {}\\n    num = {}\\n    b = []\\n    for x in a_s:\\n        if x not in col or num[x] == x:\\n            used += 1\\n            col[x] = used\\n            num[x] = 1\\n            b.append(used)\\n        else:\\n            num[x] += 1\\n            b.append(col[x])\\n    print(\\\" \\\".join(map(str, b)))\\n\\n__starting_point()\", \"n = int(input())\\na = [int(element) for element in input().split(' ')]\\nb = dict()\\nfor i in range(n):\\n    try:\\n        b[a[i]] += 1\\n    except:\\n        b[a[i]] = 1\\nc = [(b[k] % (n-k)) == 0 for k in list(b.keys())]\\nd = [b[k] for k in a]\\n\\nif all(c):\\n    print(\\\"Possible\\\")\\n    types = dict()\\n    hat = 1\\n    for k in list(b.keys()):\\n        pergroup = n-k\\n        groups = b[k] // pergroup\\n        hatsgroup = list()\\n        for i in range(groups):\\n            for j in range(pergroup):\\n                hatsgroup.append(hat)\\n            hat += 1\\n        types[k] = hatsgroup\\n    hats = list()\\n    for i in range(n):\\n        hats.append(types[a[i]].pop())\\n    print(' '.join(str(e) for e in hats))\\n\\nelse:\\n    print(\\\"Impossible\\\")\\n\", \"import math\\n\\n\\ndef hats(n, arr):\\n    processed = [False] * n\\n    hats = [None] * n\\n    cur_hat = 0\\n    for i, diff_count in enumerate(arr):\\n        if processed[i]: continue\\n        cur_hat += 1\\n        hats[i] = cur_hat\\n        processed[i] = True\\n        same_count = n - diff_count - 1\\n        if not same_count: continue\\n        for j in range(i+1, n):\\n            if arr[j] == diff_count:\\n                same_count -= 1\\n                processed[j] = True\\n                hats[j] = cur_hat\\n            if not same_count:\\n                break\\n        if same_count:\\n            print('Impossible')\\n            return\\n    print('Possible')\\n    print(' '.join(list(map(str, hats))))\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    answers = list(map(int, input().strip().split()))\\n    hats(n, answers)\\n\\n__starting_point()\", \"n=int(input())\\na=list(map(int,input().split()))\\nd={}\\nl=[[] for i in range(n+1)]\\nfor i in range(n):\\n    d[a[i]]=d.get(a[i],0)+1\\n    l[n-a[i]].append(i+1)\\nb=list(d.keys())\\nc=[]\\nfor i in b:\\n    c.append([d[i]//(n-i),n-i])\\nk=0\\nfor i in c:\\n    k+=i[0]*i[1]\\nif k!=n:\\n    print('Impossible')\\nelse:\\n    print('Possible')\\n    co=1\\n    ans=[0]*(n+1)\\n    for i in c:\\n        for j in range(i[0]):\\n            for k in range(i[1]):\\n                x=l[i[1]].pop()\\n                ans[x]=co\\n            co+=1\\n    print(*ans[1:])\", \"n = int(input())\\nL = [n-int(x) for x in input().split()]\\nD = {}\\nfor i in L:\\n    if i in D:\\n        D[i] += 1\\n    else:\\n        D[i] = 1\\ns = 0\\ncheck = True\\nfor i in D.keys():\\n    if D[i]%i != 0:\\n        check = False\\n        break\\n    else:\\n        s += D[i]\\nif s != n:\\n    print('Impossible')\\n\\nelse:\\n    if check == False:\\n        print('Impossible')\\n    else:\\n        print('Possible')\\n        small = 1\\n        D2 = {}\\n        for i in D:\\n            D2[i] = list(range(small,small+(D[i]//i)))*i\\n            small += D[i]//i\\n        for i in L:\\n            print(D2[i][-1],end = ' ')\\n            D2[i].pop()\"]",
        "difficulty": "interview",
        "input": "2\n0 0\n",
        "output": "Possible\n1 1 ",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1081/B"
    },
    {
        "id": 1558,
        "task_id": 943,
        "test_case_id": 1,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "3\n1 2 3\n",
        "output": "6",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1559,
        "task_id": 943,
        "test_case_id": 2,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "5\n999999999 999999999 999999999 999999999 999999999\n",
        "output": "3999999996",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1560,
        "task_id": 943,
        "test_case_id": 3,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "1\n1\n",
        "output": "0",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1561,
        "task_id": 943,
        "test_case_id": 4,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "15\n39 52 88 78 46 95 84 98 55 3 68 42 6 18 98\n",
        "output": "870",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1562,
        "task_id": 943,
        "test_case_id": 5,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "15\n59 96 34 48 8 72 67 90 15 85 7 90 97 47 25\n",
        "output": "840",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1563,
        "task_id": 943,
        "test_case_id": 6,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "15\n87 37 91 29 58 45 51 74 70 71 47 38 91 89 44\n",
        "output": "922",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1564,
        "task_id": 943,
        "test_case_id": 7,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "15\n11 81 49 7 11 14 30 67 29 50 90 81 77 18 59\n",
        "output": "674",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1565,
        "task_id": 943,
        "test_case_id": 8,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "15\n39 21 95 89 73 90 9 55 85 32 30 21 68 59 82\n",
        "output": "848",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1566,
        "task_id": 943,
        "test_case_id": 9,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "15\n59 70 48 54 26 67 84 39 40 18 77 69 70 88 93\n",
        "output": "902",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1567,
        "task_id": 943,
        "test_case_id": 10,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "15\n87 22 98 32 88 36 72 31 100 97 17 16 60 22 20\n",
        "output": "798",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1568,
        "task_id": 943,
        "test_case_id": 11,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "15\n15 63 51 13 37 9 43 19 55 79 57 60 50 59 31\n",
        "output": "632",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1569,
        "task_id": 943,
        "test_case_id": 12,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "1\n4\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1570,
        "task_id": 943,
        "test_case_id": 13,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "2\n1 4\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1571,
        "task_id": 943,
        "test_case_id": 14,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "3\n1 2 4\n",
        "output": "6",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1572,
        "task_id": 943,
        "test_case_id": 15,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "2\n9 3\n",
        "output": "12",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1573,
        "task_id": 943,
        "test_case_id": 16,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "2\n1000000000 1001\n",
        "output": "1000000000",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1574,
        "task_id": 943,
        "test_case_id": 17,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "3\n1 8 4\n",
        "output": "12",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1575,
        "task_id": 943,
        "test_case_id": 18,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "3\n7 4 4\n",
        "output": "8",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1576,
        "task_id": 943,
        "test_case_id": 19,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "5\n2 3 4 5 3\n",
        "output": "14",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1577,
        "task_id": 943,
        "test_case_id": 20,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "2\n4 5\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1578,
        "task_id": 943,
        "test_case_id": 21,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "3\n2 4 5\n",
        "output": "6",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1579,
        "task_id": 943,
        "test_case_id": 22,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "3\n2 2 3\n",
        "output": "4",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1580,
        "task_id": 943,
        "test_case_id": 23,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "2\n2 3\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1581,
        "task_id": 943,
        "test_case_id": 24,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "4\n2 3 7 7\n",
        "output": "16",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1582,
        "task_id": 943,
        "test_case_id": 25,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "2\n999999999 2\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1583,
        "task_id": 943,
        "test_case_id": 26,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "2\n2 5\n",
        "output": "2",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1584,
        "task_id": 943,
        "test_case_id": 27,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "3\n5 3 1\n",
        "output": "8",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1585,
        "task_id": 943,
        "test_case_id": 28,
        "question": "Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. \n\nNote, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.\n\n\n-----Input-----\n\nThe first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 10^9, inclusive. \n\n\n-----Output-----\n\nPrint the maximum possible even sum that can be obtained if we use some of the given integers. \n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n6\nInput\n5\n999999999 999999999 999999999 999999999 999999999\n\nOutput\n3999999996\n\n\n-----Note-----\n\nIn the first sample, we can simply take all three integers for a total sum of 6.\n\nIn the second sample Wet Shark should take any four out of five integers 999 999 999.",
        "solutions": "[\"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    cnt = 0\\n    mi = 10 ** 9\\n    for i in a:\\n        if i % 2 == 1:\\n            cnt ^= 1\\n            mi = min(mi, i)\\n    \\n    if not cnt:\\n        mi = 0\\n    print(sum(a) - mi)\\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\ns = sum(a)\\nif (s % 2 == 0):\\n    print(s)\\nelse:\\n    cmin = 10**9 + 1;\\n    for c in a:\\n        if c % 2 == 1 and c < cmin:\\n            cmin = c\\n    s -= cmin\\n    print(s)\\n\", \"n=int(input())\\na=sorted(list(map(int,input().split())))[::-1]\\nt = r = 0\\nfor x in a:\\n\\tif x % 2:\\n\\t\\tif t:\\n\\t\\t\\tr += t + x\\n\\t\\t\\tt = 0\\n\\t\\telse:\\n\\t\\t\\tt = x\\n\\telse:\\n\\t\\tr += x\\nprint(r)\", \"n = int(input())\\na = list(map(int, input().split()))\\nsum = 0\\np = []\\nfor i in range(n):\\n    if a[i] % 2 == 0:\\n        sum += a[i]\\n    else:\\n        p.append(a[i])\\np.sort()\\nif len(p) % 2 != 0:\\n    p.pop(0)\\nfor t in range(len(p)):\\n    sum += p[t]\\nprint(sum)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nodd = []\\nnodd = []\\nfor i in l:\\n    if i % 2 == 1:\\n        odd.append(i)\\n    else:\\n        nodd.append(i)\\nodd.sort()\\nprint(sum(nodd) + sum(odd[len(odd) % 2:]))\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nans = sum(a)\\nif ans % 2:\\n    Min = 10 ** 10\\n    for i in range(n):\\n        if a[i] % 2 and a[i] < Min:\\n            Min = a[i]\\n    if Min < 10 ** 10: ans -= Min\\n    else: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\n\\narr = list(map(int,input().split()))\\n\\narr =sorted(arr)\\n\\ns = sum(arr)\\n\\nif s % 2 == 0:\\n    print(s)\\nelse:\\n    c = -1\\n    for v in arr:\\n        if v % 2 == 1:\\n            c = v\\n            break\\n    if c == -1:\\n        print(0)\\n    else:\\n        print(s - c)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmn = 1000000000000000000000001\\nif sum(a) % 2 == 0:\\n    print(sum(a))\\nelse:\\n    for i in range(n):\\n        if a[i] % 2 == 1:\\n            mn = min(mn, a[i])\\n    print(sum(a)-mn)\", \"N = int(input())\\na = list(map(int, input().split()))\\nk = 0\\nmin_nechet = 10 ** 10\\nfor i in a:\\n    if i % 2 == 1:\\n        k += 1\\n        min_nechet = min(min_nechet, i)\\nif k % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - min_nechet)\", \"n = int(input())\\nlst = list(map(int, input().split()))\\ns = 0\\ncnt = 0\\nlst.sort()\\nfor i in lst:\\n    if i % 2 == 0:\\n        s += i\\n    else:\\n        s += i\\n        cnt += 1\\n        \\nif cnt % 2 == 0:\\n    print(s)\\nelse:\\n    for i in range(n):\\n        if lst[i] % 2 == 1:\\n            s -= lst[i]\\n            break\\n    print(s)    \\n\", \"n = int(input())\\nN = [int(x) for x in input().split()]\\nS = sum(N)\\nodd = [x for x in N if x%2 == 1]\\nx = min(odd) if len(odd) > 0 else 0\\nprint(S - x if S%2 else S)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\ns=sorted([x for x in l if x%2>0])\\nt=sum(l)\\nif t%2: t-=s[0]\\nprint(t)\", \"n = int(input())\\n\\na = [int(s) for s in input().split()]\\n\\na.sort()\\nsum = 0\\nfor i in range(n):\\n    sum += a[i]\\nans = sum\\ni = 0\\nwhile ans % 2 == 1:\\n    ans = sum - a[i]\\n    i += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nevens = list()\\nodds = list()\\n\\nfor x in a:\\n    if x % 2 == 0:\\n        evens.append(x)\\n    else:\\n        odds.append(x)\\n\\nret = sum(evens)\\n\\nodds.sort()\\n\\ni = len(odds)-1\\n\\nwhile i-1 >= 0:\\n    ret += odds[i] + odds[i-1]\\n    i -= 2\\n\\nprint(ret)\\n\", \"n, a = int(input()), list(map(int, input().split()))\\no = [x for x in a if x % 2]\\nprint(sum(a) - (min(o) if len(o) % 2 else 0))\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nif not sum(a) % 2:\\n    print(sum(a))\\n    return\\na.sort()\\nans = 0\\nflag = True\\nfor i in range(n):\\n    if (flag and (not (a[i] % 2))) or (not flag):\\n        ans += a[i]\\n    else:\\n        flag = False\\nprint(ans)\\n\\n\", \"n = int(input())\\nl = map(int, input().split())\\nl = sorted(l)\\ns = sum(l)\\n\\nif (s % 2) == 1:\\n\\tfor i in l:\\n\\t\\tif (i % 2) == 1:\\n\\t\\t\\ts -= i\\n\\t\\t\\tbreak\\nprint(s)\", \"#author=\\\"_rabbit\\\"\\nn=(int)(input())\\na=list(map(int,input().split()))\\nsum=0\\nfor i in a:\\n    sum+=int(i)\\nif(sum%2==0):\\n    print(sum)\\nelse:\\n    minn=int(1000000000000000)\\n    for i in a:\\n        if(i%2):\\n            minn=min(minn,i)\\n    sum=sum-minn\\n    print(sum)\\n    \\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nsumm = 0\\ncount = 0\\nminn = 10000000000000\\nfor i in range(n):\\n    if a[i] % 2 == 1:\\n        minn = min(minn, a[i])\\n        count += 1\\nif count % 2 == 0:\\n    print(sum(a))\\nelse:\\n    print(sum(a) - minn)\", \"n = int(input())\\n\\nodd = 0\\nlowest_odd = None\\ns = 0\\nfor num in map(int, input().split()):\\n    s += num\\n    if num % 2 == 1:\\n        odd += 1\\n        if lowest_odd is None or num < lowest_odd:\\n            lowest_odd = num\\n\\nif odd % 2 == 1:\\n    print(s-lowest_odd)\\nelse:\\n    print(s)\", \"def __starting_point():\\n\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n\\n    the_sum = sum(a)\\n\\n    if the_sum % 2 == 0:\\n        print(the_sum)\\n    else:\\n        max_num = max(a)\\n        min_odd = max_num + 1\\n        for aa in a:\\n            if aa%2 == 1 and aa < min_odd:\\n                min_odd = aa\\n\\n        if min_odd == max_num + 1:\\n            print(0)\\n        else:\\n            print( the_sum -  min_odd )\\n\\n__starting_point()\", \"input()\\nar = list(map(int, input().split()))\\n\\na = []\\nb = []\\nfor t in ar:\\n    if t % 2 == 0:\\n        a.append(t)\\n    else:\\n        b.append(t)\\n\\nb.sort()\\nif len(b) % 2 != 0:\\n    b = b[1:]\\n\\nprint(sum(a) + sum(b))\"]",
        "difficulty": "interview",
        "input": "4\n3 2 5 7\n",
        "output": "14",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/621/A"
    },
    {
        "id": 1586,
        "task_id": 1010,
        "test_case_id": 12,
        "question": "Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces.\n\nYou are asked to calculate the number of ways he can do it. Two ways to break chocolate are considered distinct if one of them contains a break between some two adjacent pieces and the other one doesn't. \n\nPlease note, that if Bob doesn't make any breaks, all the bar will form one piece and it still has to have exactly one nut.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 100) — the number of pieces in the chocolate bar.\n\nThe second line contains n integers a_{i} (0 ≤ a_{i} ≤ 1), where 0 represents a piece without the nut and 1 stands for a piece with the nut.\n\n\n-----Output-----\n\nPrint the number of ways to break the chocolate into multiple parts so that each part would contain exactly one nut.\n\n\n-----Examples-----\nInput\n3\n0 1 0\n\nOutput\n1\n\nInput\n5\n1 0 1 0 1\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample there is exactly one nut, so the number of ways equals 1 — Bob shouldn't make any breaks.\n\nIn the second sample you can break the bar in four ways:\n\n10|10|1\n\n1|010|1\n\n10|1|01\n\n1|01|01",
        "solutions": "[\"x = int(input())\\ny = list(map(int, input().split(' ')))\\nif y == [0] * x:\\n    print(0)\\n    quit()\\nfor i in range(x):\\n    if y[i] == 1:\\n        y = y[i:]\\n        break\\n\\ny.reverse()\\nfor i in range(len(y)):\\n    if y[i] == 1:\\n        y = y[i:]\\n        break\\n\\ny.reverse()\\n\\nl = []\\nct = 0\\nfor i in y:\\n    if i == 0:\\n        ct+=1\\n    if i == 1 and ct != 0:\\n        l.append(ct)\\n        ct = 0\\n\\nk = 1\\nfor i in l:\\n    k *= (i+1)\\n\\nprint(k)\\n\", \"N = int(input())\\nA = ''.join(input().split())\\n\\nA = A.split('1')\\nif len(A) == 1:\\n    print(0)\\n    return\\nA = A[1:-1]\\nanswer = 1\\nfor x in A:\\n    answer *= len(x) + 1\\n\\nprint(answer)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = 1\\ncnt = 1\\nstart = False\\nfor i in l:\\n    if i == 1:\\n        start = True\\n        ans *= cnt\\n        cnt = 1\\n    if i == 0 and start:\\n        cnt += 1\\nif l.count(1) == 0:\\n    print(0)\\nelse:\\n    print(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 1\\ni = 0\\nwhile i < n and a[i] != 1:\\n    i += 1\\nif i == n:\\n    ans = 0\\ncur = 1\\nfor j in range(i + 1, n):\\n    if a[j] == 1:\\n        ans *= cur\\n        cur = 1\\n    else:\\n        cur += 1\\nprint(ans)\", \"N = int(input())\\nchoco = [int(x) for x in input().split()]\\nif all(c == 0 for c in choco):\\n    print(0)\\n    return\\nans = 1\\ni = 0\\nwhile choco[i] == 0:\\n    i += 1\\n\\nwhile True:\\n    assert(choco[i] == 1)\\n    j = i+1\\n    while j < N and choco[j] == 0:\\n        j += 1\\n    if j == N:\\n        break\\n    else:\\n        ans *= j - i\\n    i = j\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = -1\\nfor i in a:\\n    if i == 1:\\n        if cur != -1: b.append(cur)\\n        cur = 0\\n    elif cur != -1:\\n        cur += 1\\nans = 1\\nfor i in b:\\n    ans *= (i + 1)\\nif cur == -1: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\nisnut = [(int(x) == 1) for x in input().split()]\\nans = 1\\nstack = 1\\nhasnut = False\\nfor nut in isnut:\\n    if nut:\\n        if hasnut:\\n            ans *= stack\\n            stack = 1\\n        else:\\n            hasnut = True\\n            stack = 1\\n    else:\\n        stack += 1\\nprint(ans if hasnut else 0)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = list([0 for i in range(n)])\\nj = 0\\nfor i in range(n):\\n\\tif a[i] == 1:\\n\\t\\tl[j] = i\\n\\t\\tj += 1\\nans = 1\\nif j == 0:\\n\\tprint(0)\\n\\treturn\\nfor i in range(j):\\n\\tif i == 0:    \\n\\t\\tcontinue\\n\\tans *= l[i] - l[i - 1]\\n\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nlast = -1\\nans = 1\\nfor i in range(n):\\n    if a[i] == 1:\\n        if last != -1:\\n            ans *= i - last\\n        last = i\\n\\nprint(ans if last != -1 else 0)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nans = 1\\np = -1\\nfor i in range(len(l)):\\n\\tif l[i] == 1:\\n\\t\\tif p == -1:\\n\\t\\t\\tp = i\\n\\t\\t\\tcontinue\\n\\t\\tif i-p:\\n\\t\\t\\tans *= i-p\\n\\t\\tp = i\\nif p != -1:\\n\\tprint(ans)\\nelse:\\n\\tprint(0)\\n\", \"n = int(input())\\nnuts = list(map(int, input().split()))\\nlabel = 0\\nif nuts.count(1):\\n    ans = 1\\nelse:\\n    ans = 0\\n    \\nfor i in nuts:\\n    if i == 1:\\n        if label:\\n            ans *= cnt\\n        label = 1\\n        cnt = 0\\n    if label:\\n        cnt += 1\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom itertools import dropwhile\\n\\ndef main():\\n    n = int(input())\\n    lst = [bool(int(x)) for x in input().split()]\\n    lst = list(dropwhile(lambda x: not x, lst))\\n\\n    if not lst:\\n        print(0)\\n        return\\n\\n    ans = 1\\n    cnt = 1\\n\\n    for x in lst:\\n        if x:\\n            if cnt > 1:\\n                ans *= cnt\\n                cnt = 1\\n        else:\\n            cnt += 1\\n\\n    print(ans)\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ndata = [int(i) for i in input().split()]\\nbox = []\\nl = 0\\nfor i in range(n):\\n    if data[i] == 1:\\n        box.append(i)\\n        l += 1\\nif l:\\n    ret = 1\\n    for i in range(l - 1, 0, -1):\\n        ret *= box[i] - box[i - 1]\\n    print(ret)\\nelse:\\n    print(0)\", \"n, a, v = int(input()), list(map(int, input().split())), 1\\np = [i for i, ai in enumerate(a) if ai]\\nfor i in range(1, len(p)):\\n    v *= p[i] - p[i - 1]\\nprint(v if p else 0)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport time\\n\\n#   = input()\\nn   = int(input())\\na   = [int(i) for i in input().split()]\\n\\nstart = time.time()\\n\\ns = sum(a)\\nif s == 0:\\n    ans = 0\\nelif s == 1:\\n    ans = 1\\nelse:\\n    ans = 1\\n\\n    l = 0\\n    while( a[l] != 1):\\n        l += 1\\n\\n    r = l\\n\\n    while(r < n-1):\\n        r += 1\\n        if a[r] == 1:\\n            ans *= (r-l)\\n            l = r\\n\\nprint(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\", \"#!/usr/bin/env python3\\n\\ninput()\\npieces = list(map(int, input().split()))\\nN = len(pieces)\\n\\noneIndexes = [i for i, e in enumerate(pieces) if e == 1]\\n\\nif len(oneIndexes) == 0:\\n\\tprint(0)\\nelse:\\n\\n\\tans = 1\\n\\tfor i in range(len(oneIndexes) - 1):\\n\\t\\tans *= (oneIndexes[i+1] - oneIndexes[i])\\n\\n\\tprint(ans)\", \"n = int(input())\\nm = 0\\na = 1\\np = 0\\nl = list(map(int,input().split()))\\nfor i in range(n):\\n    if l[i] == 1:\\n        m += 1    \\n        if m > 0:\\n            if m > 1:\\n                a *= i - p\\n            p = i\\nprint(a if m > 0 else 0)\\n\", \"n = int(input())\\nl = input().split(\\\" \\\")\\nfirst = 0\\nwhile first <= n-1 and l[first] == \\\"0\\\":\\n    first += 1\\nif first == n:\\n    print(0)\\nelse:\\n    last = n-1\\n    while last >= 0 and l[last] == \\\"0\\\":\\n        last -= 1\\n    count = 0\\n    divide = []\\n    for i in range(first, last+1):\\n        if(l[i] == \\\"0\\\"):\\n            count += 1\\n        else:\\n            divide.append(count+1)\\n            count = 0\\n    ans = 1\\n    for i in range(len(divide)):\\n        ans *= divide[i]\\n    print(ans)\\n\", \"n = int(input())\\nlst = list(map(int, input().split()))\\nans = 1\\ncnt = 0\\nif 1 in lst:\\n    p = lst.index(1)\\n    for i in range(p, n):\\n        if lst[i] == 1:\\n            if cnt != 0:\\n                ans *= cnt\\n                cnt = 0\\n        cnt += 1\\n    print(ans)\\nelse:\\n    print(0)\\n\", \"def solve( n , nuts ):\\n\\n    try:\\n        i = nuts.index(\\\"1\\\")\\n    except:\\n        return 0\\n\\n    ri = nuts.rindex(\\\"1\\\")\\n\\n    if i == ri:\\n        return 1\\n\\n    res = 1\\n    start = i\\n    cur = start + 1\\n    while cur <= ri:\\n        if nuts[cur] == \\\"1\\\":\\n            res *= (cur-start)\\n            start = cur\\n            cur = start + 1\\n        else:\\n            cur += 1\\n    return res\\n\\n\\ndef __starting_point():\\n\\n    n = int(input())\\n    nuts = \\\"\\\".join(input().split())\\n    print( solve( n , nuts ) )\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\na = list(tuple(map(int, input().split())))\\n\\nwhile len(a) > 0 and a[0] == 0:\\n\\ta.pop(0)\\nwhile len(a) > 0 and a[-1] == 0:\\n\\ta.pop()\\n\\nif len(a) == 0:\\n\\tprint(\\\"0\\\")\\nelse:\\n\\tres = 1\\n\\tnum = 1\\n\\n\\tfor i in a:\\n\\t\\tif i == 0:\\n\\t\\t\\tnum += 1\\n\\t\\tif i == 1:\\n\\t\\t\\tres *= num\\n\\t\\t\\tnum = 1\\n\\n\\tprint(str(res))\\n\", \"#author=\\\"_rabbit\\\"\\nn=int(input())\\na=list(map(int,input().split()))\\nb=[]\\nfor i in range(n):\\n    if a[i]==1:\\n        b.append(i)\\n#print(b)\\nif(len(b)==0):\\n    print(\\\"0\\\")\\nelse:\\n    ans=int(1)\\n    for i in range(len(b)-1):\\n        ans=ans*(b[i+1]-b[i])\\n    print(ans)\\n\", \"n = int(input())\\nnuts = list(map(str, input().split()))\\nans = 1\\ncur = 1\\nisone = False\\nfor i in range(n):\\n    if nuts[i] == '1':\\n        isone = True\\n        ans *= cur\\n        cur = 1\\n    else:\\n        if isone:\\n            cur += 1\\nif isone:\\n    print(ans)\\nelse:\\n    print(0)\\n    \\n    \\n\", \"n = int(input())\\na = [int(s) for s in input().split()]\\n\\nb = [0]*n\\nnb = 0\\n\\nk = 0\\nwhile k < n and a[k] < 1:\\n    k += 1\\n    \\nif k > n - 1:\\n    print(0)\\nelse:\\n    q = 1\\n    for i in range (k + 1, n):\\n        if a[i] == 1:\\n            nb += 1\\n            q += 1\\n        else:\\n            b[nb] += 1\\n    sum = 1\\n    for i in range (q - 1):\\n        sum *= (b[i] +1)\\n\\n    print(sum)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nif max(a) == 0:\\n\\tprint(0)\\n\\treturn\\nans = 1\\nstarted = False\\ncount = 1\\nfor i in range(n):\\n\\tif a[i] == 1 and not started:\\n\\t\\tstarted = True\\n\\t\\tcontinue\\n\\tif started and a[i] == 0:\\n\\t\\tcount +=1\\n\\tif started and a[i] == 1:\\n\\t\\tans *= count\\n\\t\\tcount = 1\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "18\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/617/B"
    },
    {
        "id": 1587,
        "task_id": 1010,
        "test_case_id": 13,
        "question": "Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces.\n\nYou are asked to calculate the number of ways he can do it. Two ways to break chocolate are considered distinct if one of them contains a break between some two adjacent pieces and the other one doesn't. \n\nPlease note, that if Bob doesn't make any breaks, all the bar will form one piece and it still has to have exactly one nut.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 100) — the number of pieces in the chocolate bar.\n\nThe second line contains n integers a_{i} (0 ≤ a_{i} ≤ 1), where 0 represents a piece without the nut and 1 stands for a piece with the nut.\n\n\n-----Output-----\n\nPrint the number of ways to break the chocolate into multiple parts so that each part would contain exactly one nut.\n\n\n-----Examples-----\nInput\n3\n0 1 0\n\nOutput\n1\n\nInput\n5\n1 0 1 0 1\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample there is exactly one nut, so the number of ways equals 1 — Bob shouldn't make any breaks.\n\nIn the second sample you can break the bar in four ways:\n\n10|10|1\n\n1|010|1\n\n10|1|01\n\n1|01|01",
        "solutions": "[\"x = int(input())\\ny = list(map(int, input().split(' ')))\\nif y == [0] * x:\\n    print(0)\\n    quit()\\nfor i in range(x):\\n    if y[i] == 1:\\n        y = y[i:]\\n        break\\n\\ny.reverse()\\nfor i in range(len(y)):\\n    if y[i] == 1:\\n        y = y[i:]\\n        break\\n\\ny.reverse()\\n\\nl = []\\nct = 0\\nfor i in y:\\n    if i == 0:\\n        ct+=1\\n    if i == 1 and ct != 0:\\n        l.append(ct)\\n        ct = 0\\n\\nk = 1\\nfor i in l:\\n    k *= (i+1)\\n\\nprint(k)\\n\", \"N = int(input())\\nA = ''.join(input().split())\\n\\nA = A.split('1')\\nif len(A) == 1:\\n    print(0)\\n    return\\nA = A[1:-1]\\nanswer = 1\\nfor x in A:\\n    answer *= len(x) + 1\\n\\nprint(answer)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\nans = 1\\ncnt = 1\\nstart = False\\nfor i in l:\\n    if i == 1:\\n        start = True\\n        ans *= cnt\\n        cnt = 1\\n    if i == 0 and start:\\n        cnt += 1\\nif l.count(1) == 0:\\n    print(0)\\nelse:\\n    print(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 1\\ni = 0\\nwhile i < n and a[i] != 1:\\n    i += 1\\nif i == n:\\n    ans = 0\\ncur = 1\\nfor j in range(i + 1, n):\\n    if a[j] == 1:\\n        ans *= cur\\n        cur = 1\\n    else:\\n        cur += 1\\nprint(ans)\", \"N = int(input())\\nchoco = [int(x) for x in input().split()]\\nif all(c == 0 for c in choco):\\n    print(0)\\n    return\\nans = 1\\ni = 0\\nwhile choco[i] == 0:\\n    i += 1\\n\\nwhile True:\\n    assert(choco[i] == 1)\\n    j = i+1\\n    while j < N and choco[j] == 0:\\n        j += 1\\n    if j == N:\\n        break\\n    else:\\n        ans *= j - i\\n    i = j\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = []\\ncur = -1\\nfor i in a:\\n    if i == 1:\\n        if cur != -1: b.append(cur)\\n        cur = 0\\n    elif cur != -1:\\n        cur += 1\\nans = 1\\nfor i in b:\\n    ans *= (i + 1)\\nif cur == -1: ans = 0\\nprint(ans)\\n\", \"n = int(input())\\nisnut = [(int(x) == 1) for x in input().split()]\\nans = 1\\nstack = 1\\nhasnut = False\\nfor nut in isnut:\\n    if nut:\\n        if hasnut:\\n            ans *= stack\\n            stack = 1\\n        else:\\n            hasnut = True\\n            stack = 1\\n    else:\\n        stack += 1\\nprint(ans if hasnut else 0)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = list([0 for i in range(n)])\\nj = 0\\nfor i in range(n):\\n\\tif a[i] == 1:\\n\\t\\tl[j] = i\\n\\t\\tj += 1\\nans = 1\\nif j == 0:\\n\\tprint(0)\\n\\treturn\\nfor i in range(j):\\n\\tif i == 0:    \\n\\t\\tcontinue\\n\\tans *= l[i] - l[i - 1]\\n\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nlast = -1\\nans = 1\\nfor i in range(n):\\n    if a[i] == 1:\\n        if last != -1:\\n            ans *= i - last\\n        last = i\\n\\nprint(ans if last != -1 else 0)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nans = 1\\np = -1\\nfor i in range(len(l)):\\n\\tif l[i] == 1:\\n\\t\\tif p == -1:\\n\\t\\t\\tp = i\\n\\t\\t\\tcontinue\\n\\t\\tif i-p:\\n\\t\\t\\tans *= i-p\\n\\t\\tp = i\\nif p != -1:\\n\\tprint(ans)\\nelse:\\n\\tprint(0)\\n\", \"n = int(input())\\nnuts = list(map(int, input().split()))\\nlabel = 0\\nif nuts.count(1):\\n    ans = 1\\nelse:\\n    ans = 0\\n    \\nfor i in nuts:\\n    if i == 1:\\n        if label:\\n            ans *= cnt\\n        label = 1\\n        cnt = 0\\n    if label:\\n        cnt += 1\\nprint(ans)\", \"#!/usr/bin/env python3\\nfrom itertools import dropwhile\\n\\ndef main():\\n    n = int(input())\\n    lst = [bool(int(x)) for x in input().split()]\\n    lst = list(dropwhile(lambda x: not x, lst))\\n\\n    if not lst:\\n        print(0)\\n        return\\n\\n    ans = 1\\n    cnt = 1\\n\\n    for x in lst:\\n        if x:\\n            if cnt > 1:\\n                ans *= cnt\\n                cnt = 1\\n        else:\\n            cnt += 1\\n\\n    print(ans)\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ndata = [int(i) for i in input().split()]\\nbox = []\\nl = 0\\nfor i in range(n):\\n    if data[i] == 1:\\n        box.append(i)\\n        l += 1\\nif l:\\n    ret = 1\\n    for i in range(l - 1, 0, -1):\\n        ret *= box[i] - box[i - 1]\\n    print(ret)\\nelse:\\n    print(0)\", \"n, a, v = int(input()), list(map(int, input().split())), 1\\np = [i for i, ai in enumerate(a) if ai]\\nfor i in range(1, len(p)):\\n    v *= p[i] - p[i - 1]\\nprint(v if p else 0)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n\\nimport time\\n\\n#   = input()\\nn   = int(input())\\na   = [int(i) for i in input().split()]\\n\\nstart = time.time()\\n\\ns = sum(a)\\nif s == 0:\\n    ans = 0\\nelif s == 1:\\n    ans = 1\\nelse:\\n    ans = 1\\n\\n    l = 0\\n    while( a[l] != 1):\\n        l += 1\\n\\n    r = l\\n\\n    while(r < n-1):\\n        r += 1\\n        if a[r] == 1:\\n            ans *= (r-l)\\n            l = r\\n\\nprint(ans)\\nfinish = time.time()\\n#print(finish - start)\\n\", \"#!/usr/bin/env python3\\n\\ninput()\\npieces = list(map(int, input().split()))\\nN = len(pieces)\\n\\noneIndexes = [i for i, e in enumerate(pieces) if e == 1]\\n\\nif len(oneIndexes) == 0:\\n\\tprint(0)\\nelse:\\n\\n\\tans = 1\\n\\tfor i in range(len(oneIndexes) - 1):\\n\\t\\tans *= (oneIndexes[i+1] - oneIndexes[i])\\n\\n\\tprint(ans)\", \"n = int(input())\\nm = 0\\na = 1\\np = 0\\nl = list(map(int,input().split()))\\nfor i in range(n):\\n    if l[i] == 1:\\n        m += 1    \\n        if m > 0:\\n            if m > 1:\\n                a *= i - p\\n            p = i\\nprint(a if m > 0 else 0)\\n\", \"n = int(input())\\nl = input().split(\\\" \\\")\\nfirst = 0\\nwhile first <= n-1 and l[first] == \\\"0\\\":\\n    first += 1\\nif first == n:\\n    print(0)\\nelse:\\n    last = n-1\\n    while last >= 0 and l[last] == \\\"0\\\":\\n        last -= 1\\n    count = 0\\n    divide = []\\n    for i in range(first, last+1):\\n        if(l[i] == \\\"0\\\"):\\n            count += 1\\n        else:\\n            divide.append(count+1)\\n            count = 0\\n    ans = 1\\n    for i in range(len(divide)):\\n        ans *= divide[i]\\n    print(ans)\\n\", \"n = int(input())\\nlst = list(map(int, input().split()))\\nans = 1\\ncnt = 0\\nif 1 in lst:\\n    p = lst.index(1)\\n    for i in range(p, n):\\n        if lst[i] == 1:\\n            if cnt != 0:\\n                ans *= cnt\\n                cnt = 0\\n        cnt += 1\\n    print(ans)\\nelse:\\n    print(0)\\n\", \"def solve( n , nuts ):\\n\\n    try:\\n        i = nuts.index(\\\"1\\\")\\n    except:\\n        return 0\\n\\n    ri = nuts.rindex(\\\"1\\\")\\n\\n    if i == ri:\\n        return 1\\n\\n    res = 1\\n    start = i\\n    cur = start + 1\\n    while cur <= ri:\\n        if nuts[cur] == \\\"1\\\":\\n            res *= (cur-start)\\n            start = cur\\n            cur = start + 1\\n        else:\\n            cur += 1\\n    return res\\n\\n\\ndef __starting_point():\\n\\n    n = int(input())\\n    nuts = \\\"\\\".join(input().split())\\n    print( solve( n , nuts ) )\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\na = list(tuple(map(int, input().split())))\\n\\nwhile len(a) > 0 and a[0] == 0:\\n\\ta.pop(0)\\nwhile len(a) > 0 and a[-1] == 0:\\n\\ta.pop()\\n\\nif len(a) == 0:\\n\\tprint(\\\"0\\\")\\nelse:\\n\\tres = 1\\n\\tnum = 1\\n\\n\\tfor i in a:\\n\\t\\tif i == 0:\\n\\t\\t\\tnum += 1\\n\\t\\tif i == 1:\\n\\t\\t\\tres *= num\\n\\t\\t\\tnum = 1\\n\\n\\tprint(str(res))\\n\", \"#author=\\\"_rabbit\\\"\\nn=int(input())\\na=list(map(int,input().split()))\\nb=[]\\nfor i in range(n):\\n    if a[i]==1:\\n        b.append(i)\\n#print(b)\\nif(len(b)==0):\\n    print(\\\"0\\\")\\nelse:\\n    ans=int(1)\\n    for i in range(len(b)-1):\\n        ans=ans*(b[i+1]-b[i])\\n    print(ans)\\n\", \"n = int(input())\\nnuts = list(map(str, input().split()))\\nans = 1\\ncur = 1\\nisone = False\\nfor i in range(n):\\n    if nuts[i] == '1':\\n        isone = True\\n        ans *= cur\\n        cur = 1\\n    else:\\n        if isone:\\n            cur += 1\\nif isone:\\n    print(ans)\\nelse:\\n    print(0)\\n    \\n    \\n\", \"n = int(input())\\na = [int(s) for s in input().split()]\\n\\nb = [0]*n\\nnb = 0\\n\\nk = 0\\nwhile k < n and a[k] < 1:\\n    k += 1\\n    \\nif k > n - 1:\\n    print(0)\\nelse:\\n    q = 1\\n    for i in range (k + 1, n):\\n        if a[i] == 1:\\n            nb += 1\\n            q += 1\\n        else:\\n            b[nb] += 1\\n    sum = 1\\n    for i in range (q - 1):\\n        sum *= (b[i] +1)\\n\\n    print(sum)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nif max(a) == 0:\\n\\tprint(0)\\n\\treturn\\nans = 1\\nstarted = False\\ncount = 1\\nfor i in range(n):\\n\\tif a[i] == 1 and not started:\\n\\t\\tstarted = True\\n\\t\\tcontinue\\n\\tif started and a[i] == 0:\\n\\t\\tcount +=1\\n\\tif started and a[i] == 1:\\n\\t\\tans *= count\\n\\t\\tcount = 1\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/617/B"
    },
    {
        "id": 1588,
        "task_id": 1081,
        "test_case_id": 1,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "5\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1589,
        "task_id": 1081,
        "test_case_id": 2,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "13\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1590,
        "task_id": 1081,
        "test_case_id": 3,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "24\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1591,
        "task_id": 1081,
        "test_case_id": 4,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "46\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1592,
        "task_id": 1081,
        "test_case_id": 5,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "1\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1593,
        "task_id": 1081,
        "test_case_id": 6,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "2\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1594,
        "task_id": 1081,
        "test_case_id": 7,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "3\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1595,
        "task_id": 1081,
        "test_case_id": 8,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "4\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1596,
        "task_id": 1081,
        "test_case_id": 9,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "10\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1597,
        "task_id": 1081,
        "test_case_id": 10,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "11\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1598,
        "task_id": 1081,
        "test_case_id": 11,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "12\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1599,
        "task_id": 1081,
        "test_case_id": 12,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "16\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1600,
        "task_id": 1081,
        "test_case_id": 13,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "20\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1601,
        "task_id": 1081,
        "test_case_id": 14,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "28\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1602,
        "task_id": 1081,
        "test_case_id": 15,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "30\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1603,
        "task_id": 1081,
        "test_case_id": 16,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "35\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1604,
        "task_id": 1081,
        "test_case_id": 17,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "37\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1605,
        "task_id": 1081,
        "test_case_id": 18,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "41\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1606,
        "task_id": 1081,
        "test_case_id": 19,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "43\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1607,
        "task_id": 1081,
        "test_case_id": 20,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "49\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1608,
        "task_id": 1081,
        "test_case_id": 21,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "52\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1609,
        "task_id": 1081,
        "test_case_id": 22,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "64\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1610,
        "task_id": 1081,
        "test_case_id": 23,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "75\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1611,
        "task_id": 1081,
        "test_case_id": 24,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "86\n",
        "output": "YES\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1612,
        "task_id": 1081,
        "test_case_id": 25,
        "question": "-----Input-----\n\nThe input contains a single integer $a$ ($1 \\le a \\le 99$).\n\n\n-----Output-----\n\nOutput \"YES\" or \"NO\".\n\n\n-----Examples-----\nInput\n5\n\nOutput\nYES\n\nInput\n13\n\nOutput\nNO\n\nInput\n24\n\nOutput\nNO\n\nInput\n46\n\nOutput\nYES",
        "solutions": "[\"n = int(input())\\ns = {1, 7, 9, 10, 11}\\nif n < 12:\\n\\tif n in s:\\n\\t\\tprint(\\\"NO\\\")\\n\\telse:\\n\\t\\tprint(\\\"YES\\\")\\nelif 12 < n < 30:\\n\\tprint(\\\"NO\\\")\\nelif 69 < n < 80:\\n\\tprint(\\\"NO\\\")\\nelif 89 < n:\\n\\tprint(\\\"NO\\\")\\nelse:\\n\\tif n % 10 not in {1, 7, 9}:\\n\\t\\tprint(\\\"YES\\\")\\n\\telse: print(\\\"NO\\\")\", \"import math\\n\\nk = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']\\nn = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']\\n\\na = int(input())\\nif a < 20:\\n    a = k[a]\\nelse:\\n    a = n[a // 10]+k[a % 10]\\nb = 'k' in a or 'a' in a or 'n' in a\\nprint('NO' if b else 'YES')\", \"s = [ 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\nn = int(input())\\nif n in s:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"s = '''\\n0\\tzero\\t(4)\\t\\n1\\tone\\t(3)\\t\\n2\\ttwo\\t(3)\\t\\n3\\tthree\\t(5)\\t\\n4\\tfour\\t(4)\\t\\n5\\tfive\\t(4)\\t\\n6\\tsix\\t(3)\\t\\n7\\tseven\\t(5)\\t\\n8\\teight\\t(5)\\t\\n9\\tnine\\t(4)\\t\\t\\n10\\tten\\t(3)\\t\\n11\\televen\\t(6)\\t\\n12\\ttwelve\\t(6)\\t\\n13\\tthirteen\\t(8)\\t\\n14\\tfourteen\\t(8)\\t\\n15\\tfifteen\\t(7)\\t\\n16\\tsixteen\\t(7)\\t\\n17\\tseventeen\\t(9)\\t\\n18\\teighteen\\t(8)\\t\\n19\\tnineteen\\t(8)\\n20\\ttwenty\\t(6)\\t\\n21\\ttwenty-one\\t(10)\\t\\n22\\ttwenty-two\\t(10)\\t\\n23\\ttwenty-three\\t(12)\\t\\n24\\ttwenty-four\\t(11)\\t\\n25\\ttwenty-five\\t(11)\\t\\n26\\ttwenty-six\\t(10)\\t\\n27\\ttwenty-seven\\t(12)\\t\\n28\\ttwenty-eight\\t(12)\\t\\n29\\ttwenty-nine\\t(11)\\n30\\tthirty\\t(6)\\t\\n31\\tthirty-one\\t(10)\\t\\n32\\tthirty-two\\t(10)\\t\\n33\\tthirty-three\\t(12)\\t\\n34\\tthirty-four\\t(11)\\t\\n35\\tthirty-five\\t(11)\\t\\n36\\tthirty-six\\t(10)\\t\\n37\\tthirty-seven\\t(12)\\t\\n38\\tthirty-eight\\t(12)\\t\\n39\\tthirty-nine\\t(11)\\t\\n40\\tforty\\t(5)\\t\\n41\\tforty-one\\t(9)\\t\\n42\\tforty-two\\t(9)\\t\\n43\\tforty-three\\t(11)\\t\\n44\\tforty-four\\t(10)\\t\\n45\\tforty-five\\t(10)\\t\\n46\\tforty-six\\t(9)\\t\\n47\\tforty-seven\\t(11)\\t\\n48\\tforty-eight\\t(11)\\t\\n49\\tforty-nine\\t(10)\\n50\\tfifty\\t(5)\\t\\n51\\tfifty-one\\t(9)\\t\\n52\\tfifty-two\\t(9)\\t\\n53\\tfifty-three\\t(11)\\t\\n54\\tfifty-four\\t(10)\\t\\n55\\tfifty-five\\t(10)\\t\\n56\\tfifty-six\\t(9)\\t\\n57\\tfifty-seven\\t(11)\\t\\n58\\tfifty-eight\\t(11)\\t\\n59\\tfifty-nine\\t(10)\\t\\n60\\tsixty\\t(5)\\t\\n61\\tsixty-one\\t(9)\\t\\n62\\tsixty-two\\t(9)\\t\\n63\\tsixty-three\\t(11)\\t\\n64\\tsixty-four\\t(10)\\t\\n65\\tsixty-five\\t(10)\\t\\n66\\tsixty-six\\t(9)\\t\\n67\\tsixty-seven\\t(11)\\t\\n68\\tsixty-eight\\t(11)\\t\\n69\\tsixty-nine\\t(10)\\t\\n70\\tseventy\\t(7)\\t\\n71\\tseventy-one\\t(11)\\t\\n72\\tseventy-two\\t(11)\\t\\n73\\tseventy-three\\t(13)\\t\\n74\\tseventy-four\\t(12)\\t\\n75\\tseventy-five\\t(12)\\t\\n76\\tseventy-six\\t(11)\\t\\n77\\tseventy-seven\\t(13)\\t\\n78\\tseventy-eight\\t(13)\\t\\n79\\tseventy-nine\\t(12)\\t\\t\\n80\\teighty\\t(6)\\t\\n81\\teighty-one\\t(10)\\t\\n82\\teighty-two\\t(10)\\t\\n83\\teighty-three\\t(12)\\t\\n84\\teighty-four\\t(11)\\t\\n85\\teighty-five\\t(11)\\t\\n86\\teighty-six\\t(10)\\t\\n87\\teighty-seven\\t(12)\\t\\n88\\teighty-eight\\t(12)\\t\\n89\\teighty-nine\\t(11)\\t\\t\\n90\\tninety\\t(6)\\t\\n91\\tninety-one\\t(10)\\t\\n92\\tninety-two\\t(10)\\t\\n93\\tninety-three\\t(12)\\t\\n94\\tninety-four\\t(11)\\t\\n95\\tninety-five\\t(11)\\t\\n96\\tninety-six\\t(10)\\t\\n97\\tninety-seven\\t(12)\\t\\n98\\tninety-eight\\t(12)\\t\\n99\\tninety-nine\\t(11)\\t\\n100\\thundred\\t(7)'''\\nres = [elem.strip().split() for elem in s.strip().split('\\\\n')]\\nassert(res[100][0] == '100')\\nn = int(input())\\nassert(len(res[n]) == 3)\\nword = res[n][1]\\nif 'k' in word or 'a' in word or 'n' in word:\\n    print('NO')\\nelse:\\n    print('YES')\", \"bad = [1, 10, 11, 13, 16,20, 24, 28, 37, 41, 49, 75]\\ngood = [2,3,4,5,12,30, 35,43, 46, 52,64,86]\\nn = int(input())\\nif n in good:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"N = int(input())\\ndef calc(n):\\n    if n == 5: return \\\"YES\\\"\\n    if n == 13: return \\\"NO\\\"\\n    if n == 24: return \\\"NO\\\"\\n    if n == 46: return \\\"YES\\\"\\n    if n == 1: return \\\"NO\\\"\\n    if n == 2: return \\\"YES\\\"\\n    if n == 3: return \\\"YES\\\"\\n    if n == 4: return \\\"YES\\\"\\n    if n <= 11: return \\\"NO\\\"\\n    if n == 12: return \\\"YES\\\"\\n    if n <= 29: return \\\"NO\\\"\\n    if n <= 30: return \\\"YES\\\"\\n    if n <= 35: return \\\"YES\\\"\\n    if n <= 41: return \\\"NO\\\"\\n    if n <= 45: return \\\"YES\\\"\\n    if n <= 50: return \\\"NO\\\"\\n    if n <= 70: return \\\"YES\\\"\\n    if n <= 80: return \\\"NO\\\"\\n    if n <= 90: return \\\"YES\\\"\\n    \\n    if n <= 100: return \\\"NO\\\"\\n    \\n    return 1/0\\n\\nprint(calc(N))\", \"v = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\na = int(input())\\nif a in v:\\n\\tprint('YES')\\nelse:\\n\\tprint('NO')\", \"n = int(input())\\nif n in {1, 10, 11, 13, 16, 20, 24, 28, 37, 41, 49, 75, 99}:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"ans = [2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86]\\na = int(input())\\nprint('YES' if a in ans else 'NO')\\n\", \"a = int(input())\\nif a == 5:\\n    print(\\\"YES\\\")\\nelif a == 13:\\n    print(\\\"NO\\\")\\nelif a == 24:\\n    print(\\\"NO\\\")\\nelif a == 46:\\n    print(\\\"YES\\\")\\nelif a == 1:\\n    print(\\\"NO\\\")\\nelif a == 2:\\n    print(\\\"YES\\\")\\nelif a == 3:\\n    print(\\\"YES\\\")\\nelif a == 4:\\n    print(\\\"YES\\\")\\nelif a == 10:\\n    print(\\\"NO\\\")\\nelif a == 11:\\n    print(\\\"NO\\\")\\nelif a == 12:\\n    print(\\\"YES\\\")\\nelif 14 <= a <= 28:\\n    print(\\\"NO\\\")\\nelif a <= 35:\\n    print(\\\"YES\\\")\\nelif a <= 41:\\n    print(\\\"NO\\\")\\nelif a <= 48:\\n    print(\\\"YES\\\")\\nelif a <= 51:\\n    print(\\\"NO\\\")\\nelif a <= 65:\\n    print(\\\"YES\\\")\\nelif a <= 80:\\n    print(\\\"NO\\\")\\nelif a <= 90:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n=int(input())\\nif n%10==1:\\n    print(\\\"NO\\\")\\nelif n%10==7:\\n    print(\\\"NO\\\")\\nelif n%10==9:\\n    print(\\\"NO\\\")\\nelif 13 <= n <= 29 or n == 10:\\n    print(\\\"NO\\\")\\nelif 70 <= n <= 79:\\n    print(\\\"NO\\\")\\nelif 90 <= n <= 99:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"a = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nn = int(input())\\nprint('YES' if n not in a else 'NO')\", \"n = int(input())\\nl = [1,7,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,31,37,39,41,47,49,51,57,59,61,67,69,70,71,72,73,74,75,76,77,78,79,81,87,89,90,91,92,93,94,95,96,97,98,99]\\nif n in l:\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \\\\\\n             6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \\\\\\n            11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \\\\\\n            15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \\\\\\n            19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \\\\\\n            50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \\\\\\n            90: 'Ninety', 0: 'Zero'}\\ndef n2w(n):\\n    if n <= 20:\\n        return num2words[n].lower()\\n    return num2words[n-n%10].lower() + num2words[n%10].lower()\\n\\nn = int(input())\\nprint('YES' if 'n' not in n2w(n) else 'NO')\\n\", \"a = [0, 2, 3, 4, 5, 6, 8, 12, 30, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88]\\n\\nn = int(input())\\nif n in a:\\n\\tprint(\\\"YES\\\")\\nelse:\\n\\tprint(\\\"NO\\\")\", \"num = int(input())\\nnumbers = [2,3,4,5,12,30,31,35,43,46,52,64,86]\\nif num in numbers:\\n    print(\\\"YES\\\")\\nelse:\\n    print(\\\"NO\\\")\", \"n = int(input())\\nif n in (2, 3, 4, 5, 6, 8, 12, 30, 31, 32, 33, 34, 35, 36, 38, 40, 42, 43, 44, 45, 46, 48, 50, 52, 53, 54, 55, 56, 58, 60, 62, 63, 64, 65, 66, 68, 80, 82, 83, 84, 85, 86, 88):\\n    print('YES')\\nelse:\\n    print('NO')\\n\", \"print(('NO', 'YES')[int(input()) in (2, 3, 4, 5, 12, 30, 31, 35, 43, 46, 52, 64, 86)])\\n\", \"n = input()\\nif \\\"12\\\"!=n and( (\\\"1\\\" in n )or (\\\"7\\\"in n)or(\\\"9\\\" in n)or( 10<=int(n)<=29 )or(70<=int(n)<80)or(90<=int(n)<=100)):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"def kanban(x):\\n    if x == 12:\\n        return False \\n    if x >= 10 and x < 30:\\n        return True\\n    if x >= 70 and x < 80:\\n        return True\\n    if x >= 90:\\n        return True\\n    return (x % 10) in [1, 7, 9]\\n\\nprint('NO' if kanban(int(input())) else 'YES')\", \"n=int(input())\\nl=[0,3,4,5,6,8]\\nprint('NYOE S'[n==12or n//10 in l and n%10 in[2]+l::2])\", \"n=int(input())\\nprint('YNEOS'[n!=12and(n//10in(1,2,7,9)or n%10in(1,7,9))::2])\", \"n='0'+input()\\nprint('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\", \"i=int(input())\\nir=i%10\\niq=i//10\\nif(i==12):\\n    print(\\\"YES\\\")\\nelif(ir==1 or ir==7 or ir==9):\\n    print(\\\"NO\\\")\\nelif(iq==1 or iq==7 or iq==9 or iq==2):\\n    print(\\\"NO\\\")\\nelse:\\n    print(\\\"YES\\\")\", \"n='0'+input();print('YNEOS'[n!='012'and(n[-2]in'1279'or n[-1]in'179')::2])\"]",
        "difficulty": "interview",
        "input": "99\n",
        "output": "NO\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/B"
    },
    {
        "id": 1613,
        "task_id": 1106,
        "test_case_id": 1,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2\n1 2 3 4 5 6\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1614,
        "task_id": 1106,
        "test_case_id": 2,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2\n1 2 3 3 2 2\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1615,
        "task_id": 1106,
        "test_case_id": 4,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2\n59 96 34 48 8 72\n",
        "output": "139\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1616,
        "task_id": 1106,
        "test_case_id": 5,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3\n87 37 91 29 58 45 51 74 70 71 47 38 91 89\n",
        "output": "210\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1617,
        "task_id": 1106,
        "test_case_id": 6,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5\n39 21 95 89 73 90 9 55 85 32 30 21 68 59 82 91 20 64 52 70 6 88 53 47 30 47 34 14 11 22 42 15 28 54 37 48 29 3 14 13 18 77 90 58 54 38 94 49 45 66 13 74 11 14 64 72 95 54 73 79 41 35\n",
        "output": "974\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1618,
        "task_id": 1106,
        "test_case_id": 10,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2\n72 22 81 23 14 75\n",
        "output": "175\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1619,
        "task_id": 1106,
        "test_case_id": 11,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2\n100 70 27 1 68 52\n",
        "output": "53\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1620,
        "task_id": 1106,
        "test_case_id": 12,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2\n24 19 89 82 22 21\n",
        "output": "80\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1621,
        "task_id": 1106,
        "test_case_id": 13,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3\n86 12 92 91 3 68 57 56 76 27 33 62 71 84\n",
        "output": "286\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1622,
        "task_id": 1106,
        "test_case_id": 14,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3\n14 56 53 61 57 45 40 44 31 9 73 2 61 26\n",
        "output": "236\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1623,
        "task_id": 1106,
        "test_case_id": 15,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3\n35 96 7 43 10 14 16 36 95 92 16 50 59 55\n",
        "output": "173\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1624,
        "task_id": 1106,
        "test_case_id": 16,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4\n1 97 18 48 96 65 24 91 17 45 36 27 74 93 78 86 39 55 53 21 26 68 31 33 79 63 80 92 1 26\n",
        "output": "511\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1625,
        "task_id": 1106,
        "test_case_id": 17,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4\n25 42 71 29 50 30 99 79 77 24 76 66 68 23 97 99 65 17 75 62 66 46 48 4 40 71 98 57 21 92\n",
        "output": "603\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1626,
        "task_id": 1106,
        "test_case_id": 18,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4\n49 86 17 7 3 6 86 71 36 10 27 10 58 64 12 16 88 67 93 3 15 20 58 87 97 91 11 6 34 62\n",
        "output": "470\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1627,
        "task_id": 1106,
        "test_case_id": 19,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5\n16 87 36 16 81 53 87 35 63 56 47 91 81 95 80 96 91 7 58 99 25 28 47 60 7 69 49 14 51 52 29 30 83 23 21 52 100 26 91 14 23 94 72 70 40 12 50 32 54 52 18 74 5 15 62 3 48 41 24 25 56 43\n",
        "output": "1060\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1628,
        "task_id": 1106,
        "test_case_id": 20,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5\n40 27 82 94 38 22 66 23 18 34 87 31 71 28 95 5 14 61 76 52 66 6 60 40 68 77 70 63 64 18 47 13 82 55 34 64 30 1 29 24 24 9 65 17 29 96 61 76 72 23 32 26 90 39 54 41 35 66 71 29 75 48\n",
        "output": "1063\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1629,
        "task_id": 1106,
        "test_case_id": 21,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5\n64 72 35 68 92 95 45 15 77 16 26 74 61 65 18 22 32 19 98 97 14 84 70 23 29 1 87 28 88 89 73 79 69 88 43 60 64 64 66 39 17 27 46 71 18 83 73 20 90 77 49 70 84 63 50 72 26 87 26 37 78 65\n",
        "output": "987\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1630,
        "task_id": 1106,
        "test_case_id": 22,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "6\n35 61 54 77 70 50 53 70 4 66 58 47 76 100 78 5 43 50 55 93 13 93 59 92 30 74 22 23 98 70 19 56 90 92 19 7 28 53 45 77 42 91 71 56 19 83 100 53 13 93 37 13 70 60 16 13 76 3 12 22 17 26 50 6 63 7 25 41 92 29 36 80 11 4 10 14 77 75 53 82 46 24 56 46 82 36 80 75 8 45 24 22 90 34 45 76 18 38 86 43 7 49 80 56 90 53 12 51 98 47 44 58 32 4 2 6 3 60 38 72 74 46 30 86 1 98\n",
        "output": "2499\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1631,
        "task_id": 1106,
        "test_case_id": 23,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "6\n63 13 100 54 31 15 29 58 59 44 2 99 70 33 97 14 70 12 73 42 65 71 68 67 87 83 43 84 18 41 37 22 81 24 27 11 57 28 83 92 39 1 56 15 16 67 16 97 31 52 50 65 63 89 8 52 55 20 71 27 28 35 86 92 94 60 10 65 83 63 89 71 34 20 78 40 34 62 2 86 100 81 87 69 25 4 52 17 57 71 62 38 1 3 54 71 34 85 20 60 80 23 82 47 4 19 7 18 14 18 28 27 4 55 26 71 45 9 2 40 67 28 32 19 81 92\n",
        "output": "2465\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1632,
        "task_id": 1106,
        "test_case_id": 24,
        "question": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2^{n}, 2^{n} + 1, ..., 2^{n} + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2^{n} + 1) there is a road to the square $\\lfloor \\frac{i}{2} \\rfloor$. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.  [Image]  To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square $\\lfloor \\frac{i}{2} \\rfloor$ has a_{i} lights.\n\nOm Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe. \n\nHe asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.\n\nThe next line contains 2^{n} + 1 - 2 numbers a_2, a_3, ... a_2^{n} + 1 - 1 — the initial numbers of street lights on each road of the park. Here a_{i} is the number of street lights on the road between squares i and $\\lfloor \\frac{i}{2} \\rfloor$. All numbers a_{i} are positive integers, not exceeding 100.\n\n\n-----Output-----\n\nPrint the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.\n\n\n-----Examples-----\nInput\n2\n1 2 3 4 5 6\n\nOutput\n5\n\n\n\n-----Note-----\n\nPicture for the sample test. Green color denotes the additional street lights. [Image]",
        "solutions": "[\"def dfs(i):\\n    if i >= 2 ** n:\\n        return 0, 0\\n    x1, m1 = dfs(i * 2)\\n    x2, m2 = dfs(i * 2 + 1)\\n    if m1 + a[i * 2] < m2 + a[i * 2 + 1]:\\n        return x1 + x2 + m2 + a[i * 2 + 1] - m1 - a[i * 2], m2 + a[i * 2 + 1]\\n    return x1 + x2 + m1 + a[i * 2] - m2 - a[i * 2 + 1], m1 + a[i * 2]\\nn = int(input())\\na = [0, 0] + [int(i) for i in input().split()]\\nprint(dfs(1)[0])\", \"n = int(input())\\nM = 2 ** (n + 1)\\nA = [0, 0] + list(map(int, input().split()))\\nAns = [0] * M\\nans = 0\\nfor i in range(2 ** n - 1, 0, -1):\\n    left = i * 2\\n    right = i * 2 + 1\\n    m_l = A[left] + Ans[left]\\n    m_r = A[right] + Ans[right]\\n    Ans[i] = max(m_l, m_r)\\n    ans += abs(m_l - m_r)\\nprint(ans)\\n\\n\", \"def result(i):\\n    nonlocal ans\\n    temp = 0\\n    if i < (1 << n):\\n        temp = (result(2 * i), result(2 * i + 1))\\n        ans += abs(temp[0] - temp[1])\\n        temp = max(temp)\\n    return lights[i] + temp\\n\\nn = int(input())\\nlights = [0, 0] + list(map(int, input().split()))\\nans = 0\\nresult(1)\\nprint(ans)\\n\", \"def B():\\n    s = 0\\n    n = int(input())\\n    k = (1 << (n + 1)) - 1\\n    a = [0, 0] + list(map(int, input().split()))\\n    for i in range(k, 1, -2):\\n        u, v = a[i], a[i - 1]\\n        if u > v: u, v = v, u\\n        s += v - u\\n        a[i >> 1] += v\\n    return s\\nprint(B())\", \"globCnt = 0\\n\\n\\ndef rec(root):\\n\\tnonlocal globCnt, cnt\\n\\tif root - 1 >= len(cnt):\\n\\t\\treturn 0\\n\\tl = rec(2 * root + 1)\\n\\tr = rec(2 * root + 2)\\n\\tif l != r:\\n\\t\\tglobCnt += abs(l - r)\\n\\treturn max(l, r) + cnt[root - 1]\\n\\n\\nn = int(input())\\ncnt = list(map(int, input().split()))\\n\\nrec(0)\\nprint(globCnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndp = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2, 2 ** (n + 1)):\\n    dp[i - 1] = dp[i // 2 - 1] + a[i - 2]\\nmx = 0\\nsm = 0\\n# print(dp)\\nx = [0] * (2 ** (n + 1) - 1)\\nfor i in range(2 ** n):\\n    mx = max(mx, dp[-i - 1])\\n    sm += dp[-i - 1]\\nfor i in range(2 ** n):\\n    x[-i - 1] = mx - dp[-i - 1]\\n# print(x)\\ni = len(x) - 1\\nwhile i >= 0:\\n    mn = min(x[i], x[i - 1])\\n    x[i] -= mn\\n    x[i - 1] -= mn\\n    x[(i + 1) // 2 - 1] += mn\\n    i -= 2\\nprint(sum(x))\", \"#!python3\\nn = int(input())\\na = input().split()\\na = [int(i) for i in a]\\n\\ndef solve(n, a, added):\\n\\tlast = a[-2**n:]\\n\\tnew = []\\n\\n\\tfor i in range(0, 2**n-1, 2):\\n\\t\\t#print(last[i])\\n\\t\\tx = last[i]\\n\\t\\ty = last[i+1]\\n\\t\\tnew.append(max(x,y))\\n\\t\\tadded = added + abs(x-y)\\n\\n\\ta = a[:-2**n]\\n\\n\\tif a==[]:\\n\\t\\ta = [0]\\n\\n\\tfor i in range(1, 2**(n-1)+1):\\n\\t\\ta[-i] = a[-i] + new[-i]\\n\\n\\tn = n-1\\n\\tif n==0:\\n\\t\\tprint(added)\\n\\telse:\\n\\t\\tsolve(n, a, added)\\n\\nsolve(n, a, 0)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nb = 2 ** (n + 1) - 3\\nwhile n != 0:\\n    n -= 1\\n    #print(n)\\n    p = 2 ** (n + 1) - 3\\n    while b != p:\\n        ans += abs(arr[b] - arr[b - 1])\\n        arr[b // 2 - 1] += max(arr[b], arr[b - 1])\\n        #print(arr)\\n        b -= 2\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    d = 0\\n    count = 0\\n    for j in range(n, 0, -1):\\n        for i in range(2**j-2, 2**(j+1)-2, 2):\\n            d = max(a[i] , a[i+1])- min(a[i], a[i+1])\\n            count += d\\n            if i:\\n                a[i//2-1] += max(a[i] , a[i+1])\\n    print(count)\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def get_lights_in_subtree(data, i):\\n    total = 0\\n\\n    if i < len(data):\\n        total += data[i]\\n    else:\\n        return 0\\n\\n    total += get_lights_in_subtree(data, 2 * i + 1)\\n    total += get_lights_in_subtree(data, 2 * i + 2)\\n\\n    return total\\n\\n\\ndef count_needed_lights(data, i):\\n    if i >= len(data):\\n        return 0, 0\\n\\n    l1 = count_needed_lights(data, 2 * i + 1)\\n    l2 = count_needed_lights(data, 2 * i + 2)\\n\\n    #print(l1, l2, '----')\\n\\n    total = l1[0] + l2[0]\\n    total += abs(l1[1] - l2[1])\\n\\n    return total, max(l1[1], l2[1]) + data[i]\\n\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = [0] + list(map(int, input().split()))\\n    print(count_needed_lights(data, 0)[0])\\n__starting_point()\", \"3\\nn = 2**(int(input())+1)-1\\nd = input().split(' ')\\nfor i in range(len(d)):\\n    d[i] = int(d[i])\\np = 0\\nfor i in range(len(d)-1, 0, -2):\\n    p += abs(d[i]-d[i-1])\\n    d[i//2-1] += max(d[i], d[i-1])\\nprint(p)\", \"from itertools import product\\nn = int(input())\\na = list(map(int, input().split()))\\nk = 1\\ncnt = []\\nfor i in product([0, 1], repeat = n):\\n\\tk = 1\\n\\tv = 0\\n\\tfor j in range(n):\\n\\t\\tk = k*2 + i[j]\\n\\t\\tif k - 2 < len(a):\\n\\t\\t\\tv += a[k - 2]\\n\\tcnt.append(v)\\nmini = -1\\nfor i in range(len(cnt)):\\n\\tif cnt[i] > mini:\\n\\t\\tmini = cnt[i]\\n\\nans = 0\\nfor i in range(1, n + 1):\\n\\tminicur = -1\\n\\tk = 0\\n\\tk1 = 2**(n-i)\\n\\tfor j in range(2**i):\\n\\t\\tminicur = -1\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tif cnt[l] > minicur:\\n\\t\\t\\t\\tminicur = cnt[l]\\n\\t\\tfor l in range(k, k1):\\n\\t\\t\\tcnt[l] += (mini - minicur)\\n\\t\\tans += mini - minicur\\n\\t\\tk += 2**(n - i)\\n\\t\\tk1 += 2**(n - i)\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\nai = list(map(int,input().split()))\\nai = [0,0] + ai\\ncnt = []\\nans = 0\\nwhile n >= 1:\\n  for i in range(2 ** n,2 ** (n + 1),2):\\n      ans += abs(ai[i] - ai[i + 1])\\n      ai[i // 2] += max(ai[i],ai[i + 1])\\n  n -= 1\\nprint(ans)\", \"# fin = open(\\\"input.txt\\\")\\n# n = int(fin.readline())\\n# A = [0] + list(map(int, fin.readline().split()))\\nn = int(input())\\nA = [0] + list(map(int, input().split()))\\nC = 0\\nfor i in range(2 ** n - 2, -1, -1):\\n\\tC += abs(A[i * 2 + 1] - A[i * 2 + 2])\\n\\tA[i] += max(A[i * 2 + 1], A[i * 2 + 2])\\nprint(C)\\n\", \"n = int(input())\\nm = (1 << (n + 1)) - 1\\na = [0] + list(map(int, input().split()))\\n\\nmax_value = 0\\n\\ndef precalc(i, prev):\\n    nonlocal max_value\\n    if i < m:\\n        a[i] += prev\\n        if a[i] > max_value:\\n            max_value = a[i]\\n        precalc((i << 1) + 1, a[i])\\n        precalc((i << 1) + 2, a[i])\\n\\ndef calc(i):\\n    if i >= (1 << n) - 1:\\n        return 0\\n    x = (i << 1) + 1\\n    y = (i << 1) + 2\\n    result = calc(x) + calc(y)\\n    a[i] = max(a[x], a[y])\\n    return result + a[i] - min(a[x], a[y])\\n\\nprecalc(0, 0)\\nprint(calc(0))\\n\", \"# stop right here... don't try to read this code, is ugly and probably doesn't work\\n\\n\\nfrom collections import deque\\n\\n\\nn = int(input())\\nligths = [0, 0] + [int(x) for x in input().split()]\\n\\nprefix_tree = [0 for _ in range(len(ligths))]\\n\\nq = deque()\\nq.append(1)\\nwhile len(q):\\n    m = q.pop()\\n    prefix_tree[m] = ligths[m] + prefix_tree[m//2]\\n\\n    if m*2+1 < len(ligths):\\n        q.append(m*2)\\n        q.append(m*2+1)\\n\\nneeded_lights = max(prefix_tree)\\n\\n\\n\\nsuffix_tree = [0 for _ in range(len(ligths))]\\ndef pocitaj(i):\\n    if i >= len(ligths):\\n        return\\n\\n    pocitaj(i*2)\\n    pocitaj(i*2+1)\\n\\n    if i >= len(ligths)//2:\\n        suffix_tree[i] = ligths[i]\\n    else:\\n        suffix_tree[i] = max(suffix_tree[i*2], suffix_tree[i*2+1]) + ligths[i]\\n\\npocitaj(1)\\nsuffix_tree += [needed_lights for _ in range(len(ligths))]\\n\\n\\nclass Test:\\n    def __init__(self):\\n        self.ans = 0\\n        self.vypocitaj(1)\\n\\n    def vypocitaj(self, i):\\n\\n        if suffix_tree[i*2] < suffix_tree[i*2+1]:\\n            rozdiel = suffix_tree[i*2+1] - suffix_tree[i*2]\\n            self.ans += rozdiel\\n        else:\\n            rozdiel = suffix_tree[i*2] - suffix_tree[i*2+1]\\n            self.ans += rozdiel\\n\\n        if i*2+1 < len(ligths):\\n            self.vypocitaj(i*2)\\n            self.vypocitaj(i*2+1)\\n\\nans = Test()\\nprint(ans.ans)\", \"from math import floor\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = list(map(int, input().split()))\\n\\t\\n\\tstreets = []\\n\\t\\t\\n\\tfor i in range(2**n, 2**(n+1)):\\n\\t\\t#print('---')\\t\\t\\n\\t\\tidx = i\\n\\t\\t#print(idx)\\n\\t\\tif idx > 1:\\n\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\tres = a[idx-2]\\n\\t\\twhile idx > 0:\\n\\t\\t\\tidx = int(floor(idx/2))\\n\\t\\t\\tif idx > 1:\\n\\t\\t\\t\\t#print(idx)\\n\\t\\t\\t\\t#print('Cost: %d' % a[idx-2])\\n\\t\\t\\t\\tres += a[idx-2]\\n\\t\\t#print('res: %d' % res)\\n\\t\\tstreets.append(res)\\n\\tres = 0\\n\\t#print(streets)\\n\\twhile len(streets) > 2:\\n\\t\\tnew_streets = []\\n\\t\\tfor i in range(0, len(streets), 2):\\n\\t\\t\\t#print('i: %d' % i)\\n\\t\\t\\tres += abs(streets[i]-streets[i+1])\\n\\t\\t\\tnew_streets.append(max(streets[i], streets[i+1]))\\n\\t\\t#print(new_streets, cur_diff)\\n\\t\\tstreets = new_streets\\n\\tprint(res+abs(streets[0]-streets[1]))\\n\\ndef __starting_point():\\n\\tmain()\\n\\n__starting_point()\", \"class Route:\\n    def __init__(self):\\n        self.lamps_count = 0\\n        self.nodes = {}\\n\\n\\ndef solve(n, lamps):\\n    routes_count = 2**n\\n    max_node_num = 2**(n+1) - 1\\n    routes = [Route() for _ in range(routes_count)]\\n\\n    def dfs_pre(node, count=0):\\n        if node >= routes_count:\\n            route = routes[node - routes_count]\\n            route.lamps_count = count\\n            while node != 0:\\n                route.nodes[node] = node\\n                node //= 2\\n        else:\\n            dfs_pre(node*2, count+lamps[(node - 1)*2])\\n            dfs_pre(node*2+1, count+lamps[(node - 1)*2 + 1])\\n\\n    def dfs_post(node):\\n        if node > max_node_num:\\n            return 0\\n\\n        diffs = []\\n        for r in routes:\\n            if node in r.nodes:\\n                diffs.append(max_lamps_count - r.lamps_count)\\n        diffs.sort()\\n        if diffs and diffs[0]:\\n            for r in routes:\\n                if node in r.nodes:\\n                    r.lamps_count += diffs[0]\\n\\n        return diffs[0] + dfs_post(node*2) + dfs_post(node*2+1)\\n\\n    dfs_pre(1)\\n    max_lamps_count = sorted(routes, key=lambda r: -r.lamps_count)[0].lamps_count\\n    res = dfs_post(1)\\n\\n    return res\\n\\n\\ndef main():\\n    n = int(input().strip())\\n    lamps = list(map(int, input().strip().split()))\\n    print(solve(n, lamps))\\n\\nmain()\\n\", \"\\nn = int(input())\\na = [int(x) for x in input().split()]\\nm = len(a)\\n\\nsums = [0] * (m+1)\\ncount = 0\\n\\na.insert(0, 0)\\n\\n#stack = [(0, 0)]\\n#while stack:\\n    #v, s = stack.pop(0)\\n    #sums[v] = s\\n    ##print(v+1, s)\\n\\n    #if 2*v+1 >= m:\\n        ##sums.append(s)\\n        #if s > count:\\n            #count = s\\n        #continue\\n\\n    #stack.append((2*v+1, s+a[2*v+1]))\\n    #stack.append((2*v+2, s+a[2*v+2]))\\n\\n#print(sums, count)\\n\\nadd = 0\\nfor i in range(m // 2 - 1, -1, -1):\\n    m = max(a[2*i+1], a[2*i+2])\\n    need_l = m - a[2*i+1]\\n    need_r = m - a[2*i+2]\\n    #print('at', i, 'l needs', need_l, 'r needs', need_r, 'setting i to', sums[i] + a[2*i+1] + need_l)\\n    add += need_l + need_r\\n    a[i] += a[2*i+1] + need_l\\n\\nprint(add)\", \"#!/usr/bin/env python3\\n# -*- coding: utf-8 -*-\\n# author: firolunis\\n# version: 0.1\\n\\nn = int(input())\\npark = input().split(' ')\\npark = [int(i) for i in park]\\npark.insert(0, 0)\\nlights = [0 for i in range(2 ** (n + 1) - 1)]\\nres = 0\\nfor k in range(n, 0, -1):\\n    for i, j in tuple(enumerate(park))[(2 ** k) - 1:2 ** (k + 1) - 1:2]:\\n        res += abs(j + lights[i] - park[i + 1] - lights[i + 1])\\n        lights[i // 2] = max(j + lights[i], park[i + 1] + lights[i + 1])\\nprint(res)\\n\", \"import sys, os\\nimport fileinput\\nn = int(input()) + 1\\na = [int(x) for x in input().split()]\\n\\nall_count = 2 ** n - 1\\nb = [0] * all_count\\n\\ncounter = 0\\n\\nfor i in range(n, 1, -1):\\n\\tlcnt =  2 ** (i - 1)\\n\\tfirst = 2 ** (i - 1) - 2 \\n\\t#print(lcnt, first)\\n\\tlevel = a[first:first + lcnt]\\n\\t# print(level)\\n\\n\\tfor j in range(0, lcnt, 2):\\n\\t\\tindex = first + 2 + j\\n\\n\\t\\tif i == n:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"-\\\" * 10)\\n\\t\\t\\tdiff = abs(level[j] - level[j + 1])\\n\\t\\t\\t# print(j, level[j], level[j+1], diff)\\n\\t\\t\\tcounter += diff\\n\\t\\t\\t# print(index//2 - 1, level[j] + level[j + 1] + diff)\\n\\n\\t\\t\\tb[index//2 - 1] += level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"=\\\" * 10)\\n\\t\\telse:\\n\\t\\t\\t# print(i)\\n\\t\\t\\t# print(\\\"*\\\" * 10)\\n\\t\\t\\t# print(index)\\n\\t\\t\\t# print(b)\\n\\t\\t\\t# print(level)\\n\\t\\t\\tdiff = abs(abs(b[index - 1]//2 + level[j]) - abs(b[index]//2 + level[j + 1]))\\n\\t\\t\\tcounter += diff\\n\\t\\t\\tb[index//2 - 1] += b[index-1]//2 + b[index]//2 + level[j] + level[j + 1] + diff\\n\\t\\t\\t# print(\\\"+\\\" * 10)\\n\\nprint(counter)\\n# print(b)\\n\", \"n = int(input())\\nV = 2 ** (n + 1) - 1\\nlights = [0] * (V + 1)\\nrem_lights = [0] * (V + 1)\\nfor i,v in enumerate(input().split()):\\n    lights[i + 2] = int(v)\\nstack = [3,2]\\nwhile(stack):\\n    i = stack.pop()\\n    rem_lights[i] = rem_lights[i // 2] + lights[i]\\n    if (2 * i < V):\\n        stack.append(2 * i + 1)\\n        stack.append(2 * i)\\nm = max(rem_lights)\\n#print(\\\"max:\\\"+str(m))\\n#print(rem_lights)\\nfor i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        rem_lights[i] = m - rem_lights[i]\\n        rem_lights[i + 1] = m - rem_lights[i + 1]\\nwhile n:\\n    for i in range(2 ** n,2 ** (n + 1) - 1,2):\\n        small = min(rem_lights[i],rem_lights[i + 1])\\n        rem_lights[i // 2] = small\\n        rem_lights[i] -= small\\n        rem_lights[i + 1] -= small\\n    n-=1\\n#print(rem_lights)\\nprint(sum(rem_lights))\", \"n = 2**(int(input())+1)-1;\\na = [0,0] + list(map(int,input().split()))\\nr = 0\\nwhile n>1:\\n  a[n//2] += max(a[n], a[n-1])\\n  r += abs(a[n]-a[n-1])\\n  n -= 2\\nprint(r)\\n\", \"import fileinput\\n\\ndef parent_id(elem_id):\\n    return int(elem_id / 2)\\n\\ndef children_ids(elem_id):\\n    return elem_id * 2, elem_id * 2 + 1\\n\\ndef solve(lights):\\n    def solve_subtree(root_id):\\n        a, b = children_ids(root_id)\\n        if a >= len(lights):\\n            # print(root_id, \\\"is leaf and has\\\", lights[root_id], \\\"lights\\\")\\n            return (0, lights[root_id])\\n        else:\\n            needed_a, val_a = solve_subtree(a)\\n            needed_b, val_b = solve_subtree(b)\\n            max_val = max(val_b, val_a)\\n            # print(root_id, \\\"has\\\", val_a, \\\"and\\\", val_b, \\\"in subtrees, totally needs\\\",\\n            #     (needed_a + needed_b + (2 * max_val - (val_a + val_b))), \\\"lights\\\")\\n            return (needed_a + needed_b + (2 * max_val - (val_a + val_b)),\\n                    max_val + lights[root_id])\\n    needed, val = solve_subtree(1)\\n    return needed\\n\\ndef __starting_point():\\n    data = list(iter(fileinput.input()))\\n    lights = [0, 0] + list(map(int, data[1].split()))\\n    print(solve(lights))\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "6\n87 62 58 32 81 92 12 50 23 27 38 39 64 74 16 35 84 59 91 87 14 48 90 47 44 95 64 45 31 11 67 5 80 60 36 15 91 3 21 2 40 24 37 69 5 50 23 37 49 19 68 21 49 9 100 94 45 41 22 31 31 48 25 70 25 25 95 88 82 1 37 53 49 31 57 74 94 45 55 93 43 37 13 85 59 72 15 68 3 90 96 55 100 64 63 69 43 33 66 84 57 97 87 34 23 89 97 77 39 89 8 92 68 13 50 36 95 61 71 96 73 13 30 49 57 89\n",
        "output": "2513\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/526/B"
    },
    {
        "id": 1633,
        "task_id": 1148,
        "test_case_id": 6,
        "question": "Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains a_{i} liters of paint of color i.\n\nVika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will start painting squares one by one from left to right, starting from the square number 1 and some arbitrary color. If the square was painted in color x, then the next square will be painted in color x + 1. In case of x = n, next square is painted in color 1. If there is no more paint of the color Vika wants to use now, then she stops.\n\nSquare is always painted in only one color, and it takes exactly 1 liter of paint. Your task is to calculate the maximum number of squares that might be painted, if Vika chooses right color to paint the first square.\n\n\n-----Input-----\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has.\n\nThe second line of the input contains a sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), where a_{i} is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that Vika has.\n\n\n-----Output-----\n\nThe only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.\n\n\n-----Examples-----\nInput\n5\n2 4 2 3 3\n\nOutput\n12\n\nInput\n3\n5 5 5\n\nOutput\n15\n\nInput\n6\n10 10 10 1 10 10\n\nOutput\n11\n\n\n\n-----Note-----\n\nIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.\n\nIn the second sample Vika can start to paint using any color.\n\nIn the third sample Vika should start painting using color number 5.",
        "solutions": "[\"am=0\\nx = int(input())\\nl = list(map(int, input().split(' ')))\\nm = min(l)\\nk = [i for i in range(x) if l[i] == m]\\nk.append(k[0]+x)\\nfor i in range(len(k)-1):\\n    am = max(am, k[i+1]-k[i])\\n\\nprint(m * x + am - 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmax_segment = 0\\ncount = 0\\na = a + a\\nfor i in range(len(a)):\\n    if a[i] == minimum:\\n        max_segment = max(count, max_segment)\\n        count = 0\\n    else:\\n        count += 1\\nmax_segment = max(count, max_segment)\\nprint(minimum * n + max_segment)\\n\", \"import itertools\\nimport math\\n\\nn = int(input())\\na = [int(x) for x in input().split()]\\namin = min(a)\\nb = list([x for x in enumerate(a) if x[1] == amin])\\nl = len(b)\\nk = max((b[(i+1) % l][0] - b[i][0] - 1)%n for i in range(l))\\nprint(amin*n + k)\\n\\n\\n\", \"n = int(input())\\nnumbers = input().split(\\\" \\\")\\nmi = 10000000007\\nfor i in range(len(numbers)):\\n    mi = min(mi, int(numbers[i]))\\nfor i in range(len(numbers)):\\n    numbers[i] = int(numbers[i])-mi\\n\\nret = 0\\nlength = 0\\nj=0\\nwhile numbers[j] > 0:\\n    j+=1\\nfor i in range(len(numbers)):\\n    if numbers[i] != 0:\\n        length+=1\\n    else:\\n        ret = max(ret, length)\\n        length = 0\\nret = max(ret, length+j)\\nprint(ret+n*mi)\\n\", \"n = int(input())\\nv = [int(x) for x in input().split()]\\nlow = min(v)\\n\\nres = low * n\\nv = [x-low for x in v]\\nv *= 2\\n\\nstart = -1\\nsol = 0\\n\\nfor i, x in enumerate(v):\\n    if x != 0:\\n        if start < 0:\\n            start = i\\n    else:\\n        if start >= 0:\\n            sol = max(sol, i-start)\\n            start = -1\\n\\nres += sol\\nprint(res)\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\nm = min(nums)\\n\\nx = [num > m for num in nums]\\nx = x + x\\n\\nleft = 0\\nright = 0\\nans = 0\\nwhile right < 2 * n:\\n    if left == right:\\n        right += 1\\n    elif not x[left]:\\n        left += 1\\n    elif x[right]:\\n        right += 1\\n    else:\\n        ans = max(ans, right - left)\\n        left = right\\nprint(n * m + ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nm = min(a)\\nb = [int(a[i] > m) for i in range(n)]\\nL = Max = 0\\nlast = -1\\nfor i in range(n):\\n    if b[i] == 0 and last != -1:\\n        Max = max(i - last, Max)\\n        last = -1\\n    elif last == -1 and b[i]:\\n        last = i\\nif last != -1:\\n    Max = max(n - last, Max)\\nif b[0] and b[-1]:\\n    L = 0; R = n - 1\\n    while b[L] and L < n - 1: L += 1\\n    while b[R] and L > 0: R -= 1\\n    L -= 1; R += 1\\n    Max = max(L + n - R + 1, Max)\\nans = m * n + Max\\nprint(ans)\\n\", \"x = int(input())\\ns = [int(i) for i in input().split()]\\nn = min(s)\\ncount = n*x\\nt = 0\\nfor i in range(x):\\n\\ts[i]-= n\\ns += s\\nm = 0\\nfor i in s:\\n\\tif not i:\\n\\t\\tm = max(m, t)\\n\\t\\tt = 0\\n\\telse:\\n\\t\\tt+=1\\nprint(count+m)\\n\", \"#Vika\\ncol=int(input())\\nll=list(map(int, input().split()))\\na1=col*min(ll)\\nm=min(ll)\\ns=[]\\nt=0\\nfor i in ll:\\n    t+=1\\n    if i==m:\\n        s.append(t-1)\\n        t=0\\ns[0]+=t\\nprint(a1+max(s))\\n\", \"import sys\\nif False:\\n\\tinp = open('B.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn = int(inp.readline())\\nliters = list(map(int, inp.readline().split()))\\nbefore = 0\\nafter = 0\\nlow = 10**9+10\\nmaxBetween = 0\\nbetween = 0\\nfor i in range(n):\\n\\tif liters[i] == low:\\n\\t\\tafter = -1\\n\\t\\tmaxBetween = max(maxBetween, between)\\n\\t\\tbetween = -1\\n\\tif liters[i] < low:\\n\\t\\tbefore = i\\n\\t\\tlow = liters[i]\\n\\t\\tafter = -1\\n\\t\\tbetween = -1\\n\\t\\tmaxBetween = 0\\n\\tafter += 1\\n\\tbetween += 1\\nans = low*n + max(maxBetween, before + after)\\nprint(ans)\\n\", \"N=int(input())\\nx=list(map(int,input().split()))\\nf=min(x)\\nans=N*f\\ncurlen=0\\nmaxlen=0\\nindex=0\\nwhile(index<2*N):\\n    if (x[index%N]==f):\\n        maxlen=max(maxlen,curlen)\\n        curlen=0\\n    else:\\n        curlen+=1\\n    index+=1\\nmaxlen=max(maxlen,curlen)\\nprint(ans+maxlen)\\n\", \"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    mi = min(a)\\n    d = 0\\n    p = n + a.index(mi)\\n    for i in range(n - 1, -1, -1):\\n        if a[i] == mi:\\n            p = i\\n        d = max(d, p - i)\\n    print(mi * n + d)\\n    \\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmaximum = 0\\nans = 0\\nind = 0\\nchallengers = []\\n\\nfor i in range(n):\\n    if a[i] != minimum and a[i - 1] == minimum:\\n        challengers.append(i)\\n        \\nwhile challengers:\\n    cnt = 0\\n    num = challengers.pop()\\n    similar = num\\n    while a[similar] != minimum:\\n        cnt += 1\\n        similar = (similar + 1) % n\\n    if cnt > maximum:\\n        maximum = cnt\\n        ind = num\\n    \\n\\nans = minimum * n\\nwhile a[ind] != minimum:\\n    ans += 1\\n    ind = (ind + 1) % n\\nprint(ans)\", \"__author__ = 'Utena'\\nn=int(input())\\ns=list(map(int,input().split()))\\nm=min(s)\\na=[]\\nb=[]\\nfor i in range(n):\\n    if s[i]==m:\\n        a.append(i)\\nfor t in range(len(a)-1):\\n    b.append(a[t+1]-a[t]-1)\\nb.append(a[0]-a[-1]-1+n)\\nprint(n*m+max(b))\", \"n = int(input())\\na = list(map(int, str(input()).split()))\\n\\n# print('n', n)\\n# print('a', a)\\n\\nminNumber = min(a)\\nsumA = minNumber * n\\n\\n# print('sumA', sumA)\\n\\nfor i in range(n):\\n    a[i] -= minNumber\\n\\n# print('a', a)\\n\\nhasGoRound = False\\nisCounting = False\\nindex = 0\\ncount = 0\\nmaxCount = 0\\nwhile True:\\n    # print('\\\\ta', a[index])\\n    if a[index] != 0 and not isCounting:\\n        isCounting = True\\n    if a[index] != 0 and isCounting:\\n        count += 1\\n    else:\\n        if maxCount < count:\\n            maxCount = count\\n        if hasGoRound:\\n            break\\n        isCounting = False\\n        count = 0\\n    index += 1\\n    if index == n:\\n        index = 0\\n        hasGoRound = True\\n# print('maxCount', maxCount)\\nprint(sumA + maxCount)\", \"def find_right(x, data):\\n    answer = -1\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            answer = i\\n    return answer\\n\\ndef find_left(x, data):\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            return i\\n\\n\\nn = int(input())\\ndata = list(map(int, input().split()))\\nmin1 = min(data)\\nindex_min_r = find_right(min1, data)\\nindex_min_l = find_left(min1, data)\\nk = data.count(min1)\\nc = index_min_r - index_min_l - 1\\nhelp = []\\nfor i in range(n):\\n    if data[i] == min1:\\n        help.append(i)\\nanswer = []\\nfor i in range(1, len(help)):\\n    answer.append(help[i] - help[i - 1] - 1)\\nanswer.append(n - (help[-1] - help[0]) - 1)\\nprint(max(answer) + n * min1)\", \"trash = int(input());\\nline1 = [int(x) for x in input().split()];\\n\\nlow = min(line1);\\nlows = [];\\n\\nfor i in range(0, len(line1)):\\n    if(line1[i]==low):\\n        lows.append(i);\\n\\ndists = [];\\n\\nfor i in range(1, len(lows)):\\n    dists.append((lows[i]-lows[i-1]) - 1);\\n    \\ndists.append( lows[0] + (len(line1)-1) - lows[-1] );\\n\\nprint((max(dists) + low * len(line1) ));\\n\\n            \\n\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\n\\nm = min(a)\\nmdist = 0\\n\\nfst, l = None, None\\nfor i in [i for i, x in enumerate(a) if x == m]:\\n    if fst is None:\\n        fst = l = i\\n    else:\\n        mdist = max(mdist, i - l - 1)\\n        l = i\\n\\nmdist = max(mdist, fst + (n - l) - 1)\\nprint(n*m + mdist)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmi=min(a)\\ncur=0\\nans=0\\nfor i in range(3*n):\\n    if(a[i%n]==mi):\\n     cur=0\\n    else:\\n     cur+=1\\n    ans=max(ans,cur)\\nprint(n*mi+ans)     \\n     \\n\", \"n = int(input())\\n\\ncolors = list(map(int, input().split()))\\n\\nm = min(colors)\\nlongest_sub = 0\\ncur_sub = 0\\npos = 0\\nbreak_on_min = False\\nwhile pos < n:\\n    if colors[pos] > m:\\n        cur_sub += 1\\n        if cur_sub > longest_sub:\\n            longest_sub = cur_sub\\n    else:\\n        cur_sub = 0\\n        if break_on_min:\\n            break\\n\\n    pos += 1\\n    if pos == n and cur_sub > 0:\\n        pos = 0\\n        break_on_min = True\\n\\nprint(m*n + longest_sub)\", \"n=int(input())\\na=list(map(int,input().split()))\\nl=len(a)\\nm=min(a)\\nmi=[]\\nb=0\\nfor i in range(l):\\n    if m==a[i]:\\n        mi.append(i)\\nif len(mi)>1:\\n    c=l-1-mi[-1]+mi[0]\\n    for i in range(len(mi)-1):\\n        b=mi[i+1]-mi[i]-1\\n        if b>c:\\n            c=b\\n    print(l*m+c)\\nelse:\\n    print((m+1)*l-1)\\n\", \"import sys\\n\\nn = int(input())\\npaint = list(map(int, input().split()))\\nlow, high = min(paint), max(paint)\\nif low == high:\\n    print(n * low)\\n    return\\n\\ncount, best = 0, 0\\nstart = paint.index(low)\\npos = start\\nwhile True:\\n    pos += 1\\n    if pos == n:\\n        pos = 0\\n    if pos == start:\\n        break\\n    if paint[pos] != low:\\n        count += 1\\n        best = max(best, count)\\n    else:\\n        count = 0\\nprint(n * low + best)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\n\\nmini = min(l)\\nfor i in range(n): l[i] -= mini\\nres = mini * n\\ntmp = 0\\nmaxi = 0\\nfor i in range(2 * n):\\n    if l[i % n] > 0:\\n        tmp += 1\\n        if tmp > maxi: maxi = tmp\\n    else: tmp = 0\\n    \\nprint(res + maxi)\", \"n=int(input())\\na=list(map(int,input().split()))\\nh=min(a)\\na=a+a\\npos=a.index(h)\\nw=0\\nfor i in range(pos+1,2*n):\\n    if a[i]==h:\\n        w=max(w,i-pos-1)\\n        pos=i\\nprint(h*n+w)\", \"n = int(input())\\ncol = list(map(int,input().split()))\\nlow = min(col)\\nstart = int()\\nstore = list()\\ndist = list()\\nfor i in range(len(col)):\\n    if col[i]==low:\\n        store.append(i+1)\\n        if i+1 in range(len(col)):\\n            start = col[i+1]\\n        else:\\n            start = col[0]\\n            \\nfor j in range(len(store)):\\n    if j==(len(store)-1):\\n        dist.append(n - store[-1] + store[0])\\n    else:\\n        dist.append(store[j+1]-store[j])\\n        \\nhigh = max(dist)\\n\\nif max(col) == min(col):\\n    print(max(col)*n)\\nelif len(store)==1:\\n    print(n*(low+1) -1)\\nelse:\\n    print(n*(low) +( high -1))\\n\\n\"]",
        "difficulty": "interview",
        "input": "2\n2 3\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/610/B"
    },
    {
        "id": 1634,
        "task_id": 1148,
        "test_case_id": 7,
        "question": "Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains a_{i} liters of paint of color i.\n\nVika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will start painting squares one by one from left to right, starting from the square number 1 and some arbitrary color. If the square was painted in color x, then the next square will be painted in color x + 1. In case of x = n, next square is painted in color 1. If there is no more paint of the color Vika wants to use now, then she stops.\n\nSquare is always painted in only one color, and it takes exactly 1 liter of paint. Your task is to calculate the maximum number of squares that might be painted, if Vika chooses right color to paint the first square.\n\n\n-----Input-----\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has.\n\nThe second line of the input contains a sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), where a_{i} is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that Vika has.\n\n\n-----Output-----\n\nThe only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.\n\n\n-----Examples-----\nInput\n5\n2 4 2 3 3\n\nOutput\n12\n\nInput\n3\n5 5 5\n\nOutput\n15\n\nInput\n6\n10 10 10 1 10 10\n\nOutput\n11\n\n\n\n-----Note-----\n\nIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.\n\nIn the second sample Vika can start to paint using any color.\n\nIn the third sample Vika should start painting using color number 5.",
        "solutions": "[\"am=0\\nx = int(input())\\nl = list(map(int, input().split(' ')))\\nm = min(l)\\nk = [i for i in range(x) if l[i] == m]\\nk.append(k[0]+x)\\nfor i in range(len(k)-1):\\n    am = max(am, k[i+1]-k[i])\\n\\nprint(m * x + am - 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmax_segment = 0\\ncount = 0\\na = a + a\\nfor i in range(len(a)):\\n    if a[i] == minimum:\\n        max_segment = max(count, max_segment)\\n        count = 0\\n    else:\\n        count += 1\\nmax_segment = max(count, max_segment)\\nprint(minimum * n + max_segment)\\n\", \"import itertools\\nimport math\\n\\nn = int(input())\\na = [int(x) for x in input().split()]\\namin = min(a)\\nb = list([x for x in enumerate(a) if x[1] == amin])\\nl = len(b)\\nk = max((b[(i+1) % l][0] - b[i][0] - 1)%n for i in range(l))\\nprint(amin*n + k)\\n\\n\\n\", \"n = int(input())\\nnumbers = input().split(\\\" \\\")\\nmi = 10000000007\\nfor i in range(len(numbers)):\\n    mi = min(mi, int(numbers[i]))\\nfor i in range(len(numbers)):\\n    numbers[i] = int(numbers[i])-mi\\n\\nret = 0\\nlength = 0\\nj=0\\nwhile numbers[j] > 0:\\n    j+=1\\nfor i in range(len(numbers)):\\n    if numbers[i] != 0:\\n        length+=1\\n    else:\\n        ret = max(ret, length)\\n        length = 0\\nret = max(ret, length+j)\\nprint(ret+n*mi)\\n\", \"n = int(input())\\nv = [int(x) for x in input().split()]\\nlow = min(v)\\n\\nres = low * n\\nv = [x-low for x in v]\\nv *= 2\\n\\nstart = -1\\nsol = 0\\n\\nfor i, x in enumerate(v):\\n    if x != 0:\\n        if start < 0:\\n            start = i\\n    else:\\n        if start >= 0:\\n            sol = max(sol, i-start)\\n            start = -1\\n\\nres += sol\\nprint(res)\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\nm = min(nums)\\n\\nx = [num > m for num in nums]\\nx = x + x\\n\\nleft = 0\\nright = 0\\nans = 0\\nwhile right < 2 * n:\\n    if left == right:\\n        right += 1\\n    elif not x[left]:\\n        left += 1\\n    elif x[right]:\\n        right += 1\\n    else:\\n        ans = max(ans, right - left)\\n        left = right\\nprint(n * m + ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nm = min(a)\\nb = [int(a[i] > m) for i in range(n)]\\nL = Max = 0\\nlast = -1\\nfor i in range(n):\\n    if b[i] == 0 and last != -1:\\n        Max = max(i - last, Max)\\n        last = -1\\n    elif last == -1 and b[i]:\\n        last = i\\nif last != -1:\\n    Max = max(n - last, Max)\\nif b[0] and b[-1]:\\n    L = 0; R = n - 1\\n    while b[L] and L < n - 1: L += 1\\n    while b[R] and L > 0: R -= 1\\n    L -= 1; R += 1\\n    Max = max(L + n - R + 1, Max)\\nans = m * n + Max\\nprint(ans)\\n\", \"x = int(input())\\ns = [int(i) for i in input().split()]\\nn = min(s)\\ncount = n*x\\nt = 0\\nfor i in range(x):\\n\\ts[i]-= n\\ns += s\\nm = 0\\nfor i in s:\\n\\tif not i:\\n\\t\\tm = max(m, t)\\n\\t\\tt = 0\\n\\telse:\\n\\t\\tt+=1\\nprint(count+m)\\n\", \"#Vika\\ncol=int(input())\\nll=list(map(int, input().split()))\\na1=col*min(ll)\\nm=min(ll)\\ns=[]\\nt=0\\nfor i in ll:\\n    t+=1\\n    if i==m:\\n        s.append(t-1)\\n        t=0\\ns[0]+=t\\nprint(a1+max(s))\\n\", \"import sys\\nif False:\\n\\tinp = open('B.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn = int(inp.readline())\\nliters = list(map(int, inp.readline().split()))\\nbefore = 0\\nafter = 0\\nlow = 10**9+10\\nmaxBetween = 0\\nbetween = 0\\nfor i in range(n):\\n\\tif liters[i] == low:\\n\\t\\tafter = -1\\n\\t\\tmaxBetween = max(maxBetween, between)\\n\\t\\tbetween = -1\\n\\tif liters[i] < low:\\n\\t\\tbefore = i\\n\\t\\tlow = liters[i]\\n\\t\\tafter = -1\\n\\t\\tbetween = -1\\n\\t\\tmaxBetween = 0\\n\\tafter += 1\\n\\tbetween += 1\\nans = low*n + max(maxBetween, before + after)\\nprint(ans)\\n\", \"N=int(input())\\nx=list(map(int,input().split()))\\nf=min(x)\\nans=N*f\\ncurlen=0\\nmaxlen=0\\nindex=0\\nwhile(index<2*N):\\n    if (x[index%N]==f):\\n        maxlen=max(maxlen,curlen)\\n        curlen=0\\n    else:\\n        curlen+=1\\n    index+=1\\nmaxlen=max(maxlen,curlen)\\nprint(ans+maxlen)\\n\", \"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    mi = min(a)\\n    d = 0\\n    p = n + a.index(mi)\\n    for i in range(n - 1, -1, -1):\\n        if a[i] == mi:\\n            p = i\\n        d = max(d, p - i)\\n    print(mi * n + d)\\n    \\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmaximum = 0\\nans = 0\\nind = 0\\nchallengers = []\\n\\nfor i in range(n):\\n    if a[i] != minimum and a[i - 1] == minimum:\\n        challengers.append(i)\\n        \\nwhile challengers:\\n    cnt = 0\\n    num = challengers.pop()\\n    similar = num\\n    while a[similar] != minimum:\\n        cnt += 1\\n        similar = (similar + 1) % n\\n    if cnt > maximum:\\n        maximum = cnt\\n        ind = num\\n    \\n\\nans = minimum * n\\nwhile a[ind] != minimum:\\n    ans += 1\\n    ind = (ind + 1) % n\\nprint(ans)\", \"__author__ = 'Utena'\\nn=int(input())\\ns=list(map(int,input().split()))\\nm=min(s)\\na=[]\\nb=[]\\nfor i in range(n):\\n    if s[i]==m:\\n        a.append(i)\\nfor t in range(len(a)-1):\\n    b.append(a[t+1]-a[t]-1)\\nb.append(a[0]-a[-1]-1+n)\\nprint(n*m+max(b))\", \"n = int(input())\\na = list(map(int, str(input()).split()))\\n\\n# print('n', n)\\n# print('a', a)\\n\\nminNumber = min(a)\\nsumA = minNumber * n\\n\\n# print('sumA', sumA)\\n\\nfor i in range(n):\\n    a[i] -= minNumber\\n\\n# print('a', a)\\n\\nhasGoRound = False\\nisCounting = False\\nindex = 0\\ncount = 0\\nmaxCount = 0\\nwhile True:\\n    # print('\\\\ta', a[index])\\n    if a[index] != 0 and not isCounting:\\n        isCounting = True\\n    if a[index] != 0 and isCounting:\\n        count += 1\\n    else:\\n        if maxCount < count:\\n            maxCount = count\\n        if hasGoRound:\\n            break\\n        isCounting = False\\n        count = 0\\n    index += 1\\n    if index == n:\\n        index = 0\\n        hasGoRound = True\\n# print('maxCount', maxCount)\\nprint(sumA + maxCount)\", \"def find_right(x, data):\\n    answer = -1\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            answer = i\\n    return answer\\n\\ndef find_left(x, data):\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            return i\\n\\n\\nn = int(input())\\ndata = list(map(int, input().split()))\\nmin1 = min(data)\\nindex_min_r = find_right(min1, data)\\nindex_min_l = find_left(min1, data)\\nk = data.count(min1)\\nc = index_min_r - index_min_l - 1\\nhelp = []\\nfor i in range(n):\\n    if data[i] == min1:\\n        help.append(i)\\nanswer = []\\nfor i in range(1, len(help)):\\n    answer.append(help[i] - help[i - 1] - 1)\\nanswer.append(n - (help[-1] - help[0]) - 1)\\nprint(max(answer) + n * min1)\", \"trash = int(input());\\nline1 = [int(x) for x in input().split()];\\n\\nlow = min(line1);\\nlows = [];\\n\\nfor i in range(0, len(line1)):\\n    if(line1[i]==low):\\n        lows.append(i);\\n\\ndists = [];\\n\\nfor i in range(1, len(lows)):\\n    dists.append((lows[i]-lows[i-1]) - 1);\\n    \\ndists.append( lows[0] + (len(line1)-1) - lows[-1] );\\n\\nprint((max(dists) + low * len(line1) ));\\n\\n            \\n\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\n\\nm = min(a)\\nmdist = 0\\n\\nfst, l = None, None\\nfor i in [i for i, x in enumerate(a) if x == m]:\\n    if fst is None:\\n        fst = l = i\\n    else:\\n        mdist = max(mdist, i - l - 1)\\n        l = i\\n\\nmdist = max(mdist, fst + (n - l) - 1)\\nprint(n*m + mdist)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmi=min(a)\\ncur=0\\nans=0\\nfor i in range(3*n):\\n    if(a[i%n]==mi):\\n     cur=0\\n    else:\\n     cur+=1\\n    ans=max(ans,cur)\\nprint(n*mi+ans)     \\n     \\n\", \"n = int(input())\\n\\ncolors = list(map(int, input().split()))\\n\\nm = min(colors)\\nlongest_sub = 0\\ncur_sub = 0\\npos = 0\\nbreak_on_min = False\\nwhile pos < n:\\n    if colors[pos] > m:\\n        cur_sub += 1\\n        if cur_sub > longest_sub:\\n            longest_sub = cur_sub\\n    else:\\n        cur_sub = 0\\n        if break_on_min:\\n            break\\n\\n    pos += 1\\n    if pos == n and cur_sub > 0:\\n        pos = 0\\n        break_on_min = True\\n\\nprint(m*n + longest_sub)\", \"n=int(input())\\na=list(map(int,input().split()))\\nl=len(a)\\nm=min(a)\\nmi=[]\\nb=0\\nfor i in range(l):\\n    if m==a[i]:\\n        mi.append(i)\\nif len(mi)>1:\\n    c=l-1-mi[-1]+mi[0]\\n    for i in range(len(mi)-1):\\n        b=mi[i+1]-mi[i]-1\\n        if b>c:\\n            c=b\\n    print(l*m+c)\\nelse:\\n    print((m+1)*l-1)\\n\", \"import sys\\n\\nn = int(input())\\npaint = list(map(int, input().split()))\\nlow, high = min(paint), max(paint)\\nif low == high:\\n    print(n * low)\\n    return\\n\\ncount, best = 0, 0\\nstart = paint.index(low)\\npos = start\\nwhile True:\\n    pos += 1\\n    if pos == n:\\n        pos = 0\\n    if pos == start:\\n        break\\n    if paint[pos] != low:\\n        count += 1\\n        best = max(best, count)\\n    else:\\n        count = 0\\nprint(n * low + best)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\n\\nmini = min(l)\\nfor i in range(n): l[i] -= mini\\nres = mini * n\\ntmp = 0\\nmaxi = 0\\nfor i in range(2 * n):\\n    if l[i % n] > 0:\\n        tmp += 1\\n        if tmp > maxi: maxi = tmp\\n    else: tmp = 0\\n    \\nprint(res + maxi)\", \"n=int(input())\\na=list(map(int,input().split()))\\nh=min(a)\\na=a+a\\npos=a.index(h)\\nw=0\\nfor i in range(pos+1,2*n):\\n    if a[i]==h:\\n        w=max(w,i-pos-1)\\n        pos=i\\nprint(h*n+w)\", \"n = int(input())\\ncol = list(map(int,input().split()))\\nlow = min(col)\\nstart = int()\\nstore = list()\\ndist = list()\\nfor i in range(len(col)):\\n    if col[i]==low:\\n        store.append(i+1)\\n        if i+1 in range(len(col)):\\n            start = col[i+1]\\n        else:\\n            start = col[0]\\n            \\nfor j in range(len(store)):\\n    if j==(len(store)-1):\\n        dist.append(n - store[-1] + store[0])\\n    else:\\n        dist.append(store[j+1]-store[j])\\n        \\nhigh = max(dist)\\n\\nif max(col) == min(col):\\n    print(max(col)*n)\\nelif len(store)==1:\\n    print(n*(low+1) -1)\\nelse:\\n    print(n*(low) +( high -1))\\n\\n\"]",
        "difficulty": "interview",
        "input": "2\n10 10\n",
        "output": "20\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/610/B"
    },
    {
        "id": 1635,
        "task_id": 1148,
        "test_case_id": 8,
        "question": "Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains a_{i} liters of paint of color i.\n\nVika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will start painting squares one by one from left to right, starting from the square number 1 and some arbitrary color. If the square was painted in color x, then the next square will be painted in color x + 1. In case of x = n, next square is painted in color 1. If there is no more paint of the color Vika wants to use now, then she stops.\n\nSquare is always painted in only one color, and it takes exactly 1 liter of paint. Your task is to calculate the maximum number of squares that might be painted, if Vika chooses right color to paint the first square.\n\n\n-----Input-----\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has.\n\nThe second line of the input contains a sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), where a_{i} is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that Vika has.\n\n\n-----Output-----\n\nThe only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.\n\n\n-----Examples-----\nInput\n5\n2 4 2 3 3\n\nOutput\n12\n\nInput\n3\n5 5 5\n\nOutput\n15\n\nInput\n6\n10 10 10 1 10 10\n\nOutput\n11\n\n\n\n-----Note-----\n\nIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.\n\nIn the second sample Vika can start to paint using any color.\n\nIn the third sample Vika should start painting using color number 5.",
        "solutions": "[\"am=0\\nx = int(input())\\nl = list(map(int, input().split(' ')))\\nm = min(l)\\nk = [i for i in range(x) if l[i] == m]\\nk.append(k[0]+x)\\nfor i in range(len(k)-1):\\n    am = max(am, k[i+1]-k[i])\\n\\nprint(m * x + am - 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmax_segment = 0\\ncount = 0\\na = a + a\\nfor i in range(len(a)):\\n    if a[i] == minimum:\\n        max_segment = max(count, max_segment)\\n        count = 0\\n    else:\\n        count += 1\\nmax_segment = max(count, max_segment)\\nprint(minimum * n + max_segment)\\n\", \"import itertools\\nimport math\\n\\nn = int(input())\\na = [int(x) for x in input().split()]\\namin = min(a)\\nb = list([x for x in enumerate(a) if x[1] == amin])\\nl = len(b)\\nk = max((b[(i+1) % l][0] - b[i][0] - 1)%n for i in range(l))\\nprint(amin*n + k)\\n\\n\\n\", \"n = int(input())\\nnumbers = input().split(\\\" \\\")\\nmi = 10000000007\\nfor i in range(len(numbers)):\\n    mi = min(mi, int(numbers[i]))\\nfor i in range(len(numbers)):\\n    numbers[i] = int(numbers[i])-mi\\n\\nret = 0\\nlength = 0\\nj=0\\nwhile numbers[j] > 0:\\n    j+=1\\nfor i in range(len(numbers)):\\n    if numbers[i] != 0:\\n        length+=1\\n    else:\\n        ret = max(ret, length)\\n        length = 0\\nret = max(ret, length+j)\\nprint(ret+n*mi)\\n\", \"n = int(input())\\nv = [int(x) for x in input().split()]\\nlow = min(v)\\n\\nres = low * n\\nv = [x-low for x in v]\\nv *= 2\\n\\nstart = -1\\nsol = 0\\n\\nfor i, x in enumerate(v):\\n    if x != 0:\\n        if start < 0:\\n            start = i\\n    else:\\n        if start >= 0:\\n            sol = max(sol, i-start)\\n            start = -1\\n\\nres += sol\\nprint(res)\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\nm = min(nums)\\n\\nx = [num > m for num in nums]\\nx = x + x\\n\\nleft = 0\\nright = 0\\nans = 0\\nwhile right < 2 * n:\\n    if left == right:\\n        right += 1\\n    elif not x[left]:\\n        left += 1\\n    elif x[right]:\\n        right += 1\\n    else:\\n        ans = max(ans, right - left)\\n        left = right\\nprint(n * m + ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nm = min(a)\\nb = [int(a[i] > m) for i in range(n)]\\nL = Max = 0\\nlast = -1\\nfor i in range(n):\\n    if b[i] == 0 and last != -1:\\n        Max = max(i - last, Max)\\n        last = -1\\n    elif last == -1 and b[i]:\\n        last = i\\nif last != -1:\\n    Max = max(n - last, Max)\\nif b[0] and b[-1]:\\n    L = 0; R = n - 1\\n    while b[L] and L < n - 1: L += 1\\n    while b[R] and L > 0: R -= 1\\n    L -= 1; R += 1\\n    Max = max(L + n - R + 1, Max)\\nans = m * n + Max\\nprint(ans)\\n\", \"x = int(input())\\ns = [int(i) for i in input().split()]\\nn = min(s)\\ncount = n*x\\nt = 0\\nfor i in range(x):\\n\\ts[i]-= n\\ns += s\\nm = 0\\nfor i in s:\\n\\tif not i:\\n\\t\\tm = max(m, t)\\n\\t\\tt = 0\\n\\telse:\\n\\t\\tt+=1\\nprint(count+m)\\n\", \"#Vika\\ncol=int(input())\\nll=list(map(int, input().split()))\\na1=col*min(ll)\\nm=min(ll)\\ns=[]\\nt=0\\nfor i in ll:\\n    t+=1\\n    if i==m:\\n        s.append(t-1)\\n        t=0\\ns[0]+=t\\nprint(a1+max(s))\\n\", \"import sys\\nif False:\\n\\tinp = open('B.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn = int(inp.readline())\\nliters = list(map(int, inp.readline().split()))\\nbefore = 0\\nafter = 0\\nlow = 10**9+10\\nmaxBetween = 0\\nbetween = 0\\nfor i in range(n):\\n\\tif liters[i] == low:\\n\\t\\tafter = -1\\n\\t\\tmaxBetween = max(maxBetween, between)\\n\\t\\tbetween = -1\\n\\tif liters[i] < low:\\n\\t\\tbefore = i\\n\\t\\tlow = liters[i]\\n\\t\\tafter = -1\\n\\t\\tbetween = -1\\n\\t\\tmaxBetween = 0\\n\\tafter += 1\\n\\tbetween += 1\\nans = low*n + max(maxBetween, before + after)\\nprint(ans)\\n\", \"N=int(input())\\nx=list(map(int,input().split()))\\nf=min(x)\\nans=N*f\\ncurlen=0\\nmaxlen=0\\nindex=0\\nwhile(index<2*N):\\n    if (x[index%N]==f):\\n        maxlen=max(maxlen,curlen)\\n        curlen=0\\n    else:\\n        curlen+=1\\n    index+=1\\nmaxlen=max(maxlen,curlen)\\nprint(ans+maxlen)\\n\", \"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    mi = min(a)\\n    d = 0\\n    p = n + a.index(mi)\\n    for i in range(n - 1, -1, -1):\\n        if a[i] == mi:\\n            p = i\\n        d = max(d, p - i)\\n    print(mi * n + d)\\n    \\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmaximum = 0\\nans = 0\\nind = 0\\nchallengers = []\\n\\nfor i in range(n):\\n    if a[i] != minimum and a[i - 1] == minimum:\\n        challengers.append(i)\\n        \\nwhile challengers:\\n    cnt = 0\\n    num = challengers.pop()\\n    similar = num\\n    while a[similar] != minimum:\\n        cnt += 1\\n        similar = (similar + 1) % n\\n    if cnt > maximum:\\n        maximum = cnt\\n        ind = num\\n    \\n\\nans = minimum * n\\nwhile a[ind] != minimum:\\n    ans += 1\\n    ind = (ind + 1) % n\\nprint(ans)\", \"__author__ = 'Utena'\\nn=int(input())\\ns=list(map(int,input().split()))\\nm=min(s)\\na=[]\\nb=[]\\nfor i in range(n):\\n    if s[i]==m:\\n        a.append(i)\\nfor t in range(len(a)-1):\\n    b.append(a[t+1]-a[t]-1)\\nb.append(a[0]-a[-1]-1+n)\\nprint(n*m+max(b))\", \"n = int(input())\\na = list(map(int, str(input()).split()))\\n\\n# print('n', n)\\n# print('a', a)\\n\\nminNumber = min(a)\\nsumA = minNumber * n\\n\\n# print('sumA', sumA)\\n\\nfor i in range(n):\\n    a[i] -= minNumber\\n\\n# print('a', a)\\n\\nhasGoRound = False\\nisCounting = False\\nindex = 0\\ncount = 0\\nmaxCount = 0\\nwhile True:\\n    # print('\\\\ta', a[index])\\n    if a[index] != 0 and not isCounting:\\n        isCounting = True\\n    if a[index] != 0 and isCounting:\\n        count += 1\\n    else:\\n        if maxCount < count:\\n            maxCount = count\\n        if hasGoRound:\\n            break\\n        isCounting = False\\n        count = 0\\n    index += 1\\n    if index == n:\\n        index = 0\\n        hasGoRound = True\\n# print('maxCount', maxCount)\\nprint(sumA + maxCount)\", \"def find_right(x, data):\\n    answer = -1\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            answer = i\\n    return answer\\n\\ndef find_left(x, data):\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            return i\\n\\n\\nn = int(input())\\ndata = list(map(int, input().split()))\\nmin1 = min(data)\\nindex_min_r = find_right(min1, data)\\nindex_min_l = find_left(min1, data)\\nk = data.count(min1)\\nc = index_min_r - index_min_l - 1\\nhelp = []\\nfor i in range(n):\\n    if data[i] == min1:\\n        help.append(i)\\nanswer = []\\nfor i in range(1, len(help)):\\n    answer.append(help[i] - help[i - 1] - 1)\\nanswer.append(n - (help[-1] - help[0]) - 1)\\nprint(max(answer) + n * min1)\", \"trash = int(input());\\nline1 = [int(x) for x in input().split()];\\n\\nlow = min(line1);\\nlows = [];\\n\\nfor i in range(0, len(line1)):\\n    if(line1[i]==low):\\n        lows.append(i);\\n\\ndists = [];\\n\\nfor i in range(1, len(lows)):\\n    dists.append((lows[i]-lows[i-1]) - 1);\\n    \\ndists.append( lows[0] + (len(line1)-1) - lows[-1] );\\n\\nprint((max(dists) + low * len(line1) ));\\n\\n            \\n\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\n\\nm = min(a)\\nmdist = 0\\n\\nfst, l = None, None\\nfor i in [i for i, x in enumerate(a) if x == m]:\\n    if fst is None:\\n        fst = l = i\\n    else:\\n        mdist = max(mdist, i - l - 1)\\n        l = i\\n\\nmdist = max(mdist, fst + (n - l) - 1)\\nprint(n*m + mdist)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmi=min(a)\\ncur=0\\nans=0\\nfor i in range(3*n):\\n    if(a[i%n]==mi):\\n     cur=0\\n    else:\\n     cur+=1\\n    ans=max(ans,cur)\\nprint(n*mi+ans)     \\n     \\n\", \"n = int(input())\\n\\ncolors = list(map(int, input().split()))\\n\\nm = min(colors)\\nlongest_sub = 0\\ncur_sub = 0\\npos = 0\\nbreak_on_min = False\\nwhile pos < n:\\n    if colors[pos] > m:\\n        cur_sub += 1\\n        if cur_sub > longest_sub:\\n            longest_sub = cur_sub\\n    else:\\n        cur_sub = 0\\n        if break_on_min:\\n            break\\n\\n    pos += 1\\n    if pos == n and cur_sub > 0:\\n        pos = 0\\n        break_on_min = True\\n\\nprint(m*n + longest_sub)\", \"n=int(input())\\na=list(map(int,input().split()))\\nl=len(a)\\nm=min(a)\\nmi=[]\\nb=0\\nfor i in range(l):\\n    if m==a[i]:\\n        mi.append(i)\\nif len(mi)>1:\\n    c=l-1-mi[-1]+mi[0]\\n    for i in range(len(mi)-1):\\n        b=mi[i+1]-mi[i]-1\\n        if b>c:\\n            c=b\\n    print(l*m+c)\\nelse:\\n    print((m+1)*l-1)\\n\", \"import sys\\n\\nn = int(input())\\npaint = list(map(int, input().split()))\\nlow, high = min(paint), max(paint)\\nif low == high:\\n    print(n * low)\\n    return\\n\\ncount, best = 0, 0\\nstart = paint.index(low)\\npos = start\\nwhile True:\\n    pos += 1\\n    if pos == n:\\n        pos = 0\\n    if pos == start:\\n        break\\n    if paint[pos] != low:\\n        count += 1\\n        best = max(best, count)\\n    else:\\n        count = 0\\nprint(n * low + best)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\n\\nmini = min(l)\\nfor i in range(n): l[i] -= mini\\nres = mini * n\\ntmp = 0\\nmaxi = 0\\nfor i in range(2 * n):\\n    if l[i % n] > 0:\\n        tmp += 1\\n        if tmp > maxi: maxi = tmp\\n    else: tmp = 0\\n    \\nprint(res + maxi)\", \"n=int(input())\\na=list(map(int,input().split()))\\nh=min(a)\\na=a+a\\npos=a.index(h)\\nw=0\\nfor i in range(pos+1,2*n):\\n    if a[i]==h:\\n        w=max(w,i-pos-1)\\n        pos=i\\nprint(h*n+w)\", \"n = int(input())\\ncol = list(map(int,input().split()))\\nlow = min(col)\\nstart = int()\\nstore = list()\\ndist = list()\\nfor i in range(len(col)):\\n    if col[i]==low:\\n        store.append(i+1)\\n        if i+1 in range(len(col)):\\n            start = col[i+1]\\n        else:\\n            start = col[0]\\n            \\nfor j in range(len(store)):\\n    if j==(len(store)-1):\\n        dist.append(n - store[-1] + store[0])\\n    else:\\n        dist.append(store[j+1]-store[j])\\n        \\nhigh = max(dist)\\n\\nif max(col) == min(col):\\n    print(max(col)*n)\\nelif len(store)==1:\\n    print(n*(low+1) -1)\\nelse:\\n    print(n*(low) +( high -1))\\n\\n\"]",
        "difficulty": "interview",
        "input": "2\n1111 1110\n",
        "output": "2221\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/610/B"
    },
    {
        "id": 1636,
        "task_id": 1148,
        "test_case_id": 9,
        "question": "Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains a_{i} liters of paint of color i.\n\nVika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will start painting squares one by one from left to right, starting from the square number 1 and some arbitrary color. If the square was painted in color x, then the next square will be painted in color x + 1. In case of x = n, next square is painted in color 1. If there is no more paint of the color Vika wants to use now, then she stops.\n\nSquare is always painted in only one color, and it takes exactly 1 liter of paint. Your task is to calculate the maximum number of squares that might be painted, if Vika chooses right color to paint the first square.\n\n\n-----Input-----\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has.\n\nThe second line of the input contains a sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), where a_{i} is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that Vika has.\n\n\n-----Output-----\n\nThe only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.\n\n\n-----Examples-----\nInput\n5\n2 4 2 3 3\n\nOutput\n12\n\nInput\n3\n5 5 5\n\nOutput\n15\n\nInput\n6\n10 10 10 1 10 10\n\nOutput\n11\n\n\n\n-----Note-----\n\nIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.\n\nIn the second sample Vika can start to paint using any color.\n\nIn the third sample Vika should start painting using color number 5.",
        "solutions": "[\"am=0\\nx = int(input())\\nl = list(map(int, input().split(' ')))\\nm = min(l)\\nk = [i for i in range(x) if l[i] == m]\\nk.append(k[0]+x)\\nfor i in range(len(k)-1):\\n    am = max(am, k[i+1]-k[i])\\n\\nprint(m * x + am - 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmax_segment = 0\\ncount = 0\\na = a + a\\nfor i in range(len(a)):\\n    if a[i] == minimum:\\n        max_segment = max(count, max_segment)\\n        count = 0\\n    else:\\n        count += 1\\nmax_segment = max(count, max_segment)\\nprint(minimum * n + max_segment)\\n\", \"import itertools\\nimport math\\n\\nn = int(input())\\na = [int(x) for x in input().split()]\\namin = min(a)\\nb = list([x for x in enumerate(a) if x[1] == amin])\\nl = len(b)\\nk = max((b[(i+1) % l][0] - b[i][0] - 1)%n for i in range(l))\\nprint(amin*n + k)\\n\\n\\n\", \"n = int(input())\\nnumbers = input().split(\\\" \\\")\\nmi = 10000000007\\nfor i in range(len(numbers)):\\n    mi = min(mi, int(numbers[i]))\\nfor i in range(len(numbers)):\\n    numbers[i] = int(numbers[i])-mi\\n\\nret = 0\\nlength = 0\\nj=0\\nwhile numbers[j] > 0:\\n    j+=1\\nfor i in range(len(numbers)):\\n    if numbers[i] != 0:\\n        length+=1\\n    else:\\n        ret = max(ret, length)\\n        length = 0\\nret = max(ret, length+j)\\nprint(ret+n*mi)\\n\", \"n = int(input())\\nv = [int(x) for x in input().split()]\\nlow = min(v)\\n\\nres = low * n\\nv = [x-low for x in v]\\nv *= 2\\n\\nstart = -1\\nsol = 0\\n\\nfor i, x in enumerate(v):\\n    if x != 0:\\n        if start < 0:\\n            start = i\\n    else:\\n        if start >= 0:\\n            sol = max(sol, i-start)\\n            start = -1\\n\\nres += sol\\nprint(res)\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\nm = min(nums)\\n\\nx = [num > m for num in nums]\\nx = x + x\\n\\nleft = 0\\nright = 0\\nans = 0\\nwhile right < 2 * n:\\n    if left == right:\\n        right += 1\\n    elif not x[left]:\\n        left += 1\\n    elif x[right]:\\n        right += 1\\n    else:\\n        ans = max(ans, right - left)\\n        left = right\\nprint(n * m + ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nm = min(a)\\nb = [int(a[i] > m) for i in range(n)]\\nL = Max = 0\\nlast = -1\\nfor i in range(n):\\n    if b[i] == 0 and last != -1:\\n        Max = max(i - last, Max)\\n        last = -1\\n    elif last == -1 and b[i]:\\n        last = i\\nif last != -1:\\n    Max = max(n - last, Max)\\nif b[0] and b[-1]:\\n    L = 0; R = n - 1\\n    while b[L] and L < n - 1: L += 1\\n    while b[R] and L > 0: R -= 1\\n    L -= 1; R += 1\\n    Max = max(L + n - R + 1, Max)\\nans = m * n + Max\\nprint(ans)\\n\", \"x = int(input())\\ns = [int(i) for i in input().split()]\\nn = min(s)\\ncount = n*x\\nt = 0\\nfor i in range(x):\\n\\ts[i]-= n\\ns += s\\nm = 0\\nfor i in s:\\n\\tif not i:\\n\\t\\tm = max(m, t)\\n\\t\\tt = 0\\n\\telse:\\n\\t\\tt+=1\\nprint(count+m)\\n\", \"#Vika\\ncol=int(input())\\nll=list(map(int, input().split()))\\na1=col*min(ll)\\nm=min(ll)\\ns=[]\\nt=0\\nfor i in ll:\\n    t+=1\\n    if i==m:\\n        s.append(t-1)\\n        t=0\\ns[0]+=t\\nprint(a1+max(s))\\n\", \"import sys\\nif False:\\n\\tinp = open('B.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn = int(inp.readline())\\nliters = list(map(int, inp.readline().split()))\\nbefore = 0\\nafter = 0\\nlow = 10**9+10\\nmaxBetween = 0\\nbetween = 0\\nfor i in range(n):\\n\\tif liters[i] == low:\\n\\t\\tafter = -1\\n\\t\\tmaxBetween = max(maxBetween, between)\\n\\t\\tbetween = -1\\n\\tif liters[i] < low:\\n\\t\\tbefore = i\\n\\t\\tlow = liters[i]\\n\\t\\tafter = -1\\n\\t\\tbetween = -1\\n\\t\\tmaxBetween = 0\\n\\tafter += 1\\n\\tbetween += 1\\nans = low*n + max(maxBetween, before + after)\\nprint(ans)\\n\", \"N=int(input())\\nx=list(map(int,input().split()))\\nf=min(x)\\nans=N*f\\ncurlen=0\\nmaxlen=0\\nindex=0\\nwhile(index<2*N):\\n    if (x[index%N]==f):\\n        maxlen=max(maxlen,curlen)\\n        curlen=0\\n    else:\\n        curlen+=1\\n    index+=1\\nmaxlen=max(maxlen,curlen)\\nprint(ans+maxlen)\\n\", \"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    mi = min(a)\\n    d = 0\\n    p = n + a.index(mi)\\n    for i in range(n - 1, -1, -1):\\n        if a[i] == mi:\\n            p = i\\n        d = max(d, p - i)\\n    print(mi * n + d)\\n    \\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmaximum = 0\\nans = 0\\nind = 0\\nchallengers = []\\n\\nfor i in range(n):\\n    if a[i] != minimum and a[i - 1] == minimum:\\n        challengers.append(i)\\n        \\nwhile challengers:\\n    cnt = 0\\n    num = challengers.pop()\\n    similar = num\\n    while a[similar] != minimum:\\n        cnt += 1\\n        similar = (similar + 1) % n\\n    if cnt > maximum:\\n        maximum = cnt\\n        ind = num\\n    \\n\\nans = minimum * n\\nwhile a[ind] != minimum:\\n    ans += 1\\n    ind = (ind + 1) % n\\nprint(ans)\", \"__author__ = 'Utena'\\nn=int(input())\\ns=list(map(int,input().split()))\\nm=min(s)\\na=[]\\nb=[]\\nfor i in range(n):\\n    if s[i]==m:\\n        a.append(i)\\nfor t in range(len(a)-1):\\n    b.append(a[t+1]-a[t]-1)\\nb.append(a[0]-a[-1]-1+n)\\nprint(n*m+max(b))\", \"n = int(input())\\na = list(map(int, str(input()).split()))\\n\\n# print('n', n)\\n# print('a', a)\\n\\nminNumber = min(a)\\nsumA = minNumber * n\\n\\n# print('sumA', sumA)\\n\\nfor i in range(n):\\n    a[i] -= minNumber\\n\\n# print('a', a)\\n\\nhasGoRound = False\\nisCounting = False\\nindex = 0\\ncount = 0\\nmaxCount = 0\\nwhile True:\\n    # print('\\\\ta', a[index])\\n    if a[index] != 0 and not isCounting:\\n        isCounting = True\\n    if a[index] != 0 and isCounting:\\n        count += 1\\n    else:\\n        if maxCount < count:\\n            maxCount = count\\n        if hasGoRound:\\n            break\\n        isCounting = False\\n        count = 0\\n    index += 1\\n    if index == n:\\n        index = 0\\n        hasGoRound = True\\n# print('maxCount', maxCount)\\nprint(sumA + maxCount)\", \"def find_right(x, data):\\n    answer = -1\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            answer = i\\n    return answer\\n\\ndef find_left(x, data):\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            return i\\n\\n\\nn = int(input())\\ndata = list(map(int, input().split()))\\nmin1 = min(data)\\nindex_min_r = find_right(min1, data)\\nindex_min_l = find_left(min1, data)\\nk = data.count(min1)\\nc = index_min_r - index_min_l - 1\\nhelp = []\\nfor i in range(n):\\n    if data[i] == min1:\\n        help.append(i)\\nanswer = []\\nfor i in range(1, len(help)):\\n    answer.append(help[i] - help[i - 1] - 1)\\nanswer.append(n - (help[-1] - help[0]) - 1)\\nprint(max(answer) + n * min1)\", \"trash = int(input());\\nline1 = [int(x) for x in input().split()];\\n\\nlow = min(line1);\\nlows = [];\\n\\nfor i in range(0, len(line1)):\\n    if(line1[i]==low):\\n        lows.append(i);\\n\\ndists = [];\\n\\nfor i in range(1, len(lows)):\\n    dists.append((lows[i]-lows[i-1]) - 1);\\n    \\ndists.append( lows[0] + (len(line1)-1) - lows[-1] );\\n\\nprint((max(dists) + low * len(line1) ));\\n\\n            \\n\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\n\\nm = min(a)\\nmdist = 0\\n\\nfst, l = None, None\\nfor i in [i for i, x in enumerate(a) if x == m]:\\n    if fst is None:\\n        fst = l = i\\n    else:\\n        mdist = max(mdist, i - l - 1)\\n        l = i\\n\\nmdist = max(mdist, fst + (n - l) - 1)\\nprint(n*m + mdist)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmi=min(a)\\ncur=0\\nans=0\\nfor i in range(3*n):\\n    if(a[i%n]==mi):\\n     cur=0\\n    else:\\n     cur+=1\\n    ans=max(ans,cur)\\nprint(n*mi+ans)     \\n     \\n\", \"n = int(input())\\n\\ncolors = list(map(int, input().split()))\\n\\nm = min(colors)\\nlongest_sub = 0\\ncur_sub = 0\\npos = 0\\nbreak_on_min = False\\nwhile pos < n:\\n    if colors[pos] > m:\\n        cur_sub += 1\\n        if cur_sub > longest_sub:\\n            longest_sub = cur_sub\\n    else:\\n        cur_sub = 0\\n        if break_on_min:\\n            break\\n\\n    pos += 1\\n    if pos == n and cur_sub > 0:\\n        pos = 0\\n        break_on_min = True\\n\\nprint(m*n + longest_sub)\", \"n=int(input())\\na=list(map(int,input().split()))\\nl=len(a)\\nm=min(a)\\nmi=[]\\nb=0\\nfor i in range(l):\\n    if m==a[i]:\\n        mi.append(i)\\nif len(mi)>1:\\n    c=l-1-mi[-1]+mi[0]\\n    for i in range(len(mi)-1):\\n        b=mi[i+1]-mi[i]-1\\n        if b>c:\\n            c=b\\n    print(l*m+c)\\nelse:\\n    print((m+1)*l-1)\\n\", \"import sys\\n\\nn = int(input())\\npaint = list(map(int, input().split()))\\nlow, high = min(paint), max(paint)\\nif low == high:\\n    print(n * low)\\n    return\\n\\ncount, best = 0, 0\\nstart = paint.index(low)\\npos = start\\nwhile True:\\n    pos += 1\\n    if pos == n:\\n        pos = 0\\n    if pos == start:\\n        break\\n    if paint[pos] != low:\\n        count += 1\\n        best = max(best, count)\\n    else:\\n        count = 0\\nprint(n * low + best)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\n\\nmini = min(l)\\nfor i in range(n): l[i] -= mini\\nres = mini * n\\ntmp = 0\\nmaxi = 0\\nfor i in range(2 * n):\\n    if l[i % n] > 0:\\n        tmp += 1\\n        if tmp > maxi: maxi = tmp\\n    else: tmp = 0\\n    \\nprint(res + maxi)\", \"n=int(input())\\na=list(map(int,input().split()))\\nh=min(a)\\na=a+a\\npos=a.index(h)\\nw=0\\nfor i in range(pos+1,2*n):\\n    if a[i]==h:\\n        w=max(w,i-pos-1)\\n        pos=i\\nprint(h*n+w)\", \"n = int(input())\\ncol = list(map(int,input().split()))\\nlow = min(col)\\nstart = int()\\nstore = list()\\ndist = list()\\nfor i in range(len(col)):\\n    if col[i]==low:\\n        store.append(i+1)\\n        if i+1 in range(len(col)):\\n            start = col[i+1]\\n        else:\\n            start = col[0]\\n            \\nfor j in range(len(store)):\\n    if j==(len(store)-1):\\n        dist.append(n - store[-1] + store[0])\\n    else:\\n        dist.append(store[j+1]-store[j])\\n        \\nhigh = max(dist)\\n\\nif max(col) == min(col):\\n    print(max(col)*n)\\nelif len(store)==1:\\n    print(n*(low+1) -1)\\nelse:\\n    print(n*(low) +( high -1))\\n\\n\"]",
        "difficulty": "interview",
        "input": "3\n100 101 100\n",
        "output": "301\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/610/B"
    },
    {
        "id": 1637,
        "task_id": 1148,
        "test_case_id": 11,
        "question": "Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains a_{i} liters of paint of color i.\n\nVika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will start painting squares one by one from left to right, starting from the square number 1 and some arbitrary color. If the square was painted in color x, then the next square will be painted in color x + 1. In case of x = n, next square is painted in color 1. If there is no more paint of the color Vika wants to use now, then she stops.\n\nSquare is always painted in only one color, and it takes exactly 1 liter of paint. Your task is to calculate the maximum number of squares that might be painted, if Vika chooses right color to paint the first square.\n\n\n-----Input-----\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has.\n\nThe second line of the input contains a sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), where a_{i} is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that Vika has.\n\n\n-----Output-----\n\nThe only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.\n\n\n-----Examples-----\nInput\n5\n2 4 2 3 3\n\nOutput\n12\n\nInput\n3\n5 5 5\n\nOutput\n15\n\nInput\n6\n10 10 10 1 10 10\n\nOutput\n11\n\n\n\n-----Note-----\n\nIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.\n\nIn the second sample Vika can start to paint using any color.\n\nIn the third sample Vika should start painting using color number 5.",
        "solutions": "[\"am=0\\nx = int(input())\\nl = list(map(int, input().split(' ')))\\nm = min(l)\\nk = [i for i in range(x) if l[i] == m]\\nk.append(k[0]+x)\\nfor i in range(len(k)-1):\\n    am = max(am, k[i+1]-k[i])\\n\\nprint(m * x + am - 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmax_segment = 0\\ncount = 0\\na = a + a\\nfor i in range(len(a)):\\n    if a[i] == minimum:\\n        max_segment = max(count, max_segment)\\n        count = 0\\n    else:\\n        count += 1\\nmax_segment = max(count, max_segment)\\nprint(minimum * n + max_segment)\\n\", \"import itertools\\nimport math\\n\\nn = int(input())\\na = [int(x) for x in input().split()]\\namin = min(a)\\nb = list([x for x in enumerate(a) if x[1] == amin])\\nl = len(b)\\nk = max((b[(i+1) % l][0] - b[i][0] - 1)%n for i in range(l))\\nprint(amin*n + k)\\n\\n\\n\", \"n = int(input())\\nnumbers = input().split(\\\" \\\")\\nmi = 10000000007\\nfor i in range(len(numbers)):\\n    mi = min(mi, int(numbers[i]))\\nfor i in range(len(numbers)):\\n    numbers[i] = int(numbers[i])-mi\\n\\nret = 0\\nlength = 0\\nj=0\\nwhile numbers[j] > 0:\\n    j+=1\\nfor i in range(len(numbers)):\\n    if numbers[i] != 0:\\n        length+=1\\n    else:\\n        ret = max(ret, length)\\n        length = 0\\nret = max(ret, length+j)\\nprint(ret+n*mi)\\n\", \"n = int(input())\\nv = [int(x) for x in input().split()]\\nlow = min(v)\\n\\nres = low * n\\nv = [x-low for x in v]\\nv *= 2\\n\\nstart = -1\\nsol = 0\\n\\nfor i, x in enumerate(v):\\n    if x != 0:\\n        if start < 0:\\n            start = i\\n    else:\\n        if start >= 0:\\n            sol = max(sol, i-start)\\n            start = -1\\n\\nres += sol\\nprint(res)\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\nm = min(nums)\\n\\nx = [num > m for num in nums]\\nx = x + x\\n\\nleft = 0\\nright = 0\\nans = 0\\nwhile right < 2 * n:\\n    if left == right:\\n        right += 1\\n    elif not x[left]:\\n        left += 1\\n    elif x[right]:\\n        right += 1\\n    else:\\n        ans = max(ans, right - left)\\n        left = right\\nprint(n * m + ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\nm = min(a)\\nb = [int(a[i] > m) for i in range(n)]\\nL = Max = 0\\nlast = -1\\nfor i in range(n):\\n    if b[i] == 0 and last != -1:\\n        Max = max(i - last, Max)\\n        last = -1\\n    elif last == -1 and b[i]:\\n        last = i\\nif last != -1:\\n    Max = max(n - last, Max)\\nif b[0] and b[-1]:\\n    L = 0; R = n - 1\\n    while b[L] and L < n - 1: L += 1\\n    while b[R] and L > 0: R -= 1\\n    L -= 1; R += 1\\n    Max = max(L + n - R + 1, Max)\\nans = m * n + Max\\nprint(ans)\\n\", \"x = int(input())\\ns = [int(i) for i in input().split()]\\nn = min(s)\\ncount = n*x\\nt = 0\\nfor i in range(x):\\n\\ts[i]-= n\\ns += s\\nm = 0\\nfor i in s:\\n\\tif not i:\\n\\t\\tm = max(m, t)\\n\\t\\tt = 0\\n\\telse:\\n\\t\\tt+=1\\nprint(count+m)\\n\", \"#Vika\\ncol=int(input())\\nll=list(map(int, input().split()))\\na1=col*min(ll)\\nm=min(ll)\\ns=[]\\nt=0\\nfor i in ll:\\n    t+=1\\n    if i==m:\\n        s.append(t-1)\\n        t=0\\ns[0]+=t\\nprint(a1+max(s))\\n\", \"import sys\\nif False:\\n\\tinp = open('B.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn = int(inp.readline())\\nliters = list(map(int, inp.readline().split()))\\nbefore = 0\\nafter = 0\\nlow = 10**9+10\\nmaxBetween = 0\\nbetween = 0\\nfor i in range(n):\\n\\tif liters[i] == low:\\n\\t\\tafter = -1\\n\\t\\tmaxBetween = max(maxBetween, between)\\n\\t\\tbetween = -1\\n\\tif liters[i] < low:\\n\\t\\tbefore = i\\n\\t\\tlow = liters[i]\\n\\t\\tafter = -1\\n\\t\\tbetween = -1\\n\\t\\tmaxBetween = 0\\n\\tafter += 1\\n\\tbetween += 1\\nans = low*n + max(maxBetween, before + after)\\nprint(ans)\\n\", \"N=int(input())\\nx=list(map(int,input().split()))\\nf=min(x)\\nans=N*f\\ncurlen=0\\nmaxlen=0\\nindex=0\\nwhile(index<2*N):\\n    if (x[index%N]==f):\\n        maxlen=max(maxlen,curlen)\\n        curlen=0\\n    else:\\n        curlen+=1\\n    index+=1\\nmaxlen=max(maxlen,curlen)\\nprint(ans+maxlen)\\n\", \"def main():\\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    \\n    mi = min(a)\\n    d = 0\\n    p = n + a.index(mi)\\n    for i in range(n - 1, -1, -1):\\n        if a[i] == mi:\\n            p = i\\n        d = max(d, p - i)\\n    print(mi * n + d)\\n    \\n    \\n    \\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\nminimum = min(a)\\nmaximum = 0\\nans = 0\\nind = 0\\nchallengers = []\\n\\nfor i in range(n):\\n    if a[i] != minimum and a[i - 1] == minimum:\\n        challengers.append(i)\\n        \\nwhile challengers:\\n    cnt = 0\\n    num = challengers.pop()\\n    similar = num\\n    while a[similar] != minimum:\\n        cnt += 1\\n        similar = (similar + 1) % n\\n    if cnt > maximum:\\n        maximum = cnt\\n        ind = num\\n    \\n\\nans = minimum * n\\nwhile a[ind] != minimum:\\n    ans += 1\\n    ind = (ind + 1) % n\\nprint(ans)\", \"__author__ = 'Utena'\\nn=int(input())\\ns=list(map(int,input().split()))\\nm=min(s)\\na=[]\\nb=[]\\nfor i in range(n):\\n    if s[i]==m:\\n        a.append(i)\\nfor t in range(len(a)-1):\\n    b.append(a[t+1]-a[t]-1)\\nb.append(a[0]-a[-1]-1+n)\\nprint(n*m+max(b))\", \"n = int(input())\\na = list(map(int, str(input()).split()))\\n\\n# print('n', n)\\n# print('a', a)\\n\\nminNumber = min(a)\\nsumA = minNumber * n\\n\\n# print('sumA', sumA)\\n\\nfor i in range(n):\\n    a[i] -= minNumber\\n\\n# print('a', a)\\n\\nhasGoRound = False\\nisCounting = False\\nindex = 0\\ncount = 0\\nmaxCount = 0\\nwhile True:\\n    # print('\\\\ta', a[index])\\n    if a[index] != 0 and not isCounting:\\n        isCounting = True\\n    if a[index] != 0 and isCounting:\\n        count += 1\\n    else:\\n        if maxCount < count:\\n            maxCount = count\\n        if hasGoRound:\\n            break\\n        isCounting = False\\n        count = 0\\n    index += 1\\n    if index == n:\\n        index = 0\\n        hasGoRound = True\\n# print('maxCount', maxCount)\\nprint(sumA + maxCount)\", \"def find_right(x, data):\\n    answer = -1\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            answer = i\\n    return answer\\n\\ndef find_left(x, data):\\n    for i in range(len(data)):\\n        if data[i] == x:\\n            return i\\n\\n\\nn = int(input())\\ndata = list(map(int, input().split()))\\nmin1 = min(data)\\nindex_min_r = find_right(min1, data)\\nindex_min_l = find_left(min1, data)\\nk = data.count(min1)\\nc = index_min_r - index_min_l - 1\\nhelp = []\\nfor i in range(n):\\n    if data[i] == min1:\\n        help.append(i)\\nanswer = []\\nfor i in range(1, len(help)):\\n    answer.append(help[i] - help[i - 1] - 1)\\nanswer.append(n - (help[-1] - help[0]) - 1)\\nprint(max(answer) + n * min1)\", \"trash = int(input());\\nline1 = [int(x) for x in input().split()];\\n\\nlow = min(line1);\\nlows = [];\\n\\nfor i in range(0, len(line1)):\\n    if(line1[i]==low):\\n        lows.append(i);\\n\\ndists = [];\\n\\nfor i in range(1, len(lows)):\\n    dists.append((lows[i]-lows[i-1]) - 1);\\n    \\ndists.append( lows[0] + (len(line1)-1) - lows[-1] );\\n\\nprint((max(dists) + low * len(line1) ));\\n\\n            \\n\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\n\\nm = min(a)\\nmdist = 0\\n\\nfst, l = None, None\\nfor i in [i for i, x in enumerate(a) if x == m]:\\n    if fst is None:\\n        fst = l = i\\n    else:\\n        mdist = max(mdist, i - l - 1)\\n        l = i\\n\\nmdist = max(mdist, fst + (n - l) - 1)\\nprint(n*m + mdist)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmi=min(a)\\ncur=0\\nans=0\\nfor i in range(3*n):\\n    if(a[i%n]==mi):\\n     cur=0\\n    else:\\n     cur+=1\\n    ans=max(ans,cur)\\nprint(n*mi+ans)     \\n     \\n\", \"n = int(input())\\n\\ncolors = list(map(int, input().split()))\\n\\nm = min(colors)\\nlongest_sub = 0\\ncur_sub = 0\\npos = 0\\nbreak_on_min = False\\nwhile pos < n:\\n    if colors[pos] > m:\\n        cur_sub += 1\\n        if cur_sub > longest_sub:\\n            longest_sub = cur_sub\\n    else:\\n        cur_sub = 0\\n        if break_on_min:\\n            break\\n\\n    pos += 1\\n    if pos == n and cur_sub > 0:\\n        pos = 0\\n        break_on_min = True\\n\\nprint(m*n + longest_sub)\", \"n=int(input())\\na=list(map(int,input().split()))\\nl=len(a)\\nm=min(a)\\nmi=[]\\nb=0\\nfor i in range(l):\\n    if m==a[i]:\\n        mi.append(i)\\nif len(mi)>1:\\n    c=l-1-mi[-1]+mi[0]\\n    for i in range(len(mi)-1):\\n        b=mi[i+1]-mi[i]-1\\n        if b>c:\\n            c=b\\n    print(l*m+c)\\nelse:\\n    print((m+1)*l-1)\\n\", \"import sys\\n\\nn = int(input())\\npaint = list(map(int, input().split()))\\nlow, high = min(paint), max(paint)\\nif low == high:\\n    print(n * low)\\n    return\\n\\ncount, best = 0, 0\\nstart = paint.index(low)\\npos = start\\nwhile True:\\n    pos += 1\\n    if pos == n:\\n        pos = 0\\n    if pos == start:\\n        break\\n    if paint[pos] != low:\\n        count += 1\\n        best = max(best, count)\\n    else:\\n        count = 0\\nprint(n * low + best)\\n\", \"n = int(input())\\nl = list(map(int, input().split()))\\n\\nmini = min(l)\\nfor i in range(n): l[i] -= mini\\nres = mini * n\\ntmp = 0\\nmaxi = 0\\nfor i in range(2 * n):\\n    if l[i % n] > 0:\\n        tmp += 1\\n        if tmp > maxi: maxi = tmp\\n    else: tmp = 0\\n    \\nprint(res + maxi)\", \"n=int(input())\\na=list(map(int,input().split()))\\nh=min(a)\\na=a+a\\npos=a.index(h)\\nw=0\\nfor i in range(pos+1,2*n):\\n    if a[i]==h:\\n        w=max(w,i-pos-1)\\n        pos=i\\nprint(h*n+w)\", \"n = int(input())\\ncol = list(map(int,input().split()))\\nlow = min(col)\\nstart = int()\\nstore = list()\\ndist = list()\\nfor i in range(len(col)):\\n    if col[i]==low:\\n        store.append(i+1)\\n        if i+1 in range(len(col)):\\n            start = col[i+1]\\n        else:\\n            start = col[0]\\n            \\nfor j in range(len(store)):\\n    if j==(len(store)-1):\\n        dist.append(n - store[-1] + store[0])\\n    else:\\n        dist.append(store[j+1]-store[j])\\n        \\nhigh = max(dist)\\n\\nif max(col) == min(col):\\n    print(max(col)*n)\\nelif len(store)==1:\\n    print(n*(low+1) -1)\\nelse:\\n    print(n*(low) +( high -1))\\n\\n\"]",
        "difficulty": "interview",
        "input": "3\n101 100 100\n",
        "output": "301\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/610/B"
    },
    {
        "id": 1638,
        "task_id": 1165,
        "test_case_id": 1,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n",
        "output": "2\n6\n-1\n4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1639,
        "task_id": 1165,
        "test_case_id": 7,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "10 10\n318890 307761 832732 700511 820583 522866 130891 914566 128429 739710\n4 9 178864\n6 9 741003\n4 9 172997\n4 6 314469\n1 4 694802\n8 8 401658\n7 10 376243\n7 8 508771\n3 5 30038\n2 10 591490\n",
        "output": "9\n9\n9\n6\n4\n8\n10\n8\n5\n10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1640,
        "task_id": 1165,
        "test_case_id": 10,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "7 1\n2 1 3 2 2 2 2\n1 7 2\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1641,
        "task_id": 1165,
        "test_case_id": 11,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "4 1\n3 1 2 2\n1 4 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1642,
        "task_id": 1165,
        "test_case_id": 12,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "6 1\n3 2 4 3 3 3\n1 6 3\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1643,
        "task_id": 1165,
        "test_case_id": 13,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "4 1\n1 3 2 2\n1 4 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1644,
        "task_id": 1165,
        "test_case_id": 14,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "5 1\n2 3 1 2 2\n1 5 2\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1645,
        "task_id": 1165,
        "test_case_id": 15,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "3 1\n1 9 5\n1 3 5\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1646,
        "task_id": 1165,
        "test_case_id": 16,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "4 1\n4 2 6 4\n1 4 4\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1647,
        "task_id": 1165,
        "test_case_id": 17,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "2 1\n1 3\n1 2 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1648,
        "task_id": 1165,
        "test_case_id": 18,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "10 1\n2 2 1 3 2 2 2 2 2 2\n2 5 2\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1649,
        "task_id": 1165,
        "test_case_id": 19,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "7 1\n6 5 7 6 6 6 6\n1 7 6\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1650,
        "task_id": 1165,
        "test_case_id": 20,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "3 1\n2 4 3\n1 3 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1651,
        "task_id": 1165,
        "test_case_id": 21,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "4 1\n4 2 3 3\n1 4 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1652,
        "task_id": 1165,
        "test_case_id": 22,
        "question": "You are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-----Input-----\n\nThe first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the number of elements in a and the number of queries.\n\nThe second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a.\n\nEach of the next m lines contains three integers l_{i}, r_{i}, x_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n, 1 ≤ x_{i} ≤ 10^6) — the parameters of the i-th query.\n\n\n-----Output-----\n\nPrint m lines. On the i-th line print integer p_{i} — the position of any number not equal to x_{i} in segment [l_{i}, r_{i}] or the value  - 1 if there is no such number.\n\n\n-----Examples-----\nInput\n6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2\n\nOutput\n2\n6\n-1\n4",
        "solutions": "[\"import collections\\nimport math\\n\\nn ,m = map(int, input().split())\\nA = list(map(int, input().split()))\\nans, f = [], [0] * n\\nf[0] = -1\\nfor i in range(1, n):\\n    if A[i] != A[i - 1]:\\n        f[i] = i - 1\\n    else:\\n        f[i] = f[i - 1]\\nfor i in range(m):\\n    l, r, x = map(int, input().split())\\n    #q.append([l - 1, r - 1, x])\\n    #for i in range(m):\\n    if A[r - 1] != x:\\n        ans.append(r)\\n    elif f[r - 1] >= l - 1:\\n        ans.append(f[r - 1] + 1)\\n    else:\\n        ans.append(-1)\\nprint('\\\\n'.join(str(x) for x in ans))\", \"from sys import *\\n\\ndef input():\\n    return stdin.readline()\\n\\nn ,m = map(int, input().split())\\na = list(map(int, input().split()))\\nans=[]\\ndifPre=[-1 for i in range(n)]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        difPre[i]=difPre[i-1]\\n    else:\\n        difPre[i]=i-1\\n\\nfor i in range(m):\\n    l,r,x=map(int,input().split())\\n    if a[r-1]!=x:\\n        ans.append(str(r))\\n    else:\\n        if difPre[r-1]>=l-1:\\n            ans.append(str(difPre[r-1]+1))\\n        else:\\n            ans.append('-1')\\nprint('\\\\n'.join(ans))\", \"n,m=list(map(int,input().split()))\\nl=input().split()\\nL,ans=[0 for i in range(n)],[]\\nL[0]=-1\\nfor i in range(1,n):\\n    if l[i]==l[i-1]:\\n        L[i]=L[i-1]\\n    else:L[i]=i\\nfor i in range(m):\\n    s=input().split()\\n    b=int(s[1])\\n    if l[b-1]!=s[2]:\\n        ans+=[str(b)]\\n    elif L[b-1]>=int(s[0]):\\n        ans+=[str(L[b-1])]\\n    else:\\n        ans+=['-1']\\nprint('\\\\n'.join(ans))\\n\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\n\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n\\n    result.append(str(answer))\\n\\nprint('\\\\n' .join(result))\", \"from sys import stdin \\n\\nn,m=list(map(int,stdin.readline().split()))\\na=list(map(int,stdin.readline().split()))\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=list(map(int,stdin.readline().split()))\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"from sys import stdin \\n\\nn,m=map(int,stdin.readline().split())\\na=stdin.readline().split()\\n\\npre=[]\\nt,index=a[0],0\\nfor i in range(n) :\\n    index=index if a[i]==t else i\\n    t=a[i]\\n    pre.append(index)\\n\\nprt=[]\\nfor i in range(m) :\\n    l,r,x=stdin.readline().split()\\n    l,r=int(l),int(r)\\n    L=pre[r-1]\\n    if a[r-1]==x :\\n        sl=pre[r-1]+1\\n        if sl<=l :\\n            prt.append(str(-1))\\n            continue\\n        r=sl-1\\n    prt.append(str(r))\\n\\nprint(\\\"\\\\n\\\".join(prt))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nresult = []\\nprev = [-1]*n\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        prev[i] = i-1\\n    else:\\n        prev[i] = prev[i-1]\\nfor i in range(m):\\n    l,r,x = input().split()\\n    r = int(r)\\n    if a[r-1] != x:\\n        answer = r\\n    elif prev[r-1]<int(l)-1:\\n        answer = -1\\n    else:\\n        answer = prev[r-1]+1\\n    result.append(str(answer))\\nprint('\\\\n' .join(result))\", \"n,m = map(int,input().split())\\na = input().split()\\nb = [0] * n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint ('\\\\n'.join(ans))\", \"n,m=map(int,input().split())\\na=input().split()\\np=[0 for i in range(n)]\\np[0]=-1\\nans=[]\\nfor i in range(1,n):\\n    if a[i]==a[i-1]:\\n        p[i]=p[i-1]\\n    else:\\n        p[i]=i-1\\nfor i in range(m):\\n    s=input().split()\\n    r=int(s[1])\\n    if a[r-1]!=s[2]:\\n        ans+=[str(r)]\\n    else:\\n        if p[r-1]>=int(s[0])-1:\\n            ans+=[str(p[r-1]+1)]\\n        else:\\n            ans+=['-1']\\nprint('\\\\n'.join(ans))\", \"n,m = [int(i) for i in input().split()]\\na = input().split()\\nb = [0]*n\\nans = []\\nfor i in range(1,n):\\n    if a[i] != a[i-1]:\\n        b[i] = i\\n    else:\\n        b[i] = b[i-1]\\nfor i in range(m):\\n    c = input().split()\\n    c[1] = int(c[1])\\n    c[0] = int(c[0])\\n    if a[c[1]-1] != c[2]:\\n        ans.append(str(c[1]))\\n    elif b[c[1]-1] <= c[0]-1:\\n        ans.append(str(-1))\\n    else:\\n        ans.append(str(b[c[1]-1]))\\nprint('\\\\n'.join(ans))\\n\", \"# -*- coding: utf-8 -*-\\n\\\"\\\"\\\"\\nCreated on Tue May 17 15:26:55 2016\\n\\n@author: Alex\\n\\\"\\\"\\\"\\nfrom sys import stdin\\n\\nn,m = [int(i) for i in input().split()]\\nl = [int(i) for i in stdin.readline().split()]\\nprev = [-1 for i in range(n)]\\nre = []\\nfor i in range(n-1):\\n    if l[i] != l[i+1]:\\n        prev[i+1] = i\\n    else:\\n        prev[i+1] = prev[i]\\nfor _ in range(m):\\n    le,ri,xi = [int(i) for i in stdin.readline().split()]\\n    i = ri-1\\n    if l[i]!=xi:\\n        re.append(str(ri))\\n    else:\\n        if prev[i]<le-1:\\n            re.append('-1')\\n        else:\\n            re.append(str(prev[i]+1))\\nprint('\\\\n'.join(re))\\n        \\n\", \"\\nn, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\n#print(a)\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"n, m = tuple(map(int, input().split()))\\nli = input().split()\\na=[0]*n\\nfor i in range(1,n):\\n    if li[i] != li[i-1]:\\n        a[i]=(i)\\n    else:\\n        a[i]=(a[i-1])\\nresult =[0]*m\\nfor k in range(m):\\n    l, r, x = input().split(); l,r=int(l),int(r)\\n    if li[r-1] != x: result[k]=str(r)\\n    elif a[r-1]>=l: result[k]=str(a[r-1])\\n    else: result[k]='-1'\\n\\nprint('\\\\n'.join(result))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[tem] < l-1:\\n\\t\\t\\tans.append('-1')\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[tem]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn, m = [int(i) for i in stdin.readline().split()]\\nori = [int(i) for i in stdin.readline().split()]\\npre = [-1] * n\\nans = list()\\nfor i in range(n-1):\\n\\tif ori[i] != ori[i+1]:\\n\\t\\tpre[i+1] = i\\n\\telse:\\n\\t\\tpre[i+1] = pre[i]\\nfor i in range(m):\\n\\tl, r, x = [int(i) for i in stdin.readline().split()]\\n\\ttem = r - 1\\n\\tif ori[tem] != x: \\n\\t\\tans.append(str(r))\\n\\telse:\\n\\t\\tif pre[r-1] == pre[l-1]:\\n\\t\\t\\tans.append('-1')\\n\\t\\t\\tcontinue\\n\\t\\telse:\\n\\t\\t\\tans.append(str(pre[r-1]+1))\\n\\nprint('\\\\n'.join(ans))\", \"from sys import stdin\\n\\nn,m = [int(i) for i in stdin.readline().split()]\\na = [int(i) for i in stdin.readline().split()]\\nb = [None] * n\\nb[0] = -1\\nans = [None] * m\\nfor i in range(1,len(a)):\\n    if a[i] == a[i - 1]:\\n        b[i] = b[i - 1]\\n    else:\\n        b[i] = i - 1\\nfor i in range(m):\\n    l,r,x = [int(j) for j in stdin.readline().split()]\\n    k = r - 1\\n    if a[k] != x:\\n        ans[i] = str(k + 1)\\n    elif b[k] + 1 >= l:\\n        ans[i] = str(b[k] + 1)\\n    else:\\n        ans[i] = ('-1')\\n\\nprint('\\\\n'.join(ans))\\n\"]",
        "difficulty": "interview",
        "input": "5 1\n3 2 4 5 5\n1 3 3\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/622/C"
    },
    {
        "id": 1653,
        "task_id": 1169,
        "test_case_id": 8,
        "question": "Vasya has got an undirected graph consisting of $n$ vertices and $m$ edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edges such that they connect the same pair of vertices. Since the graph is undirected, the pair of edges $(1, 2)$ and $(2, 1)$ is considered to be multiple edges. Isolated vertex of the graph is a vertex such that there is no edge connecting this vertex to any other vertex.\n\nVasya wants to know the minimum and maximum possible number of isolated vertices in an undirected graph consisting of $n$ vertices and $m$ edges. \n\n\n-----Input-----\n\nThe only line contains two integers $n$ and $m~(1 \\le n \\le 10^5, 0 \\le m \\le \\frac{n (n - 1)}{2})$.\n\nIt is guaranteed that there exists a graph without any self-loops or multiple edges with such number of vertices and edges.\n\n\n-----Output-----\n\nIn the only line print two numbers $min$ and $max$ — the minimum and maximum number of isolated vertices, respectively.\n\n\n-----Examples-----\nInput\n4 2\n\nOutput\n0 1\n\nInput\n3 1\n\nOutput\n1 1\n\n\n\n-----Note-----\n\nIn the first example it is possible to construct a graph with $0$ isolated vertices: for example, it should contain edges $(1, 2)$ and $(3, 4)$. To get one isolated vertex, we may construct a graph with edges $(1, 2)$ and $(1, 3)$. \n\nIn the second example the graph will always contain exactly one isolated vertex.",
        "solutions": "[\"n, m = map(int, input().split())\\nif m == 0:\\n\\tprint(n, n)\\n\\treturn\\nif m == n * (n - 1) // 2:\\n\\tprint(0, 0)\\n\\treturn\\nL = 0\\nR = n + 1\\nwhile R - L > 1:\\n\\tm1 = (L + R) // 2\\n\\tif m1 * (m1 - 1) // 2 < m:\\n\\t\\tL = m1\\n\\telse:\\n\\t\\tR = m1\\nans_max = n - R\\nans_min = max(0, n - 2 * m)\\nprint(ans_min, ans_max)\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn, m = mi()\\nx = max(0, n - 2 * m)\\nfor i in range(n + 1):\\n    c = i * (i - 1) // 2\\n    if c >= m:\\n        y = n - i\\n        break\\nprint(x, y)\\n\", \"n, m = map(int, input().split())\\nl = 0\\nr = n\\nfor i in range(50):\\n    md = (l + r) // 2\\n    if md * (md - 1) // 2 < m:\\n        l = md\\n    else:\\n        r = md\\n   # print(l, r, md)\\nprint(max(0, n - m * 2), n - r)\", \"n, m = map(int, input().split())\\n\\nmn = max(0, n - 2 * m)\\n\\nfor i in range(n + 1):\\n    if i * (i - 1) // 2 >= m:\\n        mx = n - i\\n        break\\n\\nprint(mn, mx)\", \"n, m = map(int, input().split())\\nif m == 0:\\n\\tprint(n, n)\\n\\treturn\\nleft, right = 0, n + 1\\nwhile left != right - 1:\\n\\tmid = (left + right) // 2\\n\\tif mid * (mid - 1) // 2 < m:\\n\\t\\tleft = mid\\n\\telse:\\n\\t\\tright = mid\\nprint(max(0, n - 2 * m), n - right)\", \"n, m = map(int, input().split())\\nans2 = 0\\nif (n + 1) // 2 > m:\\n    print(n - m * 2, end=' ')\\nelse:\\n    print(0, end=' ')\\nfor i in range(n, -1, -1):\\n    now = n - i\\n    if (now * (now - 1) // 2) >= m:\\n        print(i)\\n        break\", \"n, m = list(map(int,input().split()))\\nimin = max(0,n - 2 * m)\\ns = 0\\nk = 1\\nwhile s < m:\\n\\ts = (k * (k - 1) // 2)\\n\\tk += 1\\nprint(imin, n - k + 1)\\n\", \"import sys\\nimport os\\n\\ndef solve(n, m):\\n    if m == 0:\\n        return (n, n)\\n    minimum = max(0, n - m * 2)\\n    for i in range(1, n + 1):\\n        if i * (i - 1) // 2 >= m:\\n            return (minimum, n - i)\\n\\ndef main():\\n    n, m = (int(x) for x in input().split())\\n    print(' '.join(str(x) for x in solve(n, m)))\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"USE_STDIO = False\\n\\nif not USE_STDIO:\\n    try: import mypc\\n    except: pass\\n\\ndef main():\\n    n, m = list(map(int, input().split(' ')))\\n    if m == 0:\\n        print(n, n)\\n        return\\n\\n    minc = max(0, n - m * 2)\\n\\n    x = int((m*2)**0.5)\\n    if x * (x + 1) < m * 2:\\n        x += 1\\n    maxc = n - (x + 1)\\n\\n    print(minc, maxc)\\n\\ndef __starting_point():\\n    main()\\n\\n\\n\\n\\n__starting_point()\", \"n, m = list(map(int, input().split()))\\n\\nmini = max(0, n - 2 * m)\\nmaxi = 10 ** 10\\nfor i in range(n + 1):\\n    if i * (i - 1) // 2 < m:\\n        continue\\n    maxi = min(maxi, i)\\nprint(mini, n - maxi)\\n\", \"import sys\\nfrom math import *\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\nn,m = list(map(int,minp().split()))\\nk = int(sqrt(m))\\nwhile k*(k-1)//2 > m:\\n\\tk -= 1\\nwhile k*(k-1)//2 < m:\\n\\tk += 1\\n#if k*(k-1)//2 == m:\\nprint(max(0,n-m*2), n-k)\\n\", \"n,m=map(int,input().split())\\nprint(max(0,n-2*m),end=' ')\\nl = -1\\nr= n+1;\\nwhile(r-l>1):\\n    s=(l+r)//2\\n    if(s*(s-1)<2*m):\\n        l=s\\n    else:\\n        r=s\\nprint(max(0,n-r))\\n\", \"(n, m) = map(int, input().split())\\n\\nif (n + 1) // 2 <= m:\\n    print(0, end = ' ')\\nelse:\\n    print(n - m * 2, end = ' ')\\n    \\nk = 0\\nwhile k < n:\\n    if (k * (k - 1)) // 2 < m:\\n        k += 1\\n        continue\\n    else:\\n        break\\n\\nprint(n - k)\\n\\n\\n\", \"n, m = list(map(int, input().split()))\\n\\nmin_v = max(0, n - m * 2)\\n\\nin_clique = 1\\nwhile m > 0:\\n    m -= in_clique\\n    in_clique += 1\\n\\nmax_v = n - in_clique + (in_clique == 1)\\n\\n\\n\\nprint(min_v, max_v)\\n\", \"import os\\nimport sys\\n\\nn, m = [int(num) for num in sys.stdin.readline().split()]\\n\\n# for _ in range(t):\\n#     s, a, b, c = [int(s) for s in sys.stdin.readline().split()]\\n#     s = s // c\\n#     res = (a + b) * (s // a) + s % a\\n#     sys.stdout.write(\\\"{0}\\\\n\\\".format(res))\\n\\nres1 = max([0, n - 2 * m])\\nres2 = 0\\nwhile res2 * (res2 - 1) < (2 * m):\\n    res2 += 1\\n\\nprint(res1, n - res2)\\n\", \"n, m = list(map(int, input().split()))\\nl, r = 0, n\\nwhile l < r:\\n    c = (l + r) // 2\\n    if (c * (c - 1) // 2) < m:\\n        l = c + 1\\n    else:\\n        r = c\\nmn = 0\\nif m <= n // 2:\\n    mn = n - m * 2\\nprint(mn, n - l)\", \"n,m=list(map(int,input().split()))\\ni=0\\nwhile (i*(i-1)/2<m) and (i<=n):\\n    i+=1\\nif n//2+n%2<=m:\\n    print(0,n-i)\\nelse:\\n    print(n-2*m,n-i)\\n\", \"import math\\nx=input()\\nx=x.split()\\nn=int(x[0])\\nm=int(x[1])\\nif m>=n/2:\\n    min=0\\nelse:\\n    min=n-2*m\\nmax=n-math.ceil((2*m+(2*m)**(1/2))**(1/2))\\nprint(str(min)+\\\" \\\"+str(max))\", \"import math\\n\\nn,m=list(map(int,input().split()))\\n\\nMINANS=max(0,n-m*2)\\n\\ndef combi(m):\\n    return m*(m-1)//2\\n\\nfor i in range(int(math.sqrt(2*m)),n+1):\\n    if combi(i)>=m:\\n        break\\n\\nMAXANS=n-i\\n#n*(n-1)/2=m\\n#n^2-n+2m=0\\n\\n\\nprint(MINANS,MAXANS)\\n\", \"n,m=list(map(int,input().split()))\\nmn=n-min(2*m,n)\\nk=0\\nwhile k*(k-1)//2<m:\\n\\tk+=1\\nmx=n-k\\nprint(str(mn)+\\\" \\\"+str(mx))\\n\", \"import math\\ndef most_edge(n):\\n    return n*(n-1)//2\\ndef can(n,m):\\n    return most_edge(n)>=m\\n\\nn,m=[int(x) for x in input().split()]\\nminn=n-2*m\\nminn=max(0,minn)\\n\\nnp=max(0,int(math.sqrt(2*m))-10)\\n\\nfor i in range(np,np+20):\\n    if not can(i,m):\\n        continue\\n    else:\\n        maxx=i\\n        break\\n\\nmaxx=n-maxx\\n\\nprint(minn,maxx)\\n\", \"n,m = map(int, input().split())\\nif n > 1 and m >= n/2:\\n    ans1 = 0\\nelse:\\n    if n > 1:\\n        ans1 = n - m*2\\n    else:\\n        ans1 = 1\\nk = 1\\nwhile k*(k-1)//2 < m:\\n    k += 1\\nif m > 0:\\n    ans2 = n - k\\nelse:\\n    ans2 = n\\nprint(ans1, ans2)\", \"3\\n\\nimport math\\nimport sys\\n\\n\\nDEBUG = False\\n\\n\\ndef inp():\\n    return sys.stdin.readline().rstrip()\\n\\n\\ndef dprint(*value, sep=' ', end='\\\\n'):\\n    if DEBUG:\\n        print(*value, sep=sep, end=end)\\n\\n\\ndef getpf(E):\\n    if E == 0:\\n        return 0\\n\\n    e = 0\\n    for k in range(2, E + 100):\\n        e += k - 1\\n        if e >= E:\\n            return k\\n\\n    assert False\\n\\n\\ndef solve(V, E):\\n    mx = V - getpf(E)\\n    mn = max(0, V - E * 2)\\n    return mn, mx\\n\\n\\ndef main():\\n    N, M = [int(e) for e in inp().split()]\\n    print(*solve(N, M))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "100 0\n",
        "output": "100 100\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1065/B"
    },
    {
        "id": 1654,
        "task_id": 1169,
        "test_case_id": 9,
        "question": "Vasya has got an undirected graph consisting of $n$ vertices and $m$ edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edges such that they connect the same pair of vertices. Since the graph is undirected, the pair of edges $(1, 2)$ and $(2, 1)$ is considered to be multiple edges. Isolated vertex of the graph is a vertex such that there is no edge connecting this vertex to any other vertex.\n\nVasya wants to know the minimum and maximum possible number of isolated vertices in an undirected graph consisting of $n$ vertices and $m$ edges. \n\n\n-----Input-----\n\nThe only line contains two integers $n$ and $m~(1 \\le n \\le 10^5, 0 \\le m \\le \\frac{n (n - 1)}{2})$.\n\nIt is guaranteed that there exists a graph without any self-loops or multiple edges with such number of vertices and edges.\n\n\n-----Output-----\n\nIn the only line print two numbers $min$ and $max$ — the minimum and maximum number of isolated vertices, respectively.\n\n\n-----Examples-----\nInput\n4 2\n\nOutput\n0 1\n\nInput\n3 1\n\nOutput\n1 1\n\n\n\n-----Note-----\n\nIn the first example it is possible to construct a graph with $0$ isolated vertices: for example, it should contain edges $(1, 2)$ and $(3, 4)$. To get one isolated vertex, we may construct a graph with edges $(1, 2)$ and $(1, 3)$. \n\nIn the second example the graph will always contain exactly one isolated vertex.",
        "solutions": "[\"n, m = map(int, input().split())\\nif m == 0:\\n\\tprint(n, n)\\n\\treturn\\nif m == n * (n - 1) // 2:\\n\\tprint(0, 0)\\n\\treturn\\nL = 0\\nR = n + 1\\nwhile R - L > 1:\\n\\tm1 = (L + R) // 2\\n\\tif m1 * (m1 - 1) // 2 < m:\\n\\t\\tL = m1\\n\\telse:\\n\\t\\tR = m1\\nans_max = n - R\\nans_min = max(0, n - 2 * m)\\nprint(ans_min, ans_max)\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn, m = mi()\\nx = max(0, n - 2 * m)\\nfor i in range(n + 1):\\n    c = i * (i - 1) // 2\\n    if c >= m:\\n        y = n - i\\n        break\\nprint(x, y)\\n\", \"n, m = map(int, input().split())\\nl = 0\\nr = n\\nfor i in range(50):\\n    md = (l + r) // 2\\n    if md * (md - 1) // 2 < m:\\n        l = md\\n    else:\\n        r = md\\n   # print(l, r, md)\\nprint(max(0, n - m * 2), n - r)\", \"n, m = map(int, input().split())\\n\\nmn = max(0, n - 2 * m)\\n\\nfor i in range(n + 1):\\n    if i * (i - 1) // 2 >= m:\\n        mx = n - i\\n        break\\n\\nprint(mn, mx)\", \"n, m = map(int, input().split())\\nif m == 0:\\n\\tprint(n, n)\\n\\treturn\\nleft, right = 0, n + 1\\nwhile left != right - 1:\\n\\tmid = (left + right) // 2\\n\\tif mid * (mid - 1) // 2 < m:\\n\\t\\tleft = mid\\n\\telse:\\n\\t\\tright = mid\\nprint(max(0, n - 2 * m), n - right)\", \"n, m = map(int, input().split())\\nans2 = 0\\nif (n + 1) // 2 > m:\\n    print(n - m * 2, end=' ')\\nelse:\\n    print(0, end=' ')\\nfor i in range(n, -1, -1):\\n    now = n - i\\n    if (now * (now - 1) // 2) >= m:\\n        print(i)\\n        break\", \"n, m = list(map(int,input().split()))\\nimin = max(0,n - 2 * m)\\ns = 0\\nk = 1\\nwhile s < m:\\n\\ts = (k * (k - 1) // 2)\\n\\tk += 1\\nprint(imin, n - k + 1)\\n\", \"import sys\\nimport os\\n\\ndef solve(n, m):\\n    if m == 0:\\n        return (n, n)\\n    minimum = max(0, n - m * 2)\\n    for i in range(1, n + 1):\\n        if i * (i - 1) // 2 >= m:\\n            return (minimum, n - i)\\n\\ndef main():\\n    n, m = (int(x) for x in input().split())\\n    print(' '.join(str(x) for x in solve(n, m)))\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"USE_STDIO = False\\n\\nif not USE_STDIO:\\n    try: import mypc\\n    except: pass\\n\\ndef main():\\n    n, m = list(map(int, input().split(' ')))\\n    if m == 0:\\n        print(n, n)\\n        return\\n\\n    minc = max(0, n - m * 2)\\n\\n    x = int((m*2)**0.5)\\n    if x * (x + 1) < m * 2:\\n        x += 1\\n    maxc = n - (x + 1)\\n\\n    print(minc, maxc)\\n\\ndef __starting_point():\\n    main()\\n\\n\\n\\n\\n__starting_point()\", \"n, m = list(map(int, input().split()))\\n\\nmini = max(0, n - 2 * m)\\nmaxi = 10 ** 10\\nfor i in range(n + 1):\\n    if i * (i - 1) // 2 < m:\\n        continue\\n    maxi = min(maxi, i)\\nprint(mini, n - maxi)\\n\", \"import sys\\nfrom math import *\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\nn,m = list(map(int,minp().split()))\\nk = int(sqrt(m))\\nwhile k*(k-1)//2 > m:\\n\\tk -= 1\\nwhile k*(k-1)//2 < m:\\n\\tk += 1\\n#if k*(k-1)//2 == m:\\nprint(max(0,n-m*2), n-k)\\n\", \"n,m=map(int,input().split())\\nprint(max(0,n-2*m),end=' ')\\nl = -1\\nr= n+1;\\nwhile(r-l>1):\\n    s=(l+r)//2\\n    if(s*(s-1)<2*m):\\n        l=s\\n    else:\\n        r=s\\nprint(max(0,n-r))\\n\", \"(n, m) = map(int, input().split())\\n\\nif (n + 1) // 2 <= m:\\n    print(0, end = ' ')\\nelse:\\n    print(n - m * 2, end = ' ')\\n    \\nk = 0\\nwhile k < n:\\n    if (k * (k - 1)) // 2 < m:\\n        k += 1\\n        continue\\n    else:\\n        break\\n\\nprint(n - k)\\n\\n\\n\", \"n, m = list(map(int, input().split()))\\n\\nmin_v = max(0, n - m * 2)\\n\\nin_clique = 1\\nwhile m > 0:\\n    m -= in_clique\\n    in_clique += 1\\n\\nmax_v = n - in_clique + (in_clique == 1)\\n\\n\\n\\nprint(min_v, max_v)\\n\", \"import os\\nimport sys\\n\\nn, m = [int(num) for num in sys.stdin.readline().split()]\\n\\n# for _ in range(t):\\n#     s, a, b, c = [int(s) for s in sys.stdin.readline().split()]\\n#     s = s // c\\n#     res = (a + b) * (s // a) + s % a\\n#     sys.stdout.write(\\\"{0}\\\\n\\\".format(res))\\n\\nres1 = max([0, n - 2 * m])\\nres2 = 0\\nwhile res2 * (res2 - 1) < (2 * m):\\n    res2 += 1\\n\\nprint(res1, n - res2)\\n\", \"n, m = list(map(int, input().split()))\\nl, r = 0, n\\nwhile l < r:\\n    c = (l + r) // 2\\n    if (c * (c - 1) // 2) < m:\\n        l = c + 1\\n    else:\\n        r = c\\nmn = 0\\nif m <= n // 2:\\n    mn = n - m * 2\\nprint(mn, n - l)\", \"n,m=list(map(int,input().split()))\\ni=0\\nwhile (i*(i-1)/2<m) and (i<=n):\\n    i+=1\\nif n//2+n%2<=m:\\n    print(0,n-i)\\nelse:\\n    print(n-2*m,n-i)\\n\", \"import math\\nx=input()\\nx=x.split()\\nn=int(x[0])\\nm=int(x[1])\\nif m>=n/2:\\n    min=0\\nelse:\\n    min=n-2*m\\nmax=n-math.ceil((2*m+(2*m)**(1/2))**(1/2))\\nprint(str(min)+\\\" \\\"+str(max))\", \"import math\\n\\nn,m=list(map(int,input().split()))\\n\\nMINANS=max(0,n-m*2)\\n\\ndef combi(m):\\n    return m*(m-1)//2\\n\\nfor i in range(int(math.sqrt(2*m)),n+1):\\n    if combi(i)>=m:\\n        break\\n\\nMAXANS=n-i\\n#n*(n-1)/2=m\\n#n^2-n+2m=0\\n\\n\\nprint(MINANS,MAXANS)\\n\", \"n,m=list(map(int,input().split()))\\nmn=n-min(2*m,n)\\nk=0\\nwhile k*(k-1)//2<m:\\n\\tk+=1\\nmx=n-k\\nprint(str(mn)+\\\" \\\"+str(mx))\\n\", \"import math\\ndef most_edge(n):\\n    return n*(n-1)//2\\ndef can(n,m):\\n    return most_edge(n)>=m\\n\\nn,m=[int(x) for x in input().split()]\\nminn=n-2*m\\nminn=max(0,minn)\\n\\nnp=max(0,int(math.sqrt(2*m))-10)\\n\\nfor i in range(np,np+20):\\n    if not can(i,m):\\n        continue\\n    else:\\n        maxx=i\\n        break\\n\\nmaxx=n-maxx\\n\\nprint(minn,maxx)\\n\", \"n,m = map(int, input().split())\\nif n > 1 and m >= n/2:\\n    ans1 = 0\\nelse:\\n    if n > 1:\\n        ans1 = n - m*2\\n    else:\\n        ans1 = 1\\nk = 1\\nwhile k*(k-1)//2 < m:\\n    k += 1\\nif m > 0:\\n    ans2 = n - k\\nelse:\\n    ans2 = n\\nprint(ans1, ans2)\", \"3\\n\\nimport math\\nimport sys\\n\\n\\nDEBUG = False\\n\\n\\ndef inp():\\n    return sys.stdin.readline().rstrip()\\n\\n\\ndef dprint(*value, sep=' ', end='\\\\n'):\\n    if DEBUG:\\n        print(*value, sep=sep, end=end)\\n\\n\\ndef getpf(E):\\n    if E == 0:\\n        return 0\\n\\n    e = 0\\n    for k in range(2, E + 100):\\n        e += k - 1\\n        if e >= E:\\n            return k\\n\\n    assert False\\n\\n\\ndef solve(V, E):\\n    mx = V - getpf(E)\\n    mn = max(0, V - E * 2)\\n    return mn, mx\\n\\n\\ndef main():\\n    N, M = [int(e) for e in inp().split()]\\n    print(*solve(N, M))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1 0\n",
        "output": "1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1065/B"
    },
    {
        "id": 1655,
        "task_id": 1169,
        "test_case_id": 21,
        "question": "Vasya has got an undirected graph consisting of $n$ vertices and $m$ edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edges such that they connect the same pair of vertices. Since the graph is undirected, the pair of edges $(1, 2)$ and $(2, 1)$ is considered to be multiple edges. Isolated vertex of the graph is a vertex such that there is no edge connecting this vertex to any other vertex.\n\nVasya wants to know the minimum and maximum possible number of isolated vertices in an undirected graph consisting of $n$ vertices and $m$ edges. \n\n\n-----Input-----\n\nThe only line contains two integers $n$ and $m~(1 \\le n \\le 10^5, 0 \\le m \\le \\frac{n (n - 1)}{2})$.\n\nIt is guaranteed that there exists a graph without any self-loops or multiple edges with such number of vertices and edges.\n\n\n-----Output-----\n\nIn the only line print two numbers $min$ and $max$ — the minimum and maximum number of isolated vertices, respectively.\n\n\n-----Examples-----\nInput\n4 2\n\nOutput\n0 1\n\nInput\n3 1\n\nOutput\n1 1\n\n\n\n-----Note-----\n\nIn the first example it is possible to construct a graph with $0$ isolated vertices: for example, it should contain edges $(1, 2)$ and $(3, 4)$. To get one isolated vertex, we may construct a graph with edges $(1, 2)$ and $(1, 3)$. \n\nIn the second example the graph will always contain exactly one isolated vertex.",
        "solutions": "[\"n, m = map(int, input().split())\\nif m == 0:\\n\\tprint(n, n)\\n\\treturn\\nif m == n * (n - 1) // 2:\\n\\tprint(0, 0)\\n\\treturn\\nL = 0\\nR = n + 1\\nwhile R - L > 1:\\n\\tm1 = (L + R) // 2\\n\\tif m1 * (m1 - 1) // 2 < m:\\n\\t\\tL = m1\\n\\telse:\\n\\t\\tR = m1\\nans_max = n - R\\nans_min = max(0, n - 2 * m)\\nprint(ans_min, ans_max)\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return list(map(int, input().split()))\\ndef li():\\n    return list(mi())\\n\\nn, m = mi()\\nx = max(0, n - 2 * m)\\nfor i in range(n + 1):\\n    c = i * (i - 1) // 2\\n    if c >= m:\\n        y = n - i\\n        break\\nprint(x, y)\\n\", \"n, m = map(int, input().split())\\nl = 0\\nr = n\\nfor i in range(50):\\n    md = (l + r) // 2\\n    if md * (md - 1) // 2 < m:\\n        l = md\\n    else:\\n        r = md\\n   # print(l, r, md)\\nprint(max(0, n - m * 2), n - r)\", \"n, m = map(int, input().split())\\n\\nmn = max(0, n - 2 * m)\\n\\nfor i in range(n + 1):\\n    if i * (i - 1) // 2 >= m:\\n        mx = n - i\\n        break\\n\\nprint(mn, mx)\", \"n, m = map(int, input().split())\\nif m == 0:\\n\\tprint(n, n)\\n\\treturn\\nleft, right = 0, n + 1\\nwhile left != right - 1:\\n\\tmid = (left + right) // 2\\n\\tif mid * (mid - 1) // 2 < m:\\n\\t\\tleft = mid\\n\\telse:\\n\\t\\tright = mid\\nprint(max(0, n - 2 * m), n - right)\", \"n, m = map(int, input().split())\\nans2 = 0\\nif (n + 1) // 2 > m:\\n    print(n - m * 2, end=' ')\\nelse:\\n    print(0, end=' ')\\nfor i in range(n, -1, -1):\\n    now = n - i\\n    if (now * (now - 1) // 2) >= m:\\n        print(i)\\n        break\", \"n, m = list(map(int,input().split()))\\nimin = max(0,n - 2 * m)\\ns = 0\\nk = 1\\nwhile s < m:\\n\\ts = (k * (k - 1) // 2)\\n\\tk += 1\\nprint(imin, n - k + 1)\\n\", \"import sys\\nimport os\\n\\ndef solve(n, m):\\n    if m == 0:\\n        return (n, n)\\n    minimum = max(0, n - m * 2)\\n    for i in range(1, n + 1):\\n        if i * (i - 1) // 2 >= m:\\n            return (minimum, n - i)\\n\\ndef main():\\n    n, m = (int(x) for x in input().split())\\n    print(' '.join(str(x) for x in solve(n, m)))\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"USE_STDIO = False\\n\\nif not USE_STDIO:\\n    try: import mypc\\n    except: pass\\n\\ndef main():\\n    n, m = list(map(int, input().split(' ')))\\n    if m == 0:\\n        print(n, n)\\n        return\\n\\n    minc = max(0, n - m * 2)\\n\\n    x = int((m*2)**0.5)\\n    if x * (x + 1) < m * 2:\\n        x += 1\\n    maxc = n - (x + 1)\\n\\n    print(minc, maxc)\\n\\ndef __starting_point():\\n    main()\\n\\n\\n\\n\\n__starting_point()\", \"n, m = list(map(int, input().split()))\\n\\nmini = max(0, n - 2 * m)\\nmaxi = 10 ** 10\\nfor i in range(n + 1):\\n    if i * (i - 1) // 2 < m:\\n        continue\\n    maxi = min(maxi, i)\\nprint(mini, n - maxi)\\n\", \"import sys\\nfrom math import *\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\nn,m = list(map(int,minp().split()))\\nk = int(sqrt(m))\\nwhile k*(k-1)//2 > m:\\n\\tk -= 1\\nwhile k*(k-1)//2 < m:\\n\\tk += 1\\n#if k*(k-1)//2 == m:\\nprint(max(0,n-m*2), n-k)\\n\", \"n,m=map(int,input().split())\\nprint(max(0,n-2*m),end=' ')\\nl = -1\\nr= n+1;\\nwhile(r-l>1):\\n    s=(l+r)//2\\n    if(s*(s-1)<2*m):\\n        l=s\\n    else:\\n        r=s\\nprint(max(0,n-r))\\n\", \"(n, m) = map(int, input().split())\\n\\nif (n + 1) // 2 <= m:\\n    print(0, end = ' ')\\nelse:\\n    print(n - m * 2, end = ' ')\\n    \\nk = 0\\nwhile k < n:\\n    if (k * (k - 1)) // 2 < m:\\n        k += 1\\n        continue\\n    else:\\n        break\\n\\nprint(n - k)\\n\\n\\n\", \"n, m = list(map(int, input().split()))\\n\\nmin_v = max(0, n - m * 2)\\n\\nin_clique = 1\\nwhile m > 0:\\n    m -= in_clique\\n    in_clique += 1\\n\\nmax_v = n - in_clique + (in_clique == 1)\\n\\n\\n\\nprint(min_v, max_v)\\n\", \"import os\\nimport sys\\n\\nn, m = [int(num) for num in sys.stdin.readline().split()]\\n\\n# for _ in range(t):\\n#     s, a, b, c = [int(s) for s in sys.stdin.readline().split()]\\n#     s = s // c\\n#     res = (a + b) * (s // a) + s % a\\n#     sys.stdout.write(\\\"{0}\\\\n\\\".format(res))\\n\\nres1 = max([0, n - 2 * m])\\nres2 = 0\\nwhile res2 * (res2 - 1) < (2 * m):\\n    res2 += 1\\n\\nprint(res1, n - res2)\\n\", \"n, m = list(map(int, input().split()))\\nl, r = 0, n\\nwhile l < r:\\n    c = (l + r) // 2\\n    if (c * (c - 1) // 2) < m:\\n        l = c + 1\\n    else:\\n        r = c\\nmn = 0\\nif m <= n // 2:\\n    mn = n - m * 2\\nprint(mn, n - l)\", \"n,m=list(map(int,input().split()))\\ni=0\\nwhile (i*(i-1)/2<m) and (i<=n):\\n    i+=1\\nif n//2+n%2<=m:\\n    print(0,n-i)\\nelse:\\n    print(n-2*m,n-i)\\n\", \"import math\\nx=input()\\nx=x.split()\\nn=int(x[0])\\nm=int(x[1])\\nif m>=n/2:\\n    min=0\\nelse:\\n    min=n-2*m\\nmax=n-math.ceil((2*m+(2*m)**(1/2))**(1/2))\\nprint(str(min)+\\\" \\\"+str(max))\", \"import math\\n\\nn,m=list(map(int,input().split()))\\n\\nMINANS=max(0,n-m*2)\\n\\ndef combi(m):\\n    return m*(m-1)//2\\n\\nfor i in range(int(math.sqrt(2*m)),n+1):\\n    if combi(i)>=m:\\n        break\\n\\nMAXANS=n-i\\n#n*(n-1)/2=m\\n#n^2-n+2m=0\\n\\n\\nprint(MINANS,MAXANS)\\n\", \"n,m=list(map(int,input().split()))\\nmn=n-min(2*m,n)\\nk=0\\nwhile k*(k-1)//2<m:\\n\\tk+=1\\nmx=n-k\\nprint(str(mn)+\\\" \\\"+str(mx))\\n\", \"import math\\ndef most_edge(n):\\n    return n*(n-1)//2\\ndef can(n,m):\\n    return most_edge(n)>=m\\n\\nn,m=[int(x) for x in input().split()]\\nminn=n-2*m\\nminn=max(0,minn)\\n\\nnp=max(0,int(math.sqrt(2*m))-10)\\n\\nfor i in range(np,np+20):\\n    if not can(i,m):\\n        continue\\n    else:\\n        maxx=i\\n        break\\n\\nmaxx=n-maxx\\n\\nprint(minn,maxx)\\n\", \"n,m = map(int, input().split())\\nif n > 1 and m >= n/2:\\n    ans1 = 0\\nelse:\\n    if n > 1:\\n        ans1 = n - m*2\\n    else:\\n        ans1 = 1\\nk = 1\\nwhile k*(k-1)//2 < m:\\n    k += 1\\nif m > 0:\\n    ans2 = n - k\\nelse:\\n    ans2 = n\\nprint(ans1, ans2)\", \"3\\n\\nimport math\\nimport sys\\n\\n\\nDEBUG = False\\n\\n\\ndef inp():\\n    return sys.stdin.readline().rstrip()\\n\\n\\ndef dprint(*value, sep=' ', end='\\\\n'):\\n    if DEBUG:\\n        print(*value, sep=sep, end=end)\\n\\n\\ndef getpf(E):\\n    if E == 0:\\n        return 0\\n\\n    e = 0\\n    for k in range(2, E + 100):\\n        e += k - 1\\n        if e >= E:\\n            return k\\n\\n    assert False\\n\\n\\ndef solve(V, E):\\n    mx = V - getpf(E)\\n    mn = max(0, V - E * 2)\\n    return mn, mx\\n\\n\\ndef main():\\n    N, M = [int(e) for e in inp().split()]\\n    print(*solve(N, M))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2 0\n",
        "output": "2 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1065/B"
    },
    {
        "id": 1656,
        "task_id": 1195,
        "test_case_id": 1,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 2 3 4 5\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1657,
        "task_id": 1195,
        "test_case_id": 2,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "6\n6 12 3 15 9 18\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1658,
        "task_id": 1195,
        "test_case_id": 3,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "6\n28 4 13 29 17 8\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1659,
        "task_id": 1195,
        "test_case_id": 4,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "9\n23 1 2 26 9 11 23 10 26\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1660,
        "task_id": 1195,
        "test_case_id": 5,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "7\n18 29 23 23 1 14 5\n",
        "output": "24\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1661,
        "task_id": 1195,
        "test_case_id": 6,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "5\n22 19 19 16 14\n",
        "output": "31\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1662,
        "task_id": 1195,
        "test_case_id": 7,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "9\n17 16 8 13 6 29 22 27 18\n",
        "output": "16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1663,
        "task_id": 1195,
        "test_case_id": 8,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "6\n12 12 29 10 30 32\n",
        "output": "25\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1664,
        "task_id": 1195,
        "test_case_id": 9,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "7\n31 1 19 3 11 20 31\n",
        "output": "20\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1665,
        "task_id": 1195,
        "test_case_id": 10,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "5\n27 30 8 32 3\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1666,
        "task_id": 1195,
        "test_case_id": 11,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "8\n22 27 29 29 27 26 27 21\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1667,
        "task_id": 1195,
        "test_case_id": 12,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "10\n9 16 19 23 7 14 21 15 14 6\n",
        "output": "23\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1668,
        "task_id": 1195,
        "test_case_id": 13,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "7\n4 13 8 20 31 17 3\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1669,
        "task_id": 1195,
        "test_case_id": 14,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "6\n32 9 29 17 24 20\n",
        "output": "22\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1670,
        "task_id": 1195,
        "test_case_id": 15,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "8\n27 6 18 14 16 23 31 15\n",
        "output": "22\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1671,
        "task_id": 1195,
        "test_case_id": 16,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "5\n14 27 8 7 28\n",
        "output": "17\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1672,
        "task_id": 1195,
        "test_case_id": 17,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "8\n9 24 29 4 20 14 8 31\n",
        "output": "27\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1673,
        "task_id": 1195,
        "test_case_id": 18,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "10\n5 20 18 1 12 17 22 20 26 4\n",
        "output": "21\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1674,
        "task_id": 1195,
        "test_case_id": 19,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "7\n24 10 8 26 25 5 16\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1675,
        "task_id": 1195,
        "test_case_id": 20,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "8\n19 6 29 23 17 8 30 3\n",
        "output": "32\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1676,
        "task_id": 1195,
        "test_case_id": 21,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "7\n2 6 7 1 3 4 5\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1677,
        "task_id": 1195,
        "test_case_id": 22,
        "question": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.\n\nPiteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.\n\n\n-----Input-----\n\nThe first line of input data contains a single integer $n$ ($5 \\le n \\le 10$).\n\nThe second line of input data contains $n$ space-separated integers $a_i$ ($1 \\le a_i \\le 32$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n5\n1 2 3 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nWe did not proofread this statement at all.",
        "solutions": "[\"n = int(input())\\nl = list(map(int, input().split()))\\nf1 = l[2]\\nl.sort()\\nf2 = l[0]\\nprint(2 + (f1 ^ f2))\\n\", \"kk=lambda:map(int,input().split())\\nk2=lambda:map(lambda x:int(x)-1, input().split())\\nll=lambda:list(kk())\\nn, ls = int(input()), ll()\\nprint(2 + (ls[2] ^ min(ls)))\", \"def input_ints():\\n    return [int(x) for x in input().split()]\\n\\ninput()\\nxs = input_ints()\\n\\nprint(2 + (xs[2] ^ min(xs)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2+(min(a)^a[2]))\", \"# two plus xor of ghird and min elemnt\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nprint(2 + (A[2]^min(A)))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\\n\", \"n=int(input());\\na = list(map(int, input().split(' ')))\\nprint(2 + (min(a) ^ a[2]))\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nmin_ = min(a)\\n# print('min:', min_)\\n\\nprint( 2  + (a[2] ^ min_))\", \"# twoplusxorofthirdandminelement\\n\\nn = int(input())\\nxs = [ int(a) for a in input().split() ]\\n\\nthird = xs[2]\\nmin_ = min(xs)\\nprint(2 + (third ^ min_))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nn = ii()\\na = li()\\nans = 2 + (a[2] ^ min(a))\\nprint(ans)\", \"n = int(input())\\narr = list(map(int, input().strip().split()))\\n\\nprint(2 + (min(arr) ^ arr[2]))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nprint(2 + (min(a) ^ a[2]))\\n\", \"input()\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2]^min(arr)))\\n\", \"input()\\na=list(map(int,input().split()))\\nprint((min(a)^a[2])+2)\", \"n = int(input())\\ns = input().split()\\na = int(s[0])\\nfor i in range(n):\\n    a = min(a, int(s[i]))\\nprint(2 + (a^int(s[2])))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nprint(2 + (a[2] ^ min(a)))\", \"ll=lambda : list(map(int,input().split()))\\nn=int(input())\\nl=ll()\\nans=2+(l[2]^min(l))\\nprint(ans)\", \"n = int(input())\\nl = [*map(int, input().split())]\\nres = l[2]\\nres ^= min(l)\\nprint(res + 2)\", \"n = int(input())\\narr = list(map(int, input().split()))\\nprint(2 + (arr[2] ^ min(arr)))\", \"n = input()\\na = list(map(int, input().split()))\\nprint(str(2 + (a[2] ^ min(a))))\", \"n, a = int(input()), list(map(int, input().split()))\\nprint(2 + (a[2] ^ min(a)))\", \"n = int(input())\\na = [int(p) for p in input().split()]\\nprint(2 + (a[2] ^ min(a)))\\n\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\nsys.setrecursionlimit(1000000)\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nprint((a[2]^min(a))+2)\", \"n = int(input())\\ns = [int(i) for i in input().split()]\\n\\nprint(2 + (s[2] ^ min(s)))\\n\"]",
        "difficulty": "interview",
        "input": "5\n31 31 30 31 1\n",
        "output": "33\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1145/D"
    },
    {
        "id": 1678,
        "task_id": 1216,
        "test_case_id": 3,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "18\naeiouyaaeeiioouuyy\n",
        "output": "aeiouyaeeioouy\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1679,
        "task_id": 1216,
        "test_case_id": 5,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "36\naeiouyaaeeiioouuyyaaaeeeiiiooouuuyyy\n",
        "output": "aeiouyaeeioouyaeiouy\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1680,
        "task_id": 1216,
        "test_case_id": 12,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "2\nee\n",
        "output": "ee\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1681,
        "task_id": 1216,
        "test_case_id": 13,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "2\noo\n",
        "output": "oo\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1682,
        "task_id": 1216,
        "test_case_id": 14,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "4\neeoo\n",
        "output": "eeoo\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1683,
        "task_id": 1216,
        "test_case_id": 15,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "7\nooeeeee\n",
        "output": "ooe\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1684,
        "task_id": 1216,
        "test_case_id": 16,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "75\noiaaaiiioyoeuauieeeeyauioyaiuyueeoaiiyeauyuauuyueoioueieeaaeyiyeyyaiooouyoo\n",
        "output": "oiaioyoeuauieyauioyaiuyueeoaiyeauyuauyueoioueieeaeyiyeyaiouyoo\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1685,
        "task_id": 1216,
        "test_case_id": 17,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "5\noooee\n",
        "output": "oee\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1686,
        "task_id": 1216,
        "test_case_id": 18,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "8\neeeaaeee\n",
        "output": "eae\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1687,
        "task_id": 1216,
        "test_case_id": 19,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "10\noaaoooaaoo\n",
        "output": "oaoaoo\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1688,
        "task_id": 1216,
        "test_case_id": 20,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "5\nooeoo\n",
        "output": "ooeoo\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1689,
        "task_id": 1216,
        "test_case_id": 21,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "3\neoo\n",
        "output": "eoo\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1690,
        "task_id": 1216,
        "test_case_id": 22,
        "question": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are \"a\", \"e\", \"i\", \"o\", \"u\" and \"y\".\n\nThere are exceptions: if letters \"e\" or \"o\" repeat in a row exactly 2 times, like in words \"feet\" and \"foot\", the program must skip them and do not transform in one vowel. For example, the word \"iiiimpleeemeentatiioon\" must be converted to the word \"implemeentatioon\".\n\nSergey is very busy and asks you to help him and write the required program.\n\n\n-----Input-----\n\nThe first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.\n\nThe second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.\n\n\n-----Output-----\n\nPrint the single string — the word written by Stepan converted according to the rules described in the statement.\n\n\n-----Examples-----\nInput\n13\npobeeeedaaaaa\n\nOutput\npobeda\n\nInput\n22\niiiimpleeemeentatiioon\n\nOutput\nimplemeentatioon\n\nInput\n18\naeiouyaaeeiioouuyy\n\nOutput\naeiouyaeeioouy\n\nInput\n24\naaaoooiiiuuuyyyeeeggghhh\n\nOutput\naoiuyeggghhh",
        "solutions": "[\"bad = ['e', 'a', 'i', 'o', 'u', 'y']\\n\\nn = int(input())\\ns = input()\\nans = ''\\ni = 0\\nwhile i != len(s):\\n    if s[i] in bad:\\n        letter = s[i]\\n        pos = i\\n        while i != len(s) and letter == s[i]:\\n            i += 1\\n        if i - pos == 2 and letter in ['e', 'o']:\\n            ans += 2 * letter\\n        else:\\n            ans += letter\\n    else:\\n        ans += s[i]\\n        i += 1\\nprint(ans)\", \"\\\"\\\"\\\" Created by Shahen Kosyan on 4/5/17 \\\"\\\"\\\"\\n\\ndef __starting_point():\\n    vowels = ['a', 'e', 'i', 'o', 'u', 'y']\\n\\n    n = int(input())\\n    word = input()\\n\\n    answer = \\\"\\\"\\n    i = 0\\n    s_count = 1\\n    while i < n:\\n        symbol = word[i]\\n        if i == n - 1:\\n            if s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            else:\\n                answer += symbol\\n        else:\\n            if symbol == word[i + 1] and symbol in vowels:\\n                s_count += 1\\n            elif s_count == 2 and (symbol == \\\"e\\\" or symbol == \\\"o\\\"):\\n                answer += symbol + symbol\\n                s_count = 1\\n            elif s_count > 1 and symbol in vowels:\\n                s_count = 1\\n                answer += symbol\\n            else:\\n                s_count = 1\\n                answer += symbol\\n\\n        i += 1\\n\\n    print(answer)\\n\\n__starting_point()\", \"vowel = {'a', 'e', 'i', 'o', 'u', 'y'}\\n\\nn = int(input())\\ns = input()\\n\\nl = len(s)\\n\\nans, last_c, i = \\\"\\\", ' ', 0\\nfor c in s:\\n    if not c in vowel:\\n        ans += c\\n    else:\\n        if c != last_c:\\n            ans += c\\n        else:\\n            if c == 'e' or c == 'o':\\n                if (i + 1 >= l or s[i + 1] != c) and (i < 2 or s[i - 2] != c):\\n                    ans += c\\n    \\n    last_c = c\\n    \\n    i += 1\\n\\nprint(ans)\\n\", \"\\n# coding: utf-8\\n\\n# In[21]:\\n\\nodd = input()\\ns = input()\\n\\nres = \\\"\\\"\\nvows = \\\"aeiouy\\\"\\ne = \\\"eo\\\"\\n\\na = []\\npr = '@'\\nfor ch in s:\\n    if pr == ch:\\n        a[-1] += ch\\n    else:\\n        a.append(str(ch))\\n    pr = ch\\nfor g in a:\\n    if len(g) == 1 or len(g) == 2 and g[0] in e or g[0] not in vows:\\n        res += g\\n    else:\\n        res += g[0]\\nprint(res)\\n\\n\\n# In[ ]:\\n\\n\\n\\n\", \"abc = input()\\ns = '1' + input() + '1'\\nglas = ['a', 'e', 'i', 'o', 'u', 'y']\\nprint(s[1], end='')\\n\\nfor i in range(2, len(s) - 1):\\n    if (s[i] != s[i-1] or s[i] not in glas):\\n        print(s[i], end='')\\n    else:\\n        if ((s[i] == 'o') or (s[i] == 'e')) and s[i+1] != s[i] and s[i-2] != s[i]:\\n            print(s[i], end='')\\n\", \"n = int(input())\\ns = input()\\na = [[s[0]]]\\nfor i in range(1, n):\\n   if s[i] == s[i - 1]:\\n      a[-1].append(s[i])\\n   else:\\n      a.append([s[i]])\\nfor elem in a:\\n   if elem[0] in 'aeiouy':\\n      if len(elem) == 2 and elem[0] in 'eo':\\n         print(elem[0] * 2, end='')\\n      else:\\n         print(elem[0], end='')\\n   else:\\n      for i in elem:\\n         print(i, end='')\", \"n = int(input())\\ns = input()\\n\\nprint(s[0], end = '')\\nfor i in range(1, len(s)):\\n    if not(s[i - 1] == s[i] == 'a' or s[i - 1] == s[i] == 'i' or s[i - 1] == s[i] == 'u' or s[i - 1] == s[i] == 'y'):\\n        if i >= 2 and (i < len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 2] != s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 2] != s[i - 1] == s[i] == 'e' or s[i - 2] != s[i - 1] == s[i] == 'o')) or i == 1 and (i < len(s) - 1 and (s[i - 1] == s[i] == 'e' != s[i + 1] or s[i - 1] == s[i] == 'o' != s[i + 1]) or i == len(s) - 1 and (s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o')):\\n            print(s[i], end = '')\\n        elif not(s[i - 1] == s[i] == 'e' or s[i - 1] == s[i] == 'o'):\\n            print(s[i], end = '')\\n        \", \"def end(r, curr_s, curr_l):\\n    if curr_l == 0:\\n        return\\n    if (curr_s == \\\"o\\\" or curr_s == \\\"e\\\") and curr_l == 2:\\n        r.append(curr_s * 2)\\n    else:\\n        r.append(curr_s)\\n    \\n\\ndef main():\\n    n = int(input())\\n    s = input()\\n\\n    glasnie = \\\"aeiouy\\\"\\n    curr_s = \\\"\\\"\\n    curr_l = 0\\n    r = []\\n    for e in s:\\n        if e in glasnie:\\n            if e != curr_s:\\n                end(r, curr_s, curr_l)\\n                curr_s = e\\n                curr_l = 1\\n            else:\\n                curr_l += 1\\n        else:\\n            end(r, curr_s, curr_l)\\n            r.append(e)\\n            curr_s = \\\"\\\"\\n            curr_l = 0\\n    end(r, curr_s, curr_l)\\n\\n    print(\\\"\\\".join(r))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ns = list(input())\\nans = ''\\nvowels = ['a', 'e', 'i', 'o', 'u', 'y']\\nprev = ''\\neo = False\\nfor i in range(0, s.__len__()):\\n    if s[i] in vowels:\\n        if s[i] != prev:\\n            ans += s[i]\\n            eo = False\\n        elif not eo:\\n            if i != s.__len__() - 1:\\n                if prev == s[i] == 'e' and s[i + 1] == 'e' or prev == s[i] == 'o' and s[i + 1] == 'o':\\n                    eo = True\\n                elif prev == s[i] == 'e' and s[i + 1] != 'e' or prev == s[i] == 'o' and s[i + 1] != 'o':\\n                    eo = True\\n                    ans += prev\\n            else:\\n                if prev == s[i] == 'e' or prev == s[i] == 'o':\\n                    ans += prev\\n    else:\\n        eo = False\\n        ans += s[i]\\n    prev = s[i]\\nprint(ans)\", \"import sys\\nn=int(input())\\nstr=input()\\nstr=str+'##'\\ni=0\\nwhile i<n:\\n\\tif((str[i]=='e' and str[i+1]=='e' and str[i+2]!='e') or (str[i]=='o' and str[i+1]=='o' and str[i+2]!='o')):\\n\\t\\tsys.stdout.write(str[i]+str[i])\\n\\t\\ti+=2\\n\\t\\tcontinue\\n\\tif(str[i]=='e' or str[i]=='o' or str[i]=='i' or str[i]=='y' or str[i]=='u' or str[i]=='a'):\\n\\t\\tsys.stdout.write(str[i])\\n\\t\\tch=str[i];\\n\\t\\twhile(str[i]==ch):\\n\\t\\t\\ti+=1;\\n\\t\\ti-=1;\\n\\telse:\\n\\t\\tsys.stdout.write(str[i])\\n\\ti+=1\\n\", \"n = int(input())\\ns = input()\\nar = []\\ngl= [ 'a', 'e', 'i','o', 'u', 'y' ]\\ni = 0\\nwhile i < len(s):\\n    it = False\\n    if (s[i] in gl):\\n        it = True\\n    if (it):\\n        cnt = 0;\\n        c = s[i];\\n        j = i;\\n        while (j < len(s) and s[j] == s[i]):\\n            cnt += 1;\\n            j += 1;\\n\\n        if ((s[i] == 'e' or s[i] == 'o') and j - i == 2):\\n            ar.append(s[i]);\\n            ar.append(s[i]);\\n\\n        else:\\n            ar.append(s[i]);\\n        i = j;\\n    else:\\n        ar.append(s[i]);\\n        i += 1;\\nprint(''.join(ar))\\n\", \"a = input()\\ninp = input()\\na = []\\nans = \\\"\\\"\\nfor i in range(len(inp)):\\n    if (i < len(a)):\\n        continue\\n    if (inp[i] != 'a' and inp[i] != 'e' and inp[i] != 'i' and inp[i] != 'o' and inp[i] != 'u' and inp[i] != 'y'):\\n        a.append(1)\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] == inp[i + 2]):\\n        a.append(1)\\n        for k in range(i + 1, len(inp)):\\n            if (inp[k] == inp[k - 1]):\\n                a.append(0)\\n            else:\\n                break\\n        continue\\n    if (i <= len(inp) - 3 and inp[i] == inp[i + 1] and inp[i] != inp[i + 2]):\\n        if (inp[i] == 'o' or inp[i] == 'e'):\\n            a.append(1)\\n            a.append(1)\\n            continue\\n        else:\\n            a.append(1)\\n            a.append(0)\\n            continue\\n    elif (i == len(inp) - 2):\\n        if (inp[i] == inp[i + 1] and inp[i] != 'o' and inp[i] != 'e'):\\n            a.append(1)\\n            a.append(0)\\n        else:\\n            a.append(1)\\n            a.append(1)\\n        break\\n    a.append(1)\\n\\nans = \\\"\\\"\\nfor i in range(len(a)):\\n    if (a[i] == 1):\\n        ans += inp[i]\\nprint(ans)\\n\", \"n=int(input())\\ns=input()+'0'\\ni=0\\na='aeiouy'\\nb='oe'\\nans=[]\\nwhile i<n:\\n    ans.append(s[i])\\n    if s[i] in a:\\n        if s[i] in b and s[i+1]==s[i] and s[i+2]!=s[i]:\\n            ans.append(s[i])\\n            i+=2\\n        else:\\n            x=i\\n            while s[i]==s[x]:\\n                i+=1\\n    else:\\n        i+=1\\nprint(''.join(ans))\", \"n = int(input())\\ns = input()\\na = ''\\nt = \\\"aeiouy\\\"\\nfor i in range(n):\\n\\tif t.find(s[i]) < 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] != s[i-1] or i == 0:\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'e' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\telif i > 0 and s[i] == 'o' and (i < n - 1 and s[i + 1] != s[i] or i == n - 1)  and (i > 1 and s[i - 2] != s[i] or i <= 1):\\n\\t\\ta = a + s[i]\\n\\t\\t\\nprint(a)\\n \\n \\n\\\"\\\"\\\"\\n13\\npobeeeedaaaaa\\npobeda\\n22\\niiiimpleeemeentatiioon\\nimplemeentatioon\\n18\\naeiouyaaeeiioouuyy\\naeiouyaeeioouy\\n24\\naaaoooiiiuuuyyyeeeggghhh\\naoiuyeggghhh\\n\\\"\\\"\\\"\", \"n = input()\\ns = input()\\ni=0;\\nt = \\\"\\\";\\nwhile i<int(n):\\n\\tif (i==0 or s[i]!=s[i-1] or (s[i]!='a' and s[i]!='e' and s[i]!='i' and s[i]!='o' and s[i]!='u' and s[i]!='y') or (s[i]==s[i-1] and ((s[i]=='e' or s[i]=='o') and (i<2 or s[i-2]!=s[i]) and(i+1==int(n) or s[i+1]!=s[i] )))):\\n\\t\\tt+=s[i];\\n\\ti=i+1;\\nprint(t);\", \"a = int(input())\\ns = input()\\nans = \\\"\\\"\\n\\ni=0\\nwhile i<=(a-1):\\n    if (s[i]==\\\"a\\\") or  (s[i]==\\\"i\\\") or (s[i]==\\\"u\\\") or  (s[i]==\\\"y\\\"):\\n        j=i\\n        while(j<(a-1)) and (s[j]==s[j+1]):\\n            j+=1\\n        print(s[i], end=\\\"\\\")\\n        i=j+1\\n        \\n        \\n    elif (s[i]==\\\"o\\\") or  (s[i]==\\\"e\\\"):\\n        j=i\\n        while(j<a-1) and (s[j]==s[j+1]):\\n            j+=1\\n        k=1\\n        if(j-i)==1:\\n            k=2\\n        print(s[i]*k, end=\\\"\\\")\\n        i = j+1\\n        \\n    else:\\n        print(s[i], end=\\\"\\\")\\n        i+=1\", \"n = int(input())\\ns = input()\\nc = '&'\\nans = \\\"\\\"\\n\\ni = 0\\nwhile (i < n):\\n\\tj = i\\n\\twhile (j + 1 < n and s[j + 1] == s[i]): j += 1\\n\\t\\n\\t#[i, j]\\n\\tif i == j - 1 and (s[i] == 'e' or s[i] == 'o'):\\n\\t\\tans += s[i]\\n\\t\\tans += s[i + 1]\\n\\telif (s[i] == 'e' or s[i] == 'a' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u' or s[i] == 'y'):\\n\\t\\tans += s[i]\\n\\telse:\\n\\t\\tk = i\\n\\t\\twhile (k <= j):\\n\\t\\t\\tans += s[k]\\n\\t\\t\\tk += 1\\n\\n\\ti = j + 1\\n\\nprint(ans)\", \"n = int(input())\\ns = input()\\nd = (\\\"a\\\",\\\"e\\\",\\\"y\\\",\\\"u\\\",\\\"i\\\",\\\"o\\\")\\nprev = \\\"p\\\"\\nans = []\\ncount = 1\\nfor i in range(n):\\n    if s[i] == prev and s[i] in d:\\n        count+=1\\n        if (s[i] == \\\"o\\\" or s[i] == \\\"e\\\") and count == 2:\\n            if i == len(s)-1:\\n                ans.append(s[i])\\n            elif s[i+1] != s[i]:\\n                ans.append(s[i])\\n        continue\\n    ans.append(s[i])\\n    count = 1\\n    prev = s[i]\\nprint(\\\"\\\".join(ans))\", \"import re\\nn = input()\\ns = input()\\ns = re.sub(r\\\"[a]+\\\", \\\"a\\\", s)\\ns = re.sub(r\\\"[o]{3,}\\\", \\\"o\\\", s)\\ns = re.sub(r\\\"[e]{3,}\\\", \\\"e\\\", s)\\ns = re.sub(r\\\"[u]+\\\", \\\"u\\\", s)\\ns = re.sub(r\\\"[y]+\\\", \\\"y\\\", s)\\ns = re.sub(r\\\"[i]+\\\", \\\"i\\\", s)\\nprint(s);\\n\", \"n = int(input());\\na = {'a', 'o', 'e', 'u','i','y'};\\ns = input();\\ncurVolve = 'a';\\ncurCount = 0;\\nans = [];\\ni=0;\\nflag=0;\\ncurRepeat = 'e';\\nwhile i<n:\\n  if s[i] in a:\\n    curVolve = s[i];\\n    if curVolve=='e' or curVolve=='o':\\n      if flag==2:\\n        if curRepeat==curVolve:\\n          ans.pop();\\n          while i<n  and s[i]==curVolve:\\n           i+=1;\\n          i-=1;\\n          flag=0;\\n        else:\\n          flag=1;\\n          curRepeat=curVolve;\\n          ans.append(s[i]);\\n      else:\\n        if flag==0:\\n          curRepeat=curVolve;\\n          flag=1;\\n          ans.append(s[i]);\\n        else:\\n          if curRepeat==curVolve:\\n            ans.append(s[i]);\\n            flag=2;\\n          else:\\n            curRepeat=curVolve;\\n            ans.append(s[i]);\\n            flag=1;\\n    else:\\n      flag=0;\\n      ans.append(s[i]);\\n      while i<n  and s[i]==curVolve :\\n        i+=1;\\n      i-=1;\\n  else:\\n    flag=0;\\n    ans.append(s[i]);\\n  i+=1;\\n  \\nprint(''.join(ans))\", \"n=int(input(\\\"\\\"));\\na=input(\\\"\\\");\\n\\ni=0;\\ncur='';\\ncount=0;\\nwhile i<n:\\n    if a[i]!='a' and a[i]!='e' and a[i]!='y' and a[i]!='u' and  a[i]!='o' and  a[i]!='i':\\n        print(a[i], end = \\\"\\\");\\n        i=i+1;\\n    else:\\n        cur=a[i];\\n        count=0;\\n        while i<n and a[i]==cur:\\n            count=count+1; \\n            i=i+1;\\n        if count==1:\\n            print(cur, end = \\\"\\\");\\n        elif count==2 and (cur=='o' or cur=='e'):\\n            print(cur, end = \\\"\\\");\\n            print(cur, end = \\\"\\\");\\n        else:\\n            print(cur, end = \\\"\\\");\\n           \\n            \\n            \\n    \\n    \\n\\n    \", \"n = int(input())\\ns = input()\\nif len(s)==1:\\n  print(s)\\nelse:\\n  co=0\\n  ce=0\\n  ca=0\\n  cy=0\\n  cu=0\\n  ci=0\\n  r=''\\n  s+='0'\\n \\n  for i in range(0, len(s)-1):\\n    p = True\\n    p1 = False\\n    \\n    if s[i]=='o':\\n      p=False\\n      co+=1\\n      p = co==1 and s[i+1]!='o' \\n      if p==False:\\n        p= co>2 and s[i+1]!='o'\\n      if p==False:\\n        p1 = co==2 and s[i+1]!='o'\\n    else:\\n      co=0\\n      \\n    if s[i]=='e':\\n      p=False\\n      ce+=1\\n      p = ce==1 and s[i+1]!='e' \\n      if p==False:\\n        p= ce>2 and s[i+1]!='e'\\n      if p==False:\\n        p1 = ce==2 and s[i+1]!='e'\\n    else:\\n      ce=0\\n      \\n    if s[i]=='a':\\n      ca+=1\\n      p=ca==1\\n    else:\\n      ca=0\\n      \\n    if s[i]=='u':\\n      cu+=1\\n      p=cu==1\\n    else:\\n      cu=0\\n      \\n    if s[i]=='i':\\n      ci+=1\\n      p=ci==1\\n    else:\\n      ci=0\\n      \\n    if s[i]=='y':\\n      cy+=1\\n      p=cy==1\\n    else:\\n      cy=0\\n      \\n    if p1:\\n      r+=s[i]+s[i]\\n    if p:\\n      r+=s[i]\\n  print(r)\", \"gl = ('a', 'e', 'i', 'o', 'u', 'y')\\n\\ninput()\\ns = input()\\n\\nans = []\\n\\ni = 0\\nwhile i < len(s):\\n    if s[i] in gl:\\n        # print([j for j in s[i:] if j == s[i]])\\n        now = []\\n        for j in s[i:]:\\n            if j != s[i]:\\n                break\\n            now.append(j)\\n\\n        i += len(now) - 1\\n        # print(now)\\n        ans.append(s[i])\\n        if len(now) == 2 and s[i] in ('o', 'e'):\\n            ans.append(s[i])\\n\\n    else:\\n        ans += [s[i]]\\n    i += 1\\n\\n\\nprint(*ans, sep='')\\n\", \"n=input()\\ns=input()\\nx=\\\"\\\"\\nx+=s[0]\\nfor i in range(1,len(s)):\\n\\tif s[i]!=s[i-1]:\\n\\t\\tx+=' '\\n\\t\\tx+=s[i]\\n\\telse:\\n\\t\\tx+=s[i]\\nx=x.split()\\nres=\\\"\\\"\\nfor i in x:\\n\\tif (i[0]=='a'):\\n\\t\\tres+='a'\\n\\t\\tcontinue\\n\\tif (i[0]=='y'):\\n\\t\\tres+='y'\\n\\t\\tcontinue\\n\\tif (i[0]=='i'):\\n\\t\\tres+='i'\\n\\t\\tcontinue\\n\\tif (i[0]=='u'):\\n\\t\\tres+='u'\\n\\t\\tcontinue\\n\\tif (i[0]=='e'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='e'\\n\\t\\telse:\\n\\t\\t\\tres+='ee'\\t\\n\\t\\tcontinue\\n\\tif (i[0]=='o'):\\n\\t\\tif (len(i)!=2):\\n\\t\\t\\tres+='o'\\n\\t\\telse:\\n\\t\\t\\tres+='oo'\\t\\n\\t\\tcontinue\\n\\tres+=i\\nprint(res)\"]",
        "difficulty": "interview",
        "input": "3\nooo\n",
        "output": "o\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/774/K"
    },
    {
        "id": 1691,
        "task_id": 1236,
        "test_case_id": 2,
        "question": "There are n cities in Westeros. The i-th city is inhabited by a_{i} people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.\n\nThe prophecy says that if the total number of surviving residents is even, then Daenerys wins: Stannis gets beheaded, and Daenerys rises on the Iron Throne. If the total number of surviving residents is odd, Stannis wins and everything goes in the completely opposite way.\n\nLord Petyr Baelish wants to know which candidates to the throne he should support, and therefore he wonders, which one of them has a winning strategy. Answer to this question of Lord Baelish and maybe you will become the next Lord of Harrenholl.\n\n\n-----Input-----\n\nThe first line contains two positive space-separated integers, n and k (1 ≤ k ≤ n ≤ 2·10^5) — the initial number of cities in Westeros and the number of cities at which the game ends. \n\nThe second line contains n space-separated positive integers a_{i} (1 ≤ a_{i} ≤ 10^6), which represent the population of each city in Westeros.\n\n\n-----Output-----\n\nPrint string \"Daenerys\" (without the quotes), if Daenerys wins and \"Stannis\" (without the quotes), if Stannis wins.\n\n\n-----Examples-----\nInput\n3 1\n1 2 1\n\nOutput\nStannis\n\nInput\n3 1\n2 2 1\n\nOutput\nDaenerys\n\nInput\n6 3\n5 20 12 7 14 101\n\nOutput\nStannis\n\n\n\n-----Note-----\n\nIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.\n\nIn the second sample, if Stannis burns a city with two people, Daenerys burns the city with one resident, or vice versa. In any case, the last remaining city will be inhabited by two people, that is, the total sum is even, and hence Daenerys wins.",
        "solutions": "[\"def main():\\n    n, k = list(map(int, input().split()))\\n    even = 0\\n    odd = 0\\n    for elem in input().split():\\n        if int(elem) % 2 == 0:\\n            even += 1\\n        else:\\n            odd += 1\\n    turns = n - k\\n    if turns == 0:\\n        if odd % 2 == 1:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    if turns % 2 == 0:\\n        if k % 2 == 1 and even <= turns // 2:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    else:\\n        if k % 2 == 0 and even <= turns // 2 or odd <= turns // 2:\\n            return \\\"Daenerys\\\"\\n        else:\\n            return \\\"Stannis\\\"\\nprint(main())\\n\\n\\n\\n\", \"def f(n, k, l, r):\\n    if n & 1:\\n        if k == n:\\n            return bool(l & 1)\\n        elif k & 1:\\n            return n + k <= 2 * l\\n        else:\\n            return 2 * l < n + k and 2 * l > n - k - 1\\n    else:\\n        if k == n:\\n            return bool(l & 1)\\n        elif k & 1:\\n            return n - k + 1 <= 2 * l\\n        else:\\n            return False\\n\\nn, k = list(map(int, input().split(' ')))\\na = list(map(int, input().split(' ')))\\n\\nl = list([i & 1 for i in a]).count(1)\\nr = n - l\\n\\nprint('Stannis' if f(n, k, l, r) else 'Daenerys')\\n\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect\\nfrom itertools import chain, dropwhile, permutations, combinations\\nfrom collections import defaultdict, deque\\n\\ndef VI(): return list(map(int,input().split()))\\n\\ndef main(n,k,a):\\n    now = sum(a)\\n    even = sum([x%2==0 for x in a])\\n    odd = sum([x%2==1 for x in a])\\n    d = n-k\\n    D = \\\"Daenerys\\\"\\n    S = \\\"Stannis\\\"\\n    if n==k:\\n        ans = [S,D][now%2==0]\\n    elif d%2==0: # Daenerys last\\n        if k%2==0: ans = D\\n        elif even <= d//2: ans = S\\n        else: ans = D\\n    else: # Stannis last\\n        if k%2==0:\\n            if odd <= d//2 or even <= d//2: ans = D\\n            else: ans = S\\n        else:\\n            if odd <= d//2: ans = D\\n            else: ans = S\\n    print(ans)\\n\\n\\ndef main_input(info=0):\\n    n,k = VI()\\n    a = VI()\\n    main(n,k,a)\\n\\ndef __starting_point():\\n    main_input()\\n\\n__starting_point()\", \"import sys\\n\\n\\n\\ninput       = []\\ninput_index = 0\\n\\ndef next(type, number = None):\\n\\tdef next():\\n\\t\\tnonlocal input, input_index\\n\\t\\t\\n\\t\\t\\n\\t\\twhile input_index == len(input):\\n\\t\\t\\tif sys.stdin:\\n\\t\\t\\t\\tinput       = sys.stdin.readline().split()\\n\\t\\t\\t\\tinput_index = 0\\n\\t\\t\\telse:\\n\\t\\t\\t\\traise Exception()\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\tinput_index += 1\\n\\t\\t\\n\\t\\treturn input[input_index - 1]\\n\\t\\t\\n\\t\\t\\n\\tif number is None:\\n\\t\\tresult = type(next())\\n\\telse:\\n\\t\\tresult = [type(next()) for _ in range(number)]\\n\\t\\t\\n\\treturn result\\n\\t\\n\\t\\n\\t\\nn, k = next(int, 2)\\nbs = next(int, n)\\n\\noc = 0\\nfor b in bs:\\n\\toc += 1 if b % 2 == 1 else 0\\nec = n - oc\\n\\ndh = (n - k) // 2\\nsh = (n - k) - dh\\n\\n\\nif n == k:\\n\\tif oc % 2 == 0:\\n\\t\\tprint(\\\"Daenerys\\\")\\n\\telse:\\n\\t\\tprint(\\\"Stannis\\\")\\nelse:\\n\\tif k % 2 == 0:\\n\\t\\tif dh == sh:\\n\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\telse:\\n\\t\\t\\tif dh >= oc or dh >= ec:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\\telse:\\n\\t\\tif dh == sh:\\n\\t\\t\\tif sh >= ec:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\telse:\\n\\t\\t\\tif dh >= oc:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\", \"def main():\\n    n, k = map(int, input().split())\\n    even = 0\\n    odd = 0\\n    for elem in input().split():\\n        if int(elem) % 2 == 0:\\n            even += 1\\n        else:\\n            odd += 1\\n    turns = n - k\\n    if turns == 0:\\n        if odd % 2 == 1:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    if turns % 2 == 0:\\n        if k % 2 == 1 and even <= turns // 2:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    else:\\n        if k % 2 == 0 and even <= turns // 2 or odd <= turns // 2:\\n            return \\\"Daenerys\\\"\\n        else:\\n            return \\\"Stannis\\\"\\nprint(main())\", \"n, k = list(map(int, input().split()))\\no = sum(int(x) & 1 for x in input().split())\\ne, k = n - o, n - k\\nif not k:\\n    w = o & 1\\nelif k & 1:\\n    if ((n - k) & 1) and o <= (k >> 1):\\n        w = 0\\n    elif min(o, e) <= (k >> 1) and not ((n - k) & 1):\\n        w = 0\\n    else:\\n        w = 1\\nelif ((n - k) & 1) and e <= (k >> 1):\\n    w = 1\\nelse:\\n    w = 0\\nprint(['Daenerys', 'Stannis'][w])\\n\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = list(map(int, input().split()))\\n    odds = sum([x % 2 for x in a])\\n    evens = n - odds\\n    if n == k: return \\\"Daenerys\\\" if odds % 2 == 0 else \\\"Stannis\\\"\\n    moves = n - k\\n    if moves % 2 == 0: #equal number of moves and Daenerys moves last, stannis wants to destory all evens and have parity be good\\n        eachmove = moves // 2\\n        if evens <= eachmove:\\n            remodds = k\\n            if remodds % 2 == 1:\\n                return \\\"Stannis\\\"\\n        return \\\"Daenerys\\\"\\n    else: #Stannis moves last, Danerys wants to destroy all of the odds\\n        dmoves = moves//2\\n        if odds <= dmoves or (evens <= dmoves and (n - moves) % 2 == 0):\\n            return \\\"Daenerys\\\"\\n        return \\\"Stannis\\\"\\n\\n\\n\\n                \\n\\n\\nif sys.hexversion == 50594544 : sys.stdin = open(\\\"test.txt\\\")\\nprint(solve())\", \"R = lambda:list(map(int,input().split()))\\nn,k = R()\\na = R()\\nnch = 0\\nfor i in a:\\n    if i % 2 == 1:\\n        nch += 1\\nch = n - nch\\nc = n - k\\nc_dn = c // 2\\nc_st = c - c_dn\\n\\nif c == 0:\\n    if nch % 2 == 1:\\n        print('Stannis')\\n    else:\\n        print('Daenerys')\\nelif c_dn >= nch:\\n    print('Daenerys')\\nelse:\\n    if c_dn == c_st:\\n        if ch <= c_st and k % 2 == 1:\\n            print('Stannis')\\n        else:\\n            print('Daenerys')\\n    else:  \\n        if c_dn >= ch and k % 2 == 0: \\n            print('Daenerys')\\n        else: \\n            print('Stannis')\", \"n,k=input().split()\\nn=int(n)\\nk=int(k)\\ns=input()\\na=[int(i) for i in s.split()]\\nnodd=0\\nfor i in a:\\n    if(i%2!=0):\\n        nodd+=1\\nneven=len(a)-nodd\\nif(n==k):\\n    if(nodd%2==0):\\n        print(\\\"Daenerys\\\")\\n    else:\\n        print(\\\"Stannis\\\")\\nelse:\\n    if(nodd<=int((n-k)/2)):\\n        print(\\\"Daenerys\\\")\\n\\n    elif(neven<=int((n-k)/2)):\\n        if(k%2==0):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\")\\n    else:\\n        if((n-k)%2==0):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\")\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ncnt = n - k\\neven = sum([i % 2 == 0 for i in a])\\nodd = sum([i % 2 == 1 for i in a])\\nf1 = cnt % 2 == 0 and k % 2 == 1 and even <= cnt // 2\\nf2 = cnt % 2 == 1 and not (k % 2 == 0 and even <= cnt // 2 or odd <= cnt // 2)\\nf3 = cnt == 0 and odd % 2 == 1\\nans = 'Stannis' if f1 or f2 or f3 else 'Daenerys'\\nprint(ans)\", \"n, k = map(int, input().split())\\no = sum(int(x) & 1 for x in input().split())\\ne, k = n - o, n - k\\nif not k:\\n    w = o & 1\\nelif k & 1:\\n    if ((n - k) & 1) and o <= (k >> 1):\\n        w = 0\\n    elif min(o, e) <= (k >> 1) and not ((n - k) & 1):\\n        w = 0\\n    else:\\n        w = 1\\nelif ((n - k) & 1) and e <= (k >> 1):\\n    w = 1\\nelse:\\n    w = 0\\nprint(['Daenerys', 'Stannis'][w])\", \"n,k=[int(i) for i in input().split()]\\nl=[int(i) for i in input().split()]\\nno=0\\nfor i in l:\\n    no+=i%2\\nne=n-no\\nif n==k:\\n    if no%2:\\n       print(\\\"Stannis\\\")\\n    else:\\n       print(\\\"Daenerys\\\")\\nelse:\\n    if no<=(n-k)//2:\\n        print(\\\"Daenerys\\\")\\n    else:\\n        if no%2:\\n            if (n-k)%2 and ne<=(n-k)//2 and ne%2==0:\\n                print(\\\"Daenerys\\\")\\n            elif (n-k)%2==0 and (ne>(n-k)//2 or ne%2):\\n                print(\\\"Daenerys\\\")\\n            else:\\n                print(\\\"Stannis\\\")\\n        else:\\n            if (n-k)%2 and ne<=(n-k)//2 and ne%2:\\n                print(\\\"Daenerys\\\")\\n            elif (n-k)%2==0 and (ne>(n-k)//2 or ne%2==0):\\n                print(\\\"Daenerys\\\")\\n            else:\\n                print(\\\"Stannis\\\")\\n        \\n\", \"f = lambda: map(int, input().split())\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\", \"f = lambda: map(int, input().split())\\n\\nn, k = f()\\nd = n - k\\ns = d >> 1\\n\\ny = sum(q & 1 for q in f())\\nx = n - y\\n\\nt = s < y and (k & 1 or s < x) if d & 1 else k & 1 and s >= x if d else y & 1\\nprint(['Daenerys', 'Stannis'][t])\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\n\\nn, k = f()\\n\\nd = sum(q & 1 for q in f())\\n\\ns = n - k >> 1\\n\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\n\\nif n == k: q = d & 1\\n\\nprint(['Daenerys', 'Stannis'][q])\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n, k = list(map(int,input().split()))\\n\\na = list(map(int,input().split()))\\n\\ncnt1 = 0\\nfor i in range(n):\\n    cnt1 += a[i] % 2\\nans = ['Daenerys' , 'Stannis']\\nif(n == k):\\n    print(ans[sum(a)%2])\\n    return\\nif(cnt1 > (n - k)//2 and (n - cnt1) > (n - k)//2):\\n    print(ans[(n - k) % 2])\\nelse:\\n    if(cnt1 > (n - k) //2):\\n        cnt0 = n - cnt1\\n        print(ans[(sum(a) - ((n - k) - cnt0))%2])\\n        \\n    else:\\n        \\n        print(ans[(sum(a) - cnt1)%2])\\n\\n        \\n\\n    \\n\", \"n,m=map(int,input().strip().split())\\na=list(map(int,input().strip().split()))\\nx=0\\nfor i in range(n):\\n    if (a[i]&1):\\n        x=x+1\\n# print(x)\\nif (n==m):\\n    if (x&1):\\n        print(\\\"Stannis\\\")\\n    else:\\n        print(\\\"Daenerys\\\")\\nelif ((n-m)&1):\\n    if (m&1):\\n        if ((n-m)//2>=x):\\n            print(\\\"Daenerys\\\");\\n        else:\\n            print(\\\"Stannis\\\");\\n    else:\\n        if ((n-m)//2>=x or (n-m)//2>=(n-x)):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\");\\nelse:\\n    if (m&1):\\n        if ((n-m)//2>=(n-x)):\\n            print(\\\"Stannis\\\")\\n        else:\\n            print(\\\"Daenerys\\\")\\n    else:\\n        print(\\\"Daenerys\\\")\"]",
        "difficulty": "interview",
        "input": "3 1\n2 2 1\n",
        "output": "Daenerys\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/549/C"
    },
    {
        "id": 1692,
        "task_id": 1236,
        "test_case_id": 3,
        "question": "There are n cities in Westeros. The i-th city is inhabited by a_{i} people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.\n\nThe prophecy says that if the total number of surviving residents is even, then Daenerys wins: Stannis gets beheaded, and Daenerys rises on the Iron Throne. If the total number of surviving residents is odd, Stannis wins and everything goes in the completely opposite way.\n\nLord Petyr Baelish wants to know which candidates to the throne he should support, and therefore he wonders, which one of them has a winning strategy. Answer to this question of Lord Baelish and maybe you will become the next Lord of Harrenholl.\n\n\n-----Input-----\n\nThe first line contains two positive space-separated integers, n and k (1 ≤ k ≤ n ≤ 2·10^5) — the initial number of cities in Westeros and the number of cities at which the game ends. \n\nThe second line contains n space-separated positive integers a_{i} (1 ≤ a_{i} ≤ 10^6), which represent the population of each city in Westeros.\n\n\n-----Output-----\n\nPrint string \"Daenerys\" (without the quotes), if Daenerys wins and \"Stannis\" (without the quotes), if Stannis wins.\n\n\n-----Examples-----\nInput\n3 1\n1 2 1\n\nOutput\nStannis\n\nInput\n3 1\n2 2 1\n\nOutput\nDaenerys\n\nInput\n6 3\n5 20 12 7 14 101\n\nOutput\nStannis\n\n\n\n-----Note-----\n\nIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.\n\nIn the second sample, if Stannis burns a city with two people, Daenerys burns the city with one resident, or vice versa. In any case, the last remaining city will be inhabited by two people, that is, the total sum is even, and hence Daenerys wins.",
        "solutions": "[\"def main():\\n    n, k = list(map(int, input().split()))\\n    even = 0\\n    odd = 0\\n    for elem in input().split():\\n        if int(elem) % 2 == 0:\\n            even += 1\\n        else:\\n            odd += 1\\n    turns = n - k\\n    if turns == 0:\\n        if odd % 2 == 1:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    if turns % 2 == 0:\\n        if k % 2 == 1 and even <= turns // 2:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    else:\\n        if k % 2 == 0 and even <= turns // 2 or odd <= turns // 2:\\n            return \\\"Daenerys\\\"\\n        else:\\n            return \\\"Stannis\\\"\\nprint(main())\\n\\n\\n\\n\", \"def f(n, k, l, r):\\n    if n & 1:\\n        if k == n:\\n            return bool(l & 1)\\n        elif k & 1:\\n            return n + k <= 2 * l\\n        else:\\n            return 2 * l < n + k and 2 * l > n - k - 1\\n    else:\\n        if k == n:\\n            return bool(l & 1)\\n        elif k & 1:\\n            return n - k + 1 <= 2 * l\\n        else:\\n            return False\\n\\nn, k = list(map(int, input().split(' ')))\\na = list(map(int, input().split(' ')))\\n\\nl = list([i & 1 for i in a]).count(1)\\nr = n - l\\n\\nprint('Stannis' if f(n, k, l, r) else 'Daenerys')\\n\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect\\nfrom itertools import chain, dropwhile, permutations, combinations\\nfrom collections import defaultdict, deque\\n\\ndef VI(): return list(map(int,input().split()))\\n\\ndef main(n,k,a):\\n    now = sum(a)\\n    even = sum([x%2==0 for x in a])\\n    odd = sum([x%2==1 for x in a])\\n    d = n-k\\n    D = \\\"Daenerys\\\"\\n    S = \\\"Stannis\\\"\\n    if n==k:\\n        ans = [S,D][now%2==0]\\n    elif d%2==0: # Daenerys last\\n        if k%2==0: ans = D\\n        elif even <= d//2: ans = S\\n        else: ans = D\\n    else: # Stannis last\\n        if k%2==0:\\n            if odd <= d//2 or even <= d//2: ans = D\\n            else: ans = S\\n        else:\\n            if odd <= d//2: ans = D\\n            else: ans = S\\n    print(ans)\\n\\n\\ndef main_input(info=0):\\n    n,k = VI()\\n    a = VI()\\n    main(n,k,a)\\n\\ndef __starting_point():\\n    main_input()\\n\\n__starting_point()\", \"import sys\\n\\n\\n\\ninput       = []\\ninput_index = 0\\n\\ndef next(type, number = None):\\n\\tdef next():\\n\\t\\tnonlocal input, input_index\\n\\t\\t\\n\\t\\t\\n\\t\\twhile input_index == len(input):\\n\\t\\t\\tif sys.stdin:\\n\\t\\t\\t\\tinput       = sys.stdin.readline().split()\\n\\t\\t\\t\\tinput_index = 0\\n\\t\\t\\telse:\\n\\t\\t\\t\\traise Exception()\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\tinput_index += 1\\n\\t\\t\\n\\t\\treturn input[input_index - 1]\\n\\t\\t\\n\\t\\t\\n\\tif number is None:\\n\\t\\tresult = type(next())\\n\\telse:\\n\\t\\tresult = [type(next()) for _ in range(number)]\\n\\t\\t\\n\\treturn result\\n\\t\\n\\t\\n\\t\\nn, k = next(int, 2)\\nbs = next(int, n)\\n\\noc = 0\\nfor b in bs:\\n\\toc += 1 if b % 2 == 1 else 0\\nec = n - oc\\n\\ndh = (n - k) // 2\\nsh = (n - k) - dh\\n\\n\\nif n == k:\\n\\tif oc % 2 == 0:\\n\\t\\tprint(\\\"Daenerys\\\")\\n\\telse:\\n\\t\\tprint(\\\"Stannis\\\")\\nelse:\\n\\tif k % 2 == 0:\\n\\t\\tif dh == sh:\\n\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\telse:\\n\\t\\t\\tif dh >= oc or dh >= ec:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\\telse:\\n\\t\\tif dh == sh:\\n\\t\\t\\tif sh >= ec:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\telse:\\n\\t\\t\\tif dh >= oc:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\", \"def main():\\n    n, k = map(int, input().split())\\n    even = 0\\n    odd = 0\\n    for elem in input().split():\\n        if int(elem) % 2 == 0:\\n            even += 1\\n        else:\\n            odd += 1\\n    turns = n - k\\n    if turns == 0:\\n        if odd % 2 == 1:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    if turns % 2 == 0:\\n        if k % 2 == 1 and even <= turns // 2:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    else:\\n        if k % 2 == 0 and even <= turns // 2 or odd <= turns // 2:\\n            return \\\"Daenerys\\\"\\n        else:\\n            return \\\"Stannis\\\"\\nprint(main())\", \"n, k = list(map(int, input().split()))\\no = sum(int(x) & 1 for x in input().split())\\ne, k = n - o, n - k\\nif not k:\\n    w = o & 1\\nelif k & 1:\\n    if ((n - k) & 1) and o <= (k >> 1):\\n        w = 0\\n    elif min(o, e) <= (k >> 1) and not ((n - k) & 1):\\n        w = 0\\n    else:\\n        w = 1\\nelif ((n - k) & 1) and e <= (k >> 1):\\n    w = 1\\nelse:\\n    w = 0\\nprint(['Daenerys', 'Stannis'][w])\\n\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = list(map(int, input().split()))\\n    odds = sum([x % 2 for x in a])\\n    evens = n - odds\\n    if n == k: return \\\"Daenerys\\\" if odds % 2 == 0 else \\\"Stannis\\\"\\n    moves = n - k\\n    if moves % 2 == 0: #equal number of moves and Daenerys moves last, stannis wants to destory all evens and have parity be good\\n        eachmove = moves // 2\\n        if evens <= eachmove:\\n            remodds = k\\n            if remodds % 2 == 1:\\n                return \\\"Stannis\\\"\\n        return \\\"Daenerys\\\"\\n    else: #Stannis moves last, Danerys wants to destroy all of the odds\\n        dmoves = moves//2\\n        if odds <= dmoves or (evens <= dmoves and (n - moves) % 2 == 0):\\n            return \\\"Daenerys\\\"\\n        return \\\"Stannis\\\"\\n\\n\\n\\n                \\n\\n\\nif sys.hexversion == 50594544 : sys.stdin = open(\\\"test.txt\\\")\\nprint(solve())\", \"R = lambda:list(map(int,input().split()))\\nn,k = R()\\na = R()\\nnch = 0\\nfor i in a:\\n    if i % 2 == 1:\\n        nch += 1\\nch = n - nch\\nc = n - k\\nc_dn = c // 2\\nc_st = c - c_dn\\n\\nif c == 0:\\n    if nch % 2 == 1:\\n        print('Stannis')\\n    else:\\n        print('Daenerys')\\nelif c_dn >= nch:\\n    print('Daenerys')\\nelse:\\n    if c_dn == c_st:\\n        if ch <= c_st and k % 2 == 1:\\n            print('Stannis')\\n        else:\\n            print('Daenerys')\\n    else:  \\n        if c_dn >= ch and k % 2 == 0: \\n            print('Daenerys')\\n        else: \\n            print('Stannis')\", \"n,k=input().split()\\nn=int(n)\\nk=int(k)\\ns=input()\\na=[int(i) for i in s.split()]\\nnodd=0\\nfor i in a:\\n    if(i%2!=0):\\n        nodd+=1\\nneven=len(a)-nodd\\nif(n==k):\\n    if(nodd%2==0):\\n        print(\\\"Daenerys\\\")\\n    else:\\n        print(\\\"Stannis\\\")\\nelse:\\n    if(nodd<=int((n-k)/2)):\\n        print(\\\"Daenerys\\\")\\n\\n    elif(neven<=int((n-k)/2)):\\n        if(k%2==0):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\")\\n    else:\\n        if((n-k)%2==0):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\")\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ncnt = n - k\\neven = sum([i % 2 == 0 for i in a])\\nodd = sum([i % 2 == 1 for i in a])\\nf1 = cnt % 2 == 0 and k % 2 == 1 and even <= cnt // 2\\nf2 = cnt % 2 == 1 and not (k % 2 == 0 and even <= cnt // 2 or odd <= cnt // 2)\\nf3 = cnt == 0 and odd % 2 == 1\\nans = 'Stannis' if f1 or f2 or f3 else 'Daenerys'\\nprint(ans)\", \"n, k = map(int, input().split())\\no = sum(int(x) & 1 for x in input().split())\\ne, k = n - o, n - k\\nif not k:\\n    w = o & 1\\nelif k & 1:\\n    if ((n - k) & 1) and o <= (k >> 1):\\n        w = 0\\n    elif min(o, e) <= (k >> 1) and not ((n - k) & 1):\\n        w = 0\\n    else:\\n        w = 1\\nelif ((n - k) & 1) and e <= (k >> 1):\\n    w = 1\\nelse:\\n    w = 0\\nprint(['Daenerys', 'Stannis'][w])\", \"n,k=[int(i) for i in input().split()]\\nl=[int(i) for i in input().split()]\\nno=0\\nfor i in l:\\n    no+=i%2\\nne=n-no\\nif n==k:\\n    if no%2:\\n       print(\\\"Stannis\\\")\\n    else:\\n       print(\\\"Daenerys\\\")\\nelse:\\n    if no<=(n-k)//2:\\n        print(\\\"Daenerys\\\")\\n    else:\\n        if no%2:\\n            if (n-k)%2 and ne<=(n-k)//2 and ne%2==0:\\n                print(\\\"Daenerys\\\")\\n            elif (n-k)%2==0 and (ne>(n-k)//2 or ne%2):\\n                print(\\\"Daenerys\\\")\\n            else:\\n                print(\\\"Stannis\\\")\\n        else:\\n            if (n-k)%2 and ne<=(n-k)//2 and ne%2:\\n                print(\\\"Daenerys\\\")\\n            elif (n-k)%2==0 and (ne>(n-k)//2 or ne%2==0):\\n                print(\\\"Daenerys\\\")\\n            else:\\n                print(\\\"Stannis\\\")\\n        \\n\", \"f = lambda: map(int, input().split())\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\", \"f = lambda: map(int, input().split())\\n\\nn, k = f()\\nd = n - k\\ns = d >> 1\\n\\ny = sum(q & 1 for q in f())\\nx = n - y\\n\\nt = s < y and (k & 1 or s < x) if d & 1 else k & 1 and s >= x if d else y & 1\\nprint(['Daenerys', 'Stannis'][t])\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\n\\nn, k = f()\\n\\nd = sum(q & 1 for q in f())\\n\\ns = n - k >> 1\\n\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\n\\nif n == k: q = d & 1\\n\\nprint(['Daenerys', 'Stannis'][q])\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n, k = list(map(int,input().split()))\\n\\na = list(map(int,input().split()))\\n\\ncnt1 = 0\\nfor i in range(n):\\n    cnt1 += a[i] % 2\\nans = ['Daenerys' , 'Stannis']\\nif(n == k):\\n    print(ans[sum(a)%2])\\n    return\\nif(cnt1 > (n - k)//2 and (n - cnt1) > (n - k)//2):\\n    print(ans[(n - k) % 2])\\nelse:\\n    if(cnt1 > (n - k) //2):\\n        cnt0 = n - cnt1\\n        print(ans[(sum(a) - ((n - k) - cnt0))%2])\\n        \\n    else:\\n        \\n        print(ans[(sum(a) - cnt1)%2])\\n\\n        \\n\\n    \\n\", \"n,m=map(int,input().strip().split())\\na=list(map(int,input().strip().split()))\\nx=0\\nfor i in range(n):\\n    if (a[i]&1):\\n        x=x+1\\n# print(x)\\nif (n==m):\\n    if (x&1):\\n        print(\\\"Stannis\\\")\\n    else:\\n        print(\\\"Daenerys\\\")\\nelif ((n-m)&1):\\n    if (m&1):\\n        if ((n-m)//2>=x):\\n            print(\\\"Daenerys\\\");\\n        else:\\n            print(\\\"Stannis\\\");\\n    else:\\n        if ((n-m)//2>=x or (n-m)//2>=(n-x)):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\");\\nelse:\\n    if (m&1):\\n        if ((n-m)//2>=(n-x)):\\n            print(\\\"Stannis\\\")\\n        else:\\n            print(\\\"Daenerys\\\")\\n    else:\\n        print(\\\"Daenerys\\\")\"]",
        "difficulty": "interview",
        "input": "6 3\n5 20 12 7 14 101\n",
        "output": "Stannis\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/549/C"
    },
    {
        "id": 1693,
        "task_id": 1236,
        "test_case_id": 4,
        "question": "There are n cities in Westeros. The i-th city is inhabited by a_{i} people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.\n\nThe prophecy says that if the total number of surviving residents is even, then Daenerys wins: Stannis gets beheaded, and Daenerys rises on the Iron Throne. If the total number of surviving residents is odd, Stannis wins and everything goes in the completely opposite way.\n\nLord Petyr Baelish wants to know which candidates to the throne he should support, and therefore he wonders, which one of them has a winning strategy. Answer to this question of Lord Baelish and maybe you will become the next Lord of Harrenholl.\n\n\n-----Input-----\n\nThe first line contains two positive space-separated integers, n and k (1 ≤ k ≤ n ≤ 2·10^5) — the initial number of cities in Westeros and the number of cities at which the game ends. \n\nThe second line contains n space-separated positive integers a_{i} (1 ≤ a_{i} ≤ 10^6), which represent the population of each city in Westeros.\n\n\n-----Output-----\n\nPrint string \"Daenerys\" (without the quotes), if Daenerys wins and \"Stannis\" (without the quotes), if Stannis wins.\n\n\n-----Examples-----\nInput\n3 1\n1 2 1\n\nOutput\nStannis\n\nInput\n3 1\n2 2 1\n\nOutput\nDaenerys\n\nInput\n6 3\n5 20 12 7 14 101\n\nOutput\nStannis\n\n\n\n-----Note-----\n\nIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.\n\nIn the second sample, if Stannis burns a city with two people, Daenerys burns the city with one resident, or vice versa. In any case, the last remaining city will be inhabited by two people, that is, the total sum is even, and hence Daenerys wins.",
        "solutions": "[\"def main():\\n    n, k = list(map(int, input().split()))\\n    even = 0\\n    odd = 0\\n    for elem in input().split():\\n        if int(elem) % 2 == 0:\\n            even += 1\\n        else:\\n            odd += 1\\n    turns = n - k\\n    if turns == 0:\\n        if odd % 2 == 1:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    if turns % 2 == 0:\\n        if k % 2 == 1 and even <= turns // 2:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    else:\\n        if k % 2 == 0 and even <= turns // 2 or odd <= turns // 2:\\n            return \\\"Daenerys\\\"\\n        else:\\n            return \\\"Stannis\\\"\\nprint(main())\\n\\n\\n\\n\", \"def f(n, k, l, r):\\n    if n & 1:\\n        if k == n:\\n            return bool(l & 1)\\n        elif k & 1:\\n            return n + k <= 2 * l\\n        else:\\n            return 2 * l < n + k and 2 * l > n - k - 1\\n    else:\\n        if k == n:\\n            return bool(l & 1)\\n        elif k & 1:\\n            return n - k + 1 <= 2 * l\\n        else:\\n            return False\\n\\nn, k = list(map(int, input().split(' ')))\\na = list(map(int, input().split(' ')))\\n\\nl = list([i & 1 for i in a]).count(1)\\nr = n - l\\n\\nprint('Stannis' if f(n, k, l, r) else 'Daenerys')\\n\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect\\nfrom itertools import chain, dropwhile, permutations, combinations\\nfrom collections import defaultdict, deque\\n\\ndef VI(): return list(map(int,input().split()))\\n\\ndef main(n,k,a):\\n    now = sum(a)\\n    even = sum([x%2==0 for x in a])\\n    odd = sum([x%2==1 for x in a])\\n    d = n-k\\n    D = \\\"Daenerys\\\"\\n    S = \\\"Stannis\\\"\\n    if n==k:\\n        ans = [S,D][now%2==0]\\n    elif d%2==0: # Daenerys last\\n        if k%2==0: ans = D\\n        elif even <= d//2: ans = S\\n        else: ans = D\\n    else: # Stannis last\\n        if k%2==0:\\n            if odd <= d//2 or even <= d//2: ans = D\\n            else: ans = S\\n        else:\\n            if odd <= d//2: ans = D\\n            else: ans = S\\n    print(ans)\\n\\n\\ndef main_input(info=0):\\n    n,k = VI()\\n    a = VI()\\n    main(n,k,a)\\n\\ndef __starting_point():\\n    main_input()\\n\\n__starting_point()\", \"import sys\\n\\n\\n\\ninput       = []\\ninput_index = 0\\n\\ndef next(type, number = None):\\n\\tdef next():\\n\\t\\tnonlocal input, input_index\\n\\t\\t\\n\\t\\t\\n\\t\\twhile input_index == len(input):\\n\\t\\t\\tif sys.stdin:\\n\\t\\t\\t\\tinput       = sys.stdin.readline().split()\\n\\t\\t\\t\\tinput_index = 0\\n\\t\\t\\telse:\\n\\t\\t\\t\\traise Exception()\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\tinput_index += 1\\n\\t\\t\\n\\t\\treturn input[input_index - 1]\\n\\t\\t\\n\\t\\t\\n\\tif number is None:\\n\\t\\tresult = type(next())\\n\\telse:\\n\\t\\tresult = [type(next()) for _ in range(number)]\\n\\t\\t\\n\\treturn result\\n\\t\\n\\t\\n\\t\\nn, k = next(int, 2)\\nbs = next(int, n)\\n\\noc = 0\\nfor b in bs:\\n\\toc += 1 if b % 2 == 1 else 0\\nec = n - oc\\n\\ndh = (n - k) // 2\\nsh = (n - k) - dh\\n\\n\\nif n == k:\\n\\tif oc % 2 == 0:\\n\\t\\tprint(\\\"Daenerys\\\")\\n\\telse:\\n\\t\\tprint(\\\"Stannis\\\")\\nelse:\\n\\tif k % 2 == 0:\\n\\t\\tif dh == sh:\\n\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\telse:\\n\\t\\t\\tif dh >= oc or dh >= ec:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\\telse:\\n\\t\\tif dh == sh:\\n\\t\\t\\tif sh >= ec:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\telse:\\n\\t\\t\\tif dh >= oc:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\", \"def main():\\n    n, k = map(int, input().split())\\n    even = 0\\n    odd = 0\\n    for elem in input().split():\\n        if int(elem) % 2 == 0:\\n            even += 1\\n        else:\\n            odd += 1\\n    turns = n - k\\n    if turns == 0:\\n        if odd % 2 == 1:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    if turns % 2 == 0:\\n        if k % 2 == 1 and even <= turns // 2:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    else:\\n        if k % 2 == 0 and even <= turns // 2 or odd <= turns // 2:\\n            return \\\"Daenerys\\\"\\n        else:\\n            return \\\"Stannis\\\"\\nprint(main())\", \"n, k = list(map(int, input().split()))\\no = sum(int(x) & 1 for x in input().split())\\ne, k = n - o, n - k\\nif not k:\\n    w = o & 1\\nelif k & 1:\\n    if ((n - k) & 1) and o <= (k >> 1):\\n        w = 0\\n    elif min(o, e) <= (k >> 1) and not ((n - k) & 1):\\n        w = 0\\n    else:\\n        w = 1\\nelif ((n - k) & 1) and e <= (k >> 1):\\n    w = 1\\nelse:\\n    w = 0\\nprint(['Daenerys', 'Stannis'][w])\\n\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = list(map(int, input().split()))\\n    odds = sum([x % 2 for x in a])\\n    evens = n - odds\\n    if n == k: return \\\"Daenerys\\\" if odds % 2 == 0 else \\\"Stannis\\\"\\n    moves = n - k\\n    if moves % 2 == 0: #equal number of moves and Daenerys moves last, stannis wants to destory all evens and have parity be good\\n        eachmove = moves // 2\\n        if evens <= eachmove:\\n            remodds = k\\n            if remodds % 2 == 1:\\n                return \\\"Stannis\\\"\\n        return \\\"Daenerys\\\"\\n    else: #Stannis moves last, Danerys wants to destroy all of the odds\\n        dmoves = moves//2\\n        if odds <= dmoves or (evens <= dmoves and (n - moves) % 2 == 0):\\n            return \\\"Daenerys\\\"\\n        return \\\"Stannis\\\"\\n\\n\\n\\n                \\n\\n\\nif sys.hexversion == 50594544 : sys.stdin = open(\\\"test.txt\\\")\\nprint(solve())\", \"R = lambda:list(map(int,input().split()))\\nn,k = R()\\na = R()\\nnch = 0\\nfor i in a:\\n    if i % 2 == 1:\\n        nch += 1\\nch = n - nch\\nc = n - k\\nc_dn = c // 2\\nc_st = c - c_dn\\n\\nif c == 0:\\n    if nch % 2 == 1:\\n        print('Stannis')\\n    else:\\n        print('Daenerys')\\nelif c_dn >= nch:\\n    print('Daenerys')\\nelse:\\n    if c_dn == c_st:\\n        if ch <= c_st and k % 2 == 1:\\n            print('Stannis')\\n        else:\\n            print('Daenerys')\\n    else:  \\n        if c_dn >= ch and k % 2 == 0: \\n            print('Daenerys')\\n        else: \\n            print('Stannis')\", \"n,k=input().split()\\nn=int(n)\\nk=int(k)\\ns=input()\\na=[int(i) for i in s.split()]\\nnodd=0\\nfor i in a:\\n    if(i%2!=0):\\n        nodd+=1\\nneven=len(a)-nodd\\nif(n==k):\\n    if(nodd%2==0):\\n        print(\\\"Daenerys\\\")\\n    else:\\n        print(\\\"Stannis\\\")\\nelse:\\n    if(nodd<=int((n-k)/2)):\\n        print(\\\"Daenerys\\\")\\n\\n    elif(neven<=int((n-k)/2)):\\n        if(k%2==0):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\")\\n    else:\\n        if((n-k)%2==0):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\")\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ncnt = n - k\\neven = sum([i % 2 == 0 for i in a])\\nodd = sum([i % 2 == 1 for i in a])\\nf1 = cnt % 2 == 0 and k % 2 == 1 and even <= cnt // 2\\nf2 = cnt % 2 == 1 and not (k % 2 == 0 and even <= cnt // 2 or odd <= cnt // 2)\\nf3 = cnt == 0 and odd % 2 == 1\\nans = 'Stannis' if f1 or f2 or f3 else 'Daenerys'\\nprint(ans)\", \"n, k = map(int, input().split())\\no = sum(int(x) & 1 for x in input().split())\\ne, k = n - o, n - k\\nif not k:\\n    w = o & 1\\nelif k & 1:\\n    if ((n - k) & 1) and o <= (k >> 1):\\n        w = 0\\n    elif min(o, e) <= (k >> 1) and not ((n - k) & 1):\\n        w = 0\\n    else:\\n        w = 1\\nelif ((n - k) & 1) and e <= (k >> 1):\\n    w = 1\\nelse:\\n    w = 0\\nprint(['Daenerys', 'Stannis'][w])\", \"n,k=[int(i) for i in input().split()]\\nl=[int(i) for i in input().split()]\\nno=0\\nfor i in l:\\n    no+=i%2\\nne=n-no\\nif n==k:\\n    if no%2:\\n       print(\\\"Stannis\\\")\\n    else:\\n       print(\\\"Daenerys\\\")\\nelse:\\n    if no<=(n-k)//2:\\n        print(\\\"Daenerys\\\")\\n    else:\\n        if no%2:\\n            if (n-k)%2 and ne<=(n-k)//2 and ne%2==0:\\n                print(\\\"Daenerys\\\")\\n            elif (n-k)%2==0 and (ne>(n-k)//2 or ne%2):\\n                print(\\\"Daenerys\\\")\\n            else:\\n                print(\\\"Stannis\\\")\\n        else:\\n            if (n-k)%2 and ne<=(n-k)//2 and ne%2:\\n                print(\\\"Daenerys\\\")\\n            elif (n-k)%2==0 and (ne>(n-k)//2 or ne%2==0):\\n                print(\\\"Daenerys\\\")\\n            else:\\n                print(\\\"Stannis\\\")\\n        \\n\", \"f = lambda: map(int, input().split())\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\", \"f = lambda: map(int, input().split())\\n\\nn, k = f()\\nd = n - k\\ns = d >> 1\\n\\ny = sum(q & 1 for q in f())\\nx = n - y\\n\\nt = s < y and (k & 1 or s < x) if d & 1 else k & 1 and s >= x if d else y & 1\\nprint(['Daenerys', 'Stannis'][t])\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\n\\nn, k = f()\\n\\nd = sum(q & 1 for q in f())\\n\\ns = n - k >> 1\\n\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\n\\nif n == k: q = d & 1\\n\\nprint(['Daenerys', 'Stannis'][q])\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n, k = list(map(int,input().split()))\\n\\na = list(map(int,input().split()))\\n\\ncnt1 = 0\\nfor i in range(n):\\n    cnt1 += a[i] % 2\\nans = ['Daenerys' , 'Stannis']\\nif(n == k):\\n    print(ans[sum(a)%2])\\n    return\\nif(cnt1 > (n - k)//2 and (n - cnt1) > (n - k)//2):\\n    print(ans[(n - k) % 2])\\nelse:\\n    if(cnt1 > (n - k) //2):\\n        cnt0 = n - cnt1\\n        print(ans[(sum(a) - ((n - k) - cnt0))%2])\\n        \\n    else:\\n        \\n        print(ans[(sum(a) - cnt1)%2])\\n\\n        \\n\\n    \\n\", \"n,m=map(int,input().strip().split())\\na=list(map(int,input().strip().split()))\\nx=0\\nfor i in range(n):\\n    if (a[i]&1):\\n        x=x+1\\n# print(x)\\nif (n==m):\\n    if (x&1):\\n        print(\\\"Stannis\\\")\\n    else:\\n        print(\\\"Daenerys\\\")\\nelif ((n-m)&1):\\n    if (m&1):\\n        if ((n-m)//2>=x):\\n            print(\\\"Daenerys\\\");\\n        else:\\n            print(\\\"Stannis\\\");\\n    else:\\n        if ((n-m)//2>=x or (n-m)//2>=(n-x)):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\");\\nelse:\\n    if (m&1):\\n        if ((n-m)//2>=(n-x)):\\n            print(\\\"Stannis\\\")\\n        else:\\n            print(\\\"Daenerys\\\")\\n    else:\\n        print(\\\"Daenerys\\\")\"]",
        "difficulty": "interview",
        "input": "6 3\n346 118 330 1403 5244 480\n",
        "output": "Daenerys\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/549/C"
    },
    {
        "id": 1694,
        "task_id": 1236,
        "test_case_id": 7,
        "question": "There are n cities in Westeros. The i-th city is inhabited by a_{i} people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.\n\nThe prophecy says that if the total number of surviving residents is even, then Daenerys wins: Stannis gets beheaded, and Daenerys rises on the Iron Throne. If the total number of surviving residents is odd, Stannis wins and everything goes in the completely opposite way.\n\nLord Petyr Baelish wants to know which candidates to the throne he should support, and therefore he wonders, which one of them has a winning strategy. Answer to this question of Lord Baelish and maybe you will become the next Lord of Harrenholl.\n\n\n-----Input-----\n\nThe first line contains two positive space-separated integers, n and k (1 ≤ k ≤ n ≤ 2·10^5) — the initial number of cities in Westeros and the number of cities at which the game ends. \n\nThe second line contains n space-separated positive integers a_{i} (1 ≤ a_{i} ≤ 10^6), which represent the population of each city in Westeros.\n\n\n-----Output-----\n\nPrint string \"Daenerys\" (without the quotes), if Daenerys wins and \"Stannis\" (without the quotes), if Stannis wins.\n\n\n-----Examples-----\nInput\n3 1\n1 2 1\n\nOutput\nStannis\n\nInput\n3 1\n2 2 1\n\nOutput\nDaenerys\n\nInput\n6 3\n5 20 12 7 14 101\n\nOutput\nStannis\n\n\n\n-----Note-----\n\nIn the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.\n\nIn the second sample, if Stannis burns a city with two people, Daenerys burns the city with one resident, or vice versa. In any case, the last remaining city will be inhabited by two people, that is, the total sum is even, and hence Daenerys wins.",
        "solutions": "[\"def main():\\n    n, k = list(map(int, input().split()))\\n    even = 0\\n    odd = 0\\n    for elem in input().split():\\n        if int(elem) % 2 == 0:\\n            even += 1\\n        else:\\n            odd += 1\\n    turns = n - k\\n    if turns == 0:\\n        if odd % 2 == 1:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    if turns % 2 == 0:\\n        if k % 2 == 1 and even <= turns // 2:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    else:\\n        if k % 2 == 0 and even <= turns // 2 or odd <= turns // 2:\\n            return \\\"Daenerys\\\"\\n        else:\\n            return \\\"Stannis\\\"\\nprint(main())\\n\\n\\n\\n\", \"def f(n, k, l, r):\\n    if n & 1:\\n        if k == n:\\n            return bool(l & 1)\\n        elif k & 1:\\n            return n + k <= 2 * l\\n        else:\\n            return 2 * l < n + k and 2 * l > n - k - 1\\n    else:\\n        if k == n:\\n            return bool(l & 1)\\n        elif k & 1:\\n            return n - k + 1 <= 2 * l\\n        else:\\n            return False\\n\\nn, k = list(map(int, input().split(' ')))\\na = list(map(int, input().split(' ')))\\n\\nl = list([i & 1 for i in a]).count(1)\\nr = n - l\\n\\nprint('Stannis' if f(n, k, l, r) else 'Daenerys')\\n\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect\\nfrom itertools import chain, dropwhile, permutations, combinations\\nfrom collections import defaultdict, deque\\n\\ndef VI(): return list(map(int,input().split()))\\n\\ndef main(n,k,a):\\n    now = sum(a)\\n    even = sum([x%2==0 for x in a])\\n    odd = sum([x%2==1 for x in a])\\n    d = n-k\\n    D = \\\"Daenerys\\\"\\n    S = \\\"Stannis\\\"\\n    if n==k:\\n        ans = [S,D][now%2==0]\\n    elif d%2==0: # Daenerys last\\n        if k%2==0: ans = D\\n        elif even <= d//2: ans = S\\n        else: ans = D\\n    else: # Stannis last\\n        if k%2==0:\\n            if odd <= d//2 or even <= d//2: ans = D\\n            else: ans = S\\n        else:\\n            if odd <= d//2: ans = D\\n            else: ans = S\\n    print(ans)\\n\\n\\ndef main_input(info=0):\\n    n,k = VI()\\n    a = VI()\\n    main(n,k,a)\\n\\ndef __starting_point():\\n    main_input()\\n\\n__starting_point()\", \"import sys\\n\\n\\n\\ninput       = []\\ninput_index = 0\\n\\ndef next(type, number = None):\\n\\tdef next():\\n\\t\\tnonlocal input, input_index\\n\\t\\t\\n\\t\\t\\n\\t\\twhile input_index == len(input):\\n\\t\\t\\tif sys.stdin:\\n\\t\\t\\t\\tinput       = sys.stdin.readline().split()\\n\\t\\t\\t\\tinput_index = 0\\n\\t\\t\\telse:\\n\\t\\t\\t\\traise Exception()\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\tinput_index += 1\\n\\t\\t\\n\\t\\treturn input[input_index - 1]\\n\\t\\t\\n\\t\\t\\n\\tif number is None:\\n\\t\\tresult = type(next())\\n\\telse:\\n\\t\\tresult = [type(next()) for _ in range(number)]\\n\\t\\t\\n\\treturn result\\n\\t\\n\\t\\n\\t\\nn, k = next(int, 2)\\nbs = next(int, n)\\n\\noc = 0\\nfor b in bs:\\n\\toc += 1 if b % 2 == 1 else 0\\nec = n - oc\\n\\ndh = (n - k) // 2\\nsh = (n - k) - dh\\n\\n\\nif n == k:\\n\\tif oc % 2 == 0:\\n\\t\\tprint(\\\"Daenerys\\\")\\n\\telse:\\n\\t\\tprint(\\\"Stannis\\\")\\nelse:\\n\\tif k % 2 == 0:\\n\\t\\tif dh == sh:\\n\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\telse:\\n\\t\\t\\tif dh >= oc or dh >= ec:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\\telse:\\n\\t\\tif dh == sh:\\n\\t\\t\\tif sh >= ec:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\telse:\\n\\t\\t\\tif dh >= oc:\\n\\t\\t\\t\\tprint(\\\"Daenerys\\\")\\n\\t\\t\\telse:\\n\\t\\t\\t\\tprint(\\\"Stannis\\\")\\n\", \"def main():\\n    n, k = map(int, input().split())\\n    even = 0\\n    odd = 0\\n    for elem in input().split():\\n        if int(elem) % 2 == 0:\\n            even += 1\\n        else:\\n            odd += 1\\n    turns = n - k\\n    if turns == 0:\\n        if odd % 2 == 1:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    if turns % 2 == 0:\\n        if k % 2 == 1 and even <= turns // 2:\\n            return \\\"Stannis\\\"\\n        else:\\n            return \\\"Daenerys\\\"\\n    else:\\n        if k % 2 == 0 and even <= turns // 2 or odd <= turns // 2:\\n            return \\\"Daenerys\\\"\\n        else:\\n            return \\\"Stannis\\\"\\nprint(main())\", \"n, k = list(map(int, input().split()))\\no = sum(int(x) & 1 for x in input().split())\\ne, k = n - o, n - k\\nif not k:\\n    w = o & 1\\nelif k & 1:\\n    if ((n - k) & 1) and o <= (k >> 1):\\n        w = 0\\n    elif min(o, e) <= (k >> 1) and not ((n - k) & 1):\\n        w = 0\\n    else:\\n        w = 1\\nelif ((n - k) & 1) and e <= (k >> 1):\\n    w = 1\\nelse:\\n    w = 0\\nprint(['Daenerys', 'Stannis'][w])\\n\", \"import sys\\n\\ndef solve():\\n    n, k = map(int, input().split())\\n    a = list(map(int, input().split()))\\n    odds = sum([x % 2 for x in a])\\n    evens = n - odds\\n    if n == k: return \\\"Daenerys\\\" if odds % 2 == 0 else \\\"Stannis\\\"\\n    moves = n - k\\n    if moves % 2 == 0: #equal number of moves and Daenerys moves last, stannis wants to destory all evens and have parity be good\\n        eachmove = moves // 2\\n        if evens <= eachmove:\\n            remodds = k\\n            if remodds % 2 == 1:\\n                return \\\"Stannis\\\"\\n        return \\\"Daenerys\\\"\\n    else: #Stannis moves last, Danerys wants to destroy all of the odds\\n        dmoves = moves//2\\n        if odds <= dmoves or (evens <= dmoves and (n - moves) % 2 == 0):\\n            return \\\"Daenerys\\\"\\n        return \\\"Stannis\\\"\\n\\n\\n\\n                \\n\\n\\nif sys.hexversion == 50594544 : sys.stdin = open(\\\"test.txt\\\")\\nprint(solve())\", \"R = lambda:list(map(int,input().split()))\\nn,k = R()\\na = R()\\nnch = 0\\nfor i in a:\\n    if i % 2 == 1:\\n        nch += 1\\nch = n - nch\\nc = n - k\\nc_dn = c // 2\\nc_st = c - c_dn\\n\\nif c == 0:\\n    if nch % 2 == 1:\\n        print('Stannis')\\n    else:\\n        print('Daenerys')\\nelif c_dn >= nch:\\n    print('Daenerys')\\nelse:\\n    if c_dn == c_st:\\n        if ch <= c_st and k % 2 == 1:\\n            print('Stannis')\\n        else:\\n            print('Daenerys')\\n    else:  \\n        if c_dn >= ch and k % 2 == 0: \\n            print('Daenerys')\\n        else: \\n            print('Stannis')\", \"n,k=input().split()\\nn=int(n)\\nk=int(k)\\ns=input()\\na=[int(i) for i in s.split()]\\nnodd=0\\nfor i in a:\\n    if(i%2!=0):\\n        nodd+=1\\nneven=len(a)-nodd\\nif(n==k):\\n    if(nodd%2==0):\\n        print(\\\"Daenerys\\\")\\n    else:\\n        print(\\\"Stannis\\\")\\nelse:\\n    if(nodd<=int((n-k)/2)):\\n        print(\\\"Daenerys\\\")\\n\\n    elif(neven<=int((n-k)/2)):\\n        if(k%2==0):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\")\\n    else:\\n        if((n-k)%2==0):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\")\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\ncnt = n - k\\neven = sum([i % 2 == 0 for i in a])\\nodd = sum([i % 2 == 1 for i in a])\\nf1 = cnt % 2 == 0 and k % 2 == 1 and even <= cnt // 2\\nf2 = cnt % 2 == 1 and not (k % 2 == 0 and even <= cnt // 2 or odd <= cnt // 2)\\nf3 = cnt == 0 and odd % 2 == 1\\nans = 'Stannis' if f1 or f2 or f3 else 'Daenerys'\\nprint(ans)\", \"n, k = map(int, input().split())\\no = sum(int(x) & 1 for x in input().split())\\ne, k = n - o, n - k\\nif not k:\\n    w = o & 1\\nelif k & 1:\\n    if ((n - k) & 1) and o <= (k >> 1):\\n        w = 0\\n    elif min(o, e) <= (k >> 1) and not ((n - k) & 1):\\n        w = 0\\n    else:\\n        w = 1\\nelif ((n - k) & 1) and e <= (k >> 1):\\n    w = 1\\nelse:\\n    w = 0\\nprint(['Daenerys', 'Stannis'][w])\", \"n,k=[int(i) for i in input().split()]\\nl=[int(i) for i in input().split()]\\nno=0\\nfor i in l:\\n    no+=i%2\\nne=n-no\\nif n==k:\\n    if no%2:\\n       print(\\\"Stannis\\\")\\n    else:\\n       print(\\\"Daenerys\\\")\\nelse:\\n    if no<=(n-k)//2:\\n        print(\\\"Daenerys\\\")\\n    else:\\n        if no%2:\\n            if (n-k)%2 and ne<=(n-k)//2 and ne%2==0:\\n                print(\\\"Daenerys\\\")\\n            elif (n-k)%2==0 and (ne>(n-k)//2 or ne%2):\\n                print(\\\"Daenerys\\\")\\n            else:\\n                print(\\\"Stannis\\\")\\n        else:\\n            if (n-k)%2 and ne<=(n-k)//2 and ne%2:\\n                print(\\\"Daenerys\\\")\\n            elif (n-k)%2==0 and (ne>(n-k)//2 or ne%2==0):\\n                print(\\\"Daenerys\\\")\\n            else:\\n                print(\\\"Stannis\\\")\\n        \\n\", \"f = lambda: map(int, input().split())\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\", \"f = lambda: map(int, input().split())\\n\\nn, k = f()\\nd = n - k\\ns = d >> 1\\n\\ny = sum(q & 1 for q in f())\\nx = n - y\\n\\nt = s < y and (k & 1 or s < x) if d & 1 else k & 1 and s >= x if d else y & 1\\nprint(['Daenerys', 'Stannis'][t])\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\nn, k = f()\\nd = sum(q & 1 for q in f())\\ns = n - k >> 1\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\nif n == k: q = d & 1\\nprint(['Daenerys', 'Stannis'][q])\\n\", \"f = lambda: list(map(int, input().split()))\\n\\nn, k = f()\\n\\nd = sum(q & 1 for q in f())\\n\\ns = n - k >> 1\\n\\nq = s < d and (k & 1 or s < n - d) if n - k & 1 else k & 1 and s >= n - d\\n\\nif n == k: q = d & 1\\n\\nprint(['Daenerys', 'Stannis'][q])\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n, k = list(map(int,input().split()))\\n\\na = list(map(int,input().split()))\\n\\ncnt1 = 0\\nfor i in range(n):\\n    cnt1 += a[i] % 2\\nans = ['Daenerys' , 'Stannis']\\nif(n == k):\\n    print(ans[sum(a)%2])\\n    return\\nif(cnt1 > (n - k)//2 and (n - cnt1) > (n - k)//2):\\n    print(ans[(n - k) % 2])\\nelse:\\n    if(cnt1 > (n - k) //2):\\n        cnt0 = n - cnt1\\n        print(ans[(sum(a) - ((n - k) - cnt0))%2])\\n        \\n    else:\\n        \\n        print(ans[(sum(a) - cnt1)%2])\\n\\n        \\n\\n    \\n\", \"n,m=map(int,input().strip().split())\\na=list(map(int,input().strip().split()))\\nx=0\\nfor i in range(n):\\n    if (a[i]&1):\\n        x=x+1\\n# print(x)\\nif (n==m):\\n    if (x&1):\\n        print(\\\"Stannis\\\")\\n    else:\\n        print(\\\"Daenerys\\\")\\nelif ((n-m)&1):\\n    if (m&1):\\n        if ((n-m)//2>=x):\\n            print(\\\"Daenerys\\\");\\n        else:\\n            print(\\\"Stannis\\\");\\n    else:\\n        if ((n-m)//2>=x or (n-m)//2>=(n-x)):\\n            print(\\\"Daenerys\\\")\\n        else:\\n            print(\\\"Stannis\\\");\\nelse:\\n    if (m&1):\\n        if ((n-m)//2>=(n-x)):\\n            print(\\\"Stannis\\\")\\n        else:\\n            print(\\\"Daenerys\\\")\\n    else:\\n        print(\\\"Daenerys\\\")\"]",
        "difficulty": "interview",
        "input": "8 2\n1 3 22 45 21 132 78 901\n",
        "output": "Daenerys\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/549/C"
    },
    {
        "id": 1695,
        "task_id": 1237,
        "test_case_id": 1,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "3 7\n2 1\n3 8\n5 2\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1696,
        "task_id": 1237,
        "test_case_id": 2,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n",
        "output": "79\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1697,
        "task_id": 1237,
        "test_case_id": 3,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "1 1000\n1000 1000\n",
        "output": "2000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1698,
        "task_id": 1237,
        "test_case_id": 4,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "1 1\n1 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1699,
        "task_id": 1237,
        "test_case_id": 5,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "1 1000\n1 1\n",
        "output": "1000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1700,
        "task_id": 1237,
        "test_case_id": 6,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "1 1000\n1 1000\n",
        "output": "1001\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1701,
        "task_id": 1237,
        "test_case_id": 8,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 7\n6 3\n1 5\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1702,
        "task_id": 1237,
        "test_case_id": 9,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 100\n99 2\n1 10\n",
        "output": "101\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1703,
        "task_id": 1237,
        "test_case_id": 10,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "5 5\n1 1\n2 1\n3 1\n4 1\n5 1\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1704,
        "task_id": 1237,
        "test_case_id": 11,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "3 7\n1 6\n5 5\n6 1\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1705,
        "task_id": 1237,
        "test_case_id": 12,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 100\n4 100\n7 99\n",
        "output": "106\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1706,
        "task_id": 1237,
        "test_case_id": 13,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 10\n9 3\n1 4\n",
        "output": "12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1707,
        "task_id": 1237,
        "test_case_id": 14,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 5\n4 4\n5 4\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1708,
        "task_id": 1237,
        "test_case_id": 15,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 10\n9 10\n6 11\n",
        "output": "19\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1709,
        "task_id": 1237,
        "test_case_id": 16,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 100\n99 9\n1 10\n",
        "output": "108\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1710,
        "task_id": 1237,
        "test_case_id": 17,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 7\n3 5\n7 4\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1711,
        "task_id": 1237,
        "test_case_id": 18,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "4 4\n4 6\n4 8\n1 7\n2 9\n",
        "output": "12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1712,
        "task_id": 1237,
        "test_case_id": 19,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 1000\n1 2\n1000 1\n",
        "output": "1001\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1713,
        "task_id": 1237,
        "test_case_id": 20,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 20\n1 1\n2 2\n",
        "output": "20\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1714,
        "task_id": 1237,
        "test_case_id": 21,
        "question": "Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.\n\nThe elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.\n\n\n-----Input-----\n\nThe first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.\n\nThe next n lines each contain two space-separated integers f_{i} and t_{i} (1 ≤ f_{i} ≤ s, 1 ≤ t_{i} ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.\n\n\n-----Output-----\n\nPrint a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.\n\n\n-----Examples-----\nInput\n3 7\n2 1\n3 8\n5 2\n\nOutput\n11\n\nInput\n5 10\n2 77\n3 33\n8 21\n9 12\n10 64\n\nOutput\n79\n\n\n\n-----Note-----\n\nIn the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:\n\n1. Move to floor 5: takes 2 seconds.\n\n2. Pick up passenger 3.\n\n3. Move to floor 3: takes 2 seconds.\n\n4. Wait for passenger 2 to arrive: takes 4 seconds.\n\n5. Pick up passenger 2.\n\n6. Go to floor 2: takes 1 second.\n\n7. Pick up passenger 1.\n\n8. Go to floor 0: takes 2 seconds.\n\nThis gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.",
        "solutions": "[\"n, up = map(int, input().split())\\nres = 0\\nfor i in range(n):\\n    fl, t = map(int, input().split())\\n    res = max(res, max(t, up - fl) + fl)\\nprint(res)\", \"3\\n\\nn, s = list(map(int, input().split()))\\n\\nlast = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split()))\\n    last[f] = max(last[f], t)\\n\\nans = -1\\nfor i in range(s, -1, -1):\\n    ans += 1\\n    ans = max(ans, last[i])\\n\\nprint(ans)\\n\", \"read = lambda: list(map(int, input().split()))\\nn, s = read()\\nans = s\\nfor i in range(n):\\n    f, t = read()\\n    ans = max(ans, f + t)\\nprint(ans)\\n\", \"import math\\n\\n\\nn, s = tuple(map(int, input().split()))\\nfloors = [0 for i in range(s + 1)]\\n\\nfor i in range(n):\\n    floor, time = tuple(map(int, input().split()))\\n    floors[floor] = max(floors[floor], time)\\n\\nres = s\\nfor i in range(s + 1):\\n    res = max(res, floors[i] + i)\\n\\nprint(res)\\n    \\n\", \"n, s = list(map(int, input().split()))\\nmaxi = 0\\nfor i in range(n):\\n    a, b = list(map(int, input().split()))\\n    maxi = max(maxi, max(b - (s - a), 0))\\nprint(maxi + s)\\n\", \"n, s = list(map(int, input().split()))\\nL = [list(map(int, input().split())) for _ in range(n)]\\n\\nT = [s-k for k in range(s+1)]\\nfor A in L:\\n    T[A[0]] = max([T[A[0]], A[1]])\\nr = 0\\nfor k in range(s,0,-1):\\n    r = max([r,T[k]])\\n    r+=1\\nprint(r)\\n\", \"k = []\\na, b = list(map(int, input().split(' ')))\\nfor i in range(a):\\n    x, y = list(map(int, input().split(' ')))\\n    k.append([x,y])\\nk.append([0, -1])\\nk.sort()\\nk.reverse()\\n\\ncurr = b\\nt = 0\\nfor i in k:\\n    d = curr - i[0]\\n    curr = i[0]\\n    t = max(i[1], t+d)\\nprint(t)\\n\", \"#!/bin/python\\nimport collections\\nimport random\\nimport sys\\ntry:\\n    from tqdm import tqdm\\nexcept:\\n    def tqdm(iterable):\\n        return iterable\\n\\n\\n__taskname = ''\\nif __taskname:\\n    sys.stdin = open(__taskname + '.in')\\n    sys.stdout = open(__taskname + '.out', 'w')\\n\\nn, s = list(map(int, input().split()))\\ntime = 0\\nfor f, t in sorted(list(map(int, input().split())) for x in range(n)):\\n    time = max(time + s - f, t)\\n    s = f\\nprint(time + s)\\n\", \"#!/usr/bin/env python3\\n\\nN, S = list(map(int, input().split()))\\n\\nstuff = [list(map(int, input().split())) for i in range(N)]\\nanswer = S\\nfor a, k in stuff:\\n    answer = max(answer, a + k)\\n\\nprint(answer)\\n\", \"s, n = [int(i) for i in input().split()]\\nout = 0\\nfor j in range(s):\\n\\ta, b = [int(i) for i in input().split()]\\n\\tout+=(n-a)\\n\\tout=max(out, b)\\n\\tn = a\\nout +=n\\nprint(out)\\n\\t\\n\", \"#!/usr/bin/env python3\\n\\n# N = number of passengers\\n# S = level of top floor\\nN, S = list(map(int, input().split()))\\n\\narrivals = [0 for i in range(S+1)]\\nfor i in range(N):\\n    # f = floor\\n    # t = time of arrival\\n    f, t = list(map(int, input().split()))\\n    arrivals[f] = max(arrivals[f], t)\\n\\nfor i in range(S, 0, -1):\\n    arrivals[i - 1] = max(arrivals[i - 1], arrivals[i] + 1)\\nprint(arrivals[0])\\n\", \"n,s=map(int, input().split())\\nd=[]\\nfor i in range(n):\\n    a,b=map(int, input().split())\\n    d.append((a,b))\\nd.sort(reverse=True)\\nans=0\\ncurr=s\\ni=0\\nwhile i<n:\\n    ans+=(curr-d[i][0])\\n    curr=d[i][0]\\n    if d[i][1]>ans:\\n        ans=d[i][1]\\n    i+=1\\nprint(ans+d[n-1][0])\", \"n, s = map(int, input().split())\\na = [0] * (s + 1)\\nfor i in range(n):\\n    x, y = map(int, input().split())\\n    a[x] = max(a[x], y)\\nans = -1\\nfor i in range(s, 0, -1):\\n    ans = max(ans + 1, a[i])\\nprint(ans + 1)\", \"n, s = list(map(int, input().split(\\\" \\\")))\\n\\nl=[0]*(s+1)\\n\\nfor i in range (n):\\n    f, t = list(map(int, input().split(\\\" \\\")))\\n    if l[f]<t:\\n        l[f]=t\\n\\ncurrent=-1\\n\\nfor i in range (s, -1, -1):\\n    current += 1\\n    if current < l[i]:\\n        current = l[i]\\n\\nprint(current)\\n\", \"def solve():\\n    N, S = list(map(int, input().split()))\\n\\n    PS = []\\n    for i in range(N):\\n        f, t = list(map(int, input().split()))\\n        PS.append((f, t))\\n\\n    PS.sort(key=lambda p: -p[0])\\n\\n    ans = 0\\n    for f, t in PS:\\n        ans += S - f\\n        S = f\\n        if ans < t:\\n            ans = t\\n\\n    if S != 0:\\n        ans += S\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"n,s=(list(map(int,input().split())))\\ncurtime=0\\na=[]\\nfor _ in range(n):\\n    a.append(tuple(map(int,input().split())))\\na.sort()\\na.reverse()\\nfor i in a:\\n    curtime+=max(s-i[0],i[1]-curtime)\\n    s=i[0]\\nprint(curtime+a[-1][0])\\n\", \"n, s = list(map(int, input().split()))\\ncf, ct = s, 0\\nfor f, t in sorted((list(map(int, input().split())) for i in range(n)), reverse=True):\\n    ct = max(ct + cf - f, t)\\n    cf = f\\nprint(ct + cf)\\n\", \"N, top = list(map(int, input().split()))\\npa = dict()\\nfor i in range(N):\\n    f, t = list(map(int, input().split()))\\n    pa[f] = max(pa.get(f, 0), t)\\nnow, time = top, 0\\nfor f, t in sorted(list(pa.items()), reverse=True):\\n    time += now - f\\n    now = f\\n    time = max(t, time)\\nelse:\\n    time += now\\nprint(time)\\n    \\n\", \"n, s = map(int, input().split())\\nmaxSmt = 0\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    maxSmt = max(maxSmt, max(t - (s - f), 0))\\nprint(s + maxSmt)\", \"n, s = map(int, input().split())\\n\\nflats = {}\\n\\nfor i in range(n):\\n    f, t = map(int, input().split())\\n    if f not in flats:\\n        flats[f] = 0\\n    flats[f] = max(flats[f], t)\\n\\ncurr_time = 0\\nfor i in range(s, -1, -1):\\n    if i in flats:\\n        if curr_time < flats[i]:\\n            curr_time = flats[i]\\n    curr_time += 1\\n\\nprint(curr_time - 1)\", \"n, s = list(map(int, input().split()))\\na, c = [0] * 1010, s\\nfor _ in range(n):\\n    y, x = list(map(int, input().split()))\\n    c    = max(c, y + x)\\nprint(c)\\n\", \"class Event:\\n    def __init__(self, floor, time):\\n        self.floor, self.time = floor, time\\n\\nn, floor = list(map(int, input().split()))\\nevents = [ Event(*list(map(int, input().split()))) for i in range(n) ]\\nevents.sort(key=lambda event: (-event.floor, event.time))\\n\\ntime = 0\\nfor event in events:\\n    time = max(event.time, time + floor - event.floor)\\n    floor = event.floor\\ntime += floor\\nprint(time)\\n\", \"__author__ = 'Utena'\\nimport operator\\nn,s=map(int,input().split())\\np=[list(map(int,input().split()))for i in range(n)]\\np=sorted(p,key=operator.itemgetter(0,1),reverse=0)\\nt=[]\\nfor j in range(n):\\n    t.append(p[j][0]+p[j][1])\\nprint(max((max(t)),s))\", \"n, s = list(map(int, input().split(' ')[:2]))\\n\\nres = 0\\n\\nfor i in range(n):\\n    f, t = list(map(int, input().split(' ')[:2]))\\n    time = max(t, s-f) + f\\n    res = max(res, time)\\n\\nprint(res)\\n\", \"import sys\\nif False:\\n\\tinp = open('A.txt', 'r')\\nelse:\\n\\tinp = sys.stdin\\n\\nn, s = list(map(int, inp.readline().split()))\\n\\nans = s\\nfor i in range(n):\\n\\tfloor, time = list(map(int, inp.readline().split()))\\n\\tif s-floor < time:\\n\\t\\tans = max(ans, time + floor)\\n\\telse:\\n\\t\\tpass\\nprint(ans)\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 20\n10 10\n19 9\n",
        "output": "28\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/608/A"
    },
    {
        "id": 1715,
        "task_id": 1345,
        "test_case_id": 1,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 2 3 5\n",
        "output": "+++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1716,
        "task_id": 1345,
        "test_case_id": 2,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "3\n3 3 5\n",
        "output": "++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1717,
        "task_id": 1345,
        "test_case_id": 3,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "4\n2 4 5 6\n",
        "output": "-++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1718,
        "task_id": 1345,
        "test_case_id": 4,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "6\n3 5 10 11 12 20\n",
        "output": "++-++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1719,
        "task_id": 1345,
        "test_case_id": 5,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "10\n10 14 17 22 43 72 74 84 88 93\n",
        "output": "++---++--+",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1720,
        "task_id": 1345,
        "test_case_id": 6,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "11\n3 6 7 11 13 16 26 52 63 97 97\n",
        "output": "++--+-++--+",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1721,
        "task_id": 1345,
        "test_case_id": 7,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "12\n3 3 4 7 14 26 51 65 72 72 85 92\n",
        "output": "+-+--++-+--+",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1722,
        "task_id": 1345,
        "test_case_id": 8,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "40\n3 3 3 6 10 10 18 19 34 66 107 150 191 286 346 661 1061 1620 2123 3679 5030 8736 10539 19659 38608 47853 53095 71391 135905 255214 384015 694921 1357571 1364832 2046644 2595866 2918203 3547173 4880025 6274651\n",
        "output": "+-++-+-+-+-++-++-+-++--++--++--+-+-+-++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1723,
        "task_id": 1345,
        "test_case_id": 9,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "41\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
        "output": "-----------------------------------------",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1724,
        "task_id": 1345,
        "test_case_id": 10,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "42\n2 2 2 3 6 8 14 22 37 70 128 232 330 472 473 784 1481 2008 3076 4031 7504 8070 8167 11954 17832 24889 27113 41190 48727 92327 148544 186992 247329 370301 547840 621571 868209 1158781 1725242 3027208 4788036 5166155\n",
        "output": "-++-+-++--+-+-+-+-+-+-+-+--++-+-++--+--++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1725,
        "task_id": 1345,
        "test_case_id": 11,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "43\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
        "output": "-------------------------------------------",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1726,
        "task_id": 1345,
        "test_case_id": 12,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "44\n4 6 8 14 28 36 43 76 78 151 184 217 228 245 469 686 932 1279 2100 2373 4006 4368 8173 10054 18409 28333 32174 53029 90283 161047 293191 479853 875055 1206876 1423386 1878171 2601579 3319570 4571631 4999760 6742654 12515994 22557290 29338426\n",
        "output": "+-+-+-+--++-+-+-++--+-+--+--+++--++--+-+-++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1727,
        "task_id": 1345,
        "test_case_id": 13,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "45\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
        "output": "---------------------------------------------",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1728,
        "task_id": 1345,
        "test_case_id": 14,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "46\n3 6 6 8 16 19 23 46 53 90 114 131 199 361 366 523 579 1081 1457 2843 4112 4766 7187 8511 15905 22537 39546 70064 125921 214041 324358 392931 547572 954380 1012122 1057632 1150405 1393895 1915284 1969248 2541748 4451203 8201302 10912223 17210988 24485089\n",
        "output": "-+++-+--+-++-+--++-+-+-++-++-+--++--++--++-++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1729,
        "task_id": 1345,
        "test_case_id": 15,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "47\n3 3 5 6 9 13 13 14 22 33 50 76 83 100 168 303 604 1074 1417 2667 3077 4821 5129 7355 11671 22342 24237 34014 66395 73366 105385 205561 387155 756780 965476 1424160 1624526 2701046 4747339 5448855 6467013 9133423 11001389 18298303 23824100 41393164 58364321\n",
        "output": "-++--+-+-+-+-+-+-++-+-++-+--+----++-+-+--++-++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1730,
        "task_id": 1345,
        "test_case_id": 16,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "48\n4 7 12 16 23 43 61 112 134 141 243 267 484 890 1427 1558 1653 2263 2889 3313 3730 5991 10176 18243 18685 36555 40006 62099 70557 106602 122641 125854 213236 309698 379653 713328 999577 1021356 2007207 2886237 4994645 5812125 11576387 14215887 26060277 35989707 36964781 57933366\n",
        "output": "++-++-+-++---+-+-+-+--+--+-+-+-+-+-+--+-++-+-++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1731,
        "task_id": 1345,
        "test_case_id": 17,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "1\n1000000000\n",
        "output": "+",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1732,
        "task_id": 1345,
        "test_case_id": 18,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "2\n5 8\n",
        "output": "-+",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1733,
        "task_id": 1345,
        "test_case_id": 19,
        "question": "Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).\n\nVasya wants to add either a \"+\" or a \"-\" before each number of array. Thus, Vasya will get an expression consisting of n summands. The value of the resulting expression is the sum of all its elements. The task is to add signs \"+\" and \"-\" before each number so that the value of expression s meets the limits 0 ≤ s ≤ a_1. Print a sequence of signs \"+\" and \"-\", satisfying the given limits. It is guaranteed that the solution for the problem exists.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^5) — the size of the array. The second line contains space-separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) — the original array. \n\nIt is guaranteed that the condition a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} fulfills for any positive integer i (i < n).\n\n\n-----Output-----\n\nIn a single line print the sequence of n characters \"+\" and \"-\", where the i-th character is the sign that is placed in front of number a_{i}. The value of the resulting expression s must fit into the limits 0 ≤ s ≤ a_1. If there are multiple solutions, you are allowed to print any of them.\n\n\n-----Examples-----\nInput\n4\n1 2 3 5\n\nOutput\n+++-\nInput\n3\n3 3 5\n\nOutput\n++-",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split(' ')))\\n\\ntemp_sgn=1\\nsgns=[]\\ncurr_sum=0\\nfor i in range(n):\\n\\tif(curr_sum>=a[n-i-1]):\\n\\t\\tsgns.append(1)\\n\\t\\tsgns.append(-1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\telse:\\n\\t\\tsgns.append(-1)\\n\\t\\tsgns.append(1)\\n\\t\\tcurr_sum-=a[n-i-1]\\n\\t\\tcurr_sum*=-1\\nsgns.reverse()\\nans=[]\\nfor i in range(2*n):\\n\\tif(i%2==0):\\n\\t\\tans.append(temp_sgn*sgns[i])\\n\\telse:\\n\\t\\ttemp_sgn*=sgns[i]\\nfor x in ans:\\n\\tif(x==1):\\n\\t\\tprint('+',end='')\\n\\telse:\\n\\t\\tprint('-',end='')\\n\\n\"]",
        "difficulty": "interview",
        "input": "3\n1000000000 1000000000 1000000000\n",
        "output": "++-",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/257/D"
    },
    {
        "id": 1734,
        "task_id": 1384,
        "test_case_id": 1,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "4\n1 1 0 1\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1735,
        "task_id": 1384,
        "test_case_id": 3,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "1\n0\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1736,
        "task_id": 1384,
        "test_case_id": 4,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
        "output": "100\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1737,
        "task_id": 1384,
        "test_case_id": 5,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "100\n0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
        "output": "80\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1738,
        "task_id": 1384,
        "test_case_id": 7,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "100\n1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 1\n",
        "output": "53\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1739,
        "task_id": 1384,
        "test_case_id": 9,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "3\n1 0 0\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1740,
        "task_id": 1384,
        "test_case_id": 10,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "10\n1 1 0 0 0 1 1 0 0 0\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1741,
        "task_id": 1384,
        "test_case_id": 11,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "90\n1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0\n",
        "output": "52\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1742,
        "task_id": 1384,
        "test_case_id": 12,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "78\n0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0\n",
        "output": "42\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1743,
        "task_id": 1384,
        "test_case_id": 13,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "4\n1 0 0 1\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1744,
        "task_id": 1384,
        "test_case_id": 14,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "2\n0 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1745,
        "task_id": 1384,
        "test_case_id": 15,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "5\n0 1 0 0 1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1746,
        "task_id": 1384,
        "test_case_id": 16,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "3\n1 0 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1747,
        "task_id": 1384,
        "test_case_id": 17,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "3\n1 1 0\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1748,
        "task_id": 1384,
        "test_case_id": 18,
        "question": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.\n\nMore formally, you are given an array s_1, s_2, ..., s_{n} of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.\n\nBesides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.\n\n\n-----Input-----\n\nThe first line contains one integer number n (1 ≤ n ≤ 100).\n\nThe second line contains n space-separated integer numbers s_1, s_2, ..., s_{n} (0 ≤ s_{i} ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.\n\n\n-----Examples-----\nInput\n4\n1 1 0 1\n\nOutput\n3\n\nInput\n6\n0 1 0 0 1 0\n\nOutput\n4\n\nInput\n1\n0\n\nOutput\n1",
        "solutions": "[\"n = int(input())\\ns = list(map(int, input().split()))\\n\\nans = 0\\nx0 = 0\\nx1 = 0\\nfor i in range(n):\\n    if s[i] == 1:\\n        x1 = max(x0, x1) + 1\\n    else:\\n        x0 = x0 + 1\\n    ans = max(x0, x1)\\nprint(ans)\\n\", \"length = int(input())\\narray = list(map(int, input().split()))\\n\\ncount = []\\ntotal = 0\\n\\nfor k in range(length):\\n    if array[length - 1 - k] == 1:\\n        total += 1\\n    count.append(total)\\ncount.reverse()\\n\\ntotal = 0\\nmaximum = 0\\nfor k in range(length):\\n    if array[k] == 0:\\n        total += 1\\n\\n    maximum = max(maximum, total + count[k])\\n\\nprint(maximum)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = sum(a)\\nfor i in range(len(a) - 1, - 1, -1):\\n    ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\\nprint(len(a) - ans)\\n\", \"n = int(input())\\ns = list(map(int, input().split()))\\nmax_games = 0\\nfor i in range(n+1):\\n    max_games = max(max_games, s[:i].count(0) + s[i:].count(1))\\nprint(max_games)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\npref1 = [0]\\nfor i in arr:\\n    pref1.append(pref1[-1] + i)\\nsuf0 = [0]\\nfor i in arr[::-1]:\\n    suf0.append(suf0[-1] + (i + 1) % 2)\\nans = []\\nfor i in range(n + 1):\\n    ans.append(n - (suf0[::-1][i] + pref1[i]))\\nprint(max(ans))\", \"n =  int(input())\\ndata = list(map(int, input().split()))\\ndata2 = [0] * n\\ndata2[0] = data[0]\\nfor i in range(1, n):\\n    if data[i]:\\n        data2[i] = data2[i - 1] + 1\\n    else:\\n        data2[i] = data2[i - 1]\\ndata2 = [0] + data2\\nma = -2\\nfor i in range(n + 1):\\n    ma = max(ma, data2[-1] - data2[i] + i - data2[i])\\nprint(ma)\", \"\\n\\ndef solve(s):\\n    '''\\n    >>> solve([1, 1, 0, 1])\\n    3\\n    >>> solve([0, 1, 0, 0, 1, 0])\\n    4\\n    >>> solve([0])\\n    1\\n    '''\\n    zeroes = accum(s, 0)\\n    ones = list(reversed(accum(reversed(s), 1)))\\n    return max(x + y for x, y in zip(zeroes, ones))\\n\\n\\ndef accum(lst, value):\\n    counts = [0]\\n    for el in lst:\\n        if el == value:\\n            counts.append(counts[-1] + 1)\\n        else:\\n            counts.append(counts[-1])\\n    return counts\\n\\n\\ndef main():\\n    n = input()\\n    s = list(map(int, input().split()))\\n    print(solve(s))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def read_ints():\\n\\treturn [int(i) for i in input().split()]\\n\\nn = int(input())\\ns = read_ints()\\nto_rem = n if sum(s) else 0\\nfor i in range(n):\\n\\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\\n\\nprint(n - to_rem)\", \"n = int(input())\\ngames = list(map(int, input().split()))\\n\\nstrike = [0] * n\\n\\nfor i in range(n):\\n\\tstrike[i] = 1\\n\\tfor j in range(i):\\n\\t\\tif games[j] <= games[i]:\\n\\t\\t\\tstrike[i] = max(strike[i], strike[j] + 1)\\n\\n# print(strike)\\nprint(max(strike))\\n\", \"n = int(input())\\nnums = list(map(int, input().split()))\\n\\nright = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    right[i] = nums[i]\\n    if i < n - 1:\\n        right[i] += right[i + 1]\\n        \\nleft = [0 for i in range(n)]\\nfor i in range(n):\\n    left[i] = nums[i]\\n    if i > 0:\\n        left[i] += left[i - 1]\\n        \\nres = 0\\nfor i in range(-1, n):\\n    count = 0\\n    if i >= 0:\\n        count = i + 1 - left[i]\\n    if i + 1 < n:\\n        count += right[i + 1]\\n    res = max(res, count)\\n\\nprint(res)\", \"n = int(input())\\n\\ndef it():\\n  A = list(map(int,input().split()))\\n  A.reverse()\\n\\n  c1 = 0\\n  r0 = len(A) - sum(A)\\n  yield r0\\n\\n  for a in A:\\n    if a == 1:\\n      c1 += 1\\n      yield c1 + r0\\n    else:\\n      r0 -= 1\\n\\nprint(max(it()))\\n\\n\\n\", \"\\n\\nINF = 10 ** 9 + 7\\n\\n\\ndef cutoff(games, pos):\\n    leave = 0\\n\\n    for i, g in enumerate(games):\\n        if i < pos:\\n            if g == 0:\\n                leave += 1\\n        else:\\n            if g == 1:\\n                leave += 1\\n\\n    return leave\\n\\n\\ndef main():\\n    n = int(input())\\n\\n    games = [int(x) for x in input().split()]\\n\\n    max_leave = -INF\\n\\n    for i in range(n+1):\\n        max_leave = max(max_leave, cutoff(games, i))\\n\\n    print(max_leave)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nanswer = [0] * n\\nanswer[0] = 1\\n\\nfor i in range(1, n):\\n    if a[i] == 1:\\n        answer[i] = max(answer) + 1\\n    else:\\n        temp_max = 0\\n        for j in range(i):\\n            if a[j] == 0 and answer[j] > temp_max:\\n                temp_max = answer[j]\\n        answer[i] = temp_max + 1\\n        \\nprint(max(answer))\", \"import math\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nz2 = a.count(0)\\no2 = n - z2\\nz1 = 0\\no1 = 0\\n\\nres = z1 + o2\\ni = 0\\nwhile i < n:\\n\\tz2 -= (1-a[i])\\n\\tz1 += (1-a[i])\\n\\to2 -= (a[i])\\n\\to1 += (a[i])\\n\\tres = max(res, z1+o2)\\n\\ti+=1\\nprint(res)\", \"a=int(input())\\nb=[int(i) for i in input().split()]\\nc=b.copy()\\nans=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans+=(b[i:].count(1))\\n        break\\n    ans+=1\\nans1=0\\nfor i in range(a):\\n    if b[i]==1:\\n        ans1=max(ans1,b[:i].count(0)+b[i:a].count(1))\\nprint(max(ans,ans1,b.count(0),b.count(1)))\\n\\n        \\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nans = 0\\nfor i in range(a.count(0) + 1):\\n    zc = 0\\n    for j in range(n):\\n        if a[j] == 0:\\n            zc += 1\\n        if zc == i:\\n            break\\n    ans = max(ans, i + a[j:].count(1))\\nprint(ans)\", \"import sys\\nfrom collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nm = 0\\nd = Counter(a)\\nfor i in range(d[0]+1):\\n    j = 0\\n    k = 0\\n    while k != i:\\n        if a[j] == 0:\\n            k += 1\\n        j += 1\\n    while j < n:\\n        if a[j] == 1:\\n            k += 1\\n        j += 1\\n    m = max(m,k)\\nprint(m)\\n\", \"from sys import stdout\\nfrom random import randint \\nfrom math import *\\nimport re\\n\\n\\nn = int(input())\\ns = input().replace(' ', '')\\n\\nones = s.count(\\\"1\\\")\\nzeros = 0\\nmx = 0\\nfor c in s:\\n    zeros += c == '0'\\n    if zeros + ones > mx: mx = zeros + ones\\n    ones -= c == '1'\\n\\nprint(mx)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\\nprint(n - min(l))\", \"n = int(input())\\na = list(map(int, input().split()))\\np = [0] * n\\np[0]= a[0]\\nfor i in range(1, n):\\n    p[i] = p[i - 1] + a[i]\\nans = min(n, n - p[n - 1])\\nfor i in range(n):\\n    l = p[i]\\n    r = (n - i - 1) - (p[n - 1] - p[i])\\n    ans = min(ans, l + r)\\nprint(n - ans)\\n\", \"n = int(input())\\nval = list(map(int, input().split()))\\nk = 0\\nfor i in range(n + 1):\\n    k = max(k, i - sum(val[:i]) + sum(val[i:]))\\nprint(k)\", \"n = int(input())\\n\\nl = list(map(int, input().split()))\\n\\nmax_games = [1 for i in range(n)]\\n\\nif n > 1:\\n    if l[1] == 0:\\n        if l[0] == 1:\\n            max_games[1] = 1\\n        else:\\n            max_games[1] = 2\\n    else:\\n        max_games[1] = 2\\n\\nt_max = max(max_games)\\n\\nif n > 2:\\n    for i in range(2, n):\\n        if l[i] == 0:\\n            j = i - 1\\n            while (j >= 0):\\n                if l[j] == 0:\\n                    max_games[i] = max_games[j] + 1\\n                    t_max = max([t_max, max_games[i]])\\n                    break\\n                j -= 1\\n        else:\\n            max_games[i] = t_max + 1\\n            t_max += 1\\n\\n\\n\\nprint(t_max)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\n\\nans = arr.count(0)\\nfor i in range(1, n + 1):\\n    one = 0\\n    ind = -1\\n    j = n - 1\\n    for j in range(n -1, -1, -1):\\n        if one == i:\\n            ind = j\\n            break\\n        if arr[j] == 1:\\n            one += 1\\n    else:\\n        if one == i:\\n            ind = j\\n        else:\\n            break\\n    ans = max(ans, i + arr[:ind + 1].count(0))\\nprint(ans)\\n\", \"KoKoKo = int\\nkudaxKudax = input\\nkukareku = max\\nkokokokoko = print\\nkudkudax = range\\n\\n\\n\\n\\nkokoko = KoKoKo(kudaxKudax())\\nko = [KoKoKo(x) for x in kudaxKudax().split()]\\nKO = KOKOKO = 0\\nfor kok in kudkudax(kokoko - 1, -1, -1):\\n    KO += ko[kok]\\n    KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\\nkokokokoko(KOKOKO)\", \"n = int(input())\\np = list(map(int, input().split()))\\nind_z = []\\nind_o = []\\nfor i in range(n):\\n    if p[i] == 0:\\n        ind_z.append(i)\\n    else:\\n        ind_o.append(i)\\nz = [0] * len(ind_z)\\no = [0] * len(ind_o)\\nfor i in range(len(z)):\\n    z[i] = i + 1\\n    for j in range(ind_z[i], n):\\n        if p[j] == 1:\\n            z[i] += 1\\nfor i in range(len(o)):\\n    o[i] = len(o) - i \\n    for j in range(ind_o[i] - 1, -1, -1):\\n        if p[j] == 0:\\n            o[i] += 1 \\nz = [0] + z\\no = [0] + o\\nprint(max(max(o), max(z)))\"]",
        "difficulty": "interview",
        "input": "16\n1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 1\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/846/A"
    },
    {
        "id": 1749,
        "task_id": 1391,
        "test_case_id": 2,
        "question": "A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs p_{j} rubles.\n\nIn total, the boys' shared budget is a rubles. Besides, each of them has his own personal money, the i-th boy has b_{i} personal rubles. The shared budget can be spent on any schoolchildren arbitrarily, but each boy's personal money can be spent on renting only this boy's bike.\n\nEach boy can rent at most one bike, one cannot give his bike to somebody else.\n\nWhat maximum number of schoolboys will be able to ride bikes? What minimum sum of personal money will they have to spend in total to let as many schoolchildren ride bikes as possible?\n\n\n-----Input-----\n\nThe first line of the input contains three integers n, m and a (1 ≤ n, m ≤ 10^5; 0 ≤ a ≤ 10^9). The second line contains the sequence of integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 10^4), where b_{i} is the amount of the i-th boy's personal money. The third line contains the sequence of integers p_1, p_2, ..., p_{m} (1 ≤ p_{j} ≤ 10^9), where p_{j} is the price for renting the j-th bike.\n\n\n-----Output-----\n\nPrint two integers r and s, where r is the maximum number of schoolboys that can rent a bike and s is the minimum total personal money needed to rent r bikes. If the schoolchildren cannot rent any bikes, then r = s = 0.\n\n\n-----Examples-----\nInput\n2 2 10\n5 5\n7 6\n\nOutput\n2 3\n\nInput\n4 5 2\n8 1 1 2\n6 3 7 5 2\n\nOutput\n3 8\n\n\n\n-----Note-----\n\nIn the first sample both schoolchildren can rent a bike. For instance, they can split the shared budget in half (5 rubles each). In this case one of them will have to pay 1 ruble from the personal money and the other one will have to pay 2 rubles from the personal money. In total, they spend 3 rubles of their personal money. This way of distribution of money minimizes the amount of spent personal money.",
        "solutions": "[\"3\\n\\ndef readln(): return tuple(map(int, input().split()))\\n\\nn, m, a = readln()\\nb = list(sorted(readln()))\\np = list(sorted(readln()))\\n\\nl = ost = 0\\nr = min(m, n) + 1\\n\\nwhile r - l > 1:\\n    k = (r + l) // 2\\n    s = d = 0\\n    for x, y in zip(b[-k:], p[:k]):\\n        if x < y:\\n            d += y - x\\n        s += y\\n    if d <= a:\\n        l = k\\n        ost = max(0, s - a)\\n    else:\\n        r = k\\n\\nprint(l, ost)\\n\", \"3\\ndef readn():\\n  return map(int, input().split())\\n\\nn, m, a = readn()\\nn = min(n, m)\\nm = n\\nb = sorted(readn())[-n:]\\np = sorted(readn())\\nr = 0\\nwhile r < n:\\n t = (r+1 + n)//2\\n a1 = sum([max(0, p[i]-b[m+i-t]) for i in range(t)])\\n if a1 <= a:\\n   r = t\\n else:\\n   n = t-1\\nprint(r, max(0, sum(p[:r])-a))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k): return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k): return sum(min(b[n - k + i], p[i]) for i in range(k))\\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a: y = k\\n    else: x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k):\\n    return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k):\\n    return sum(min(b[n - k + i], p[i]) for i in range(k))\\n    \\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a:\\n        y = k\\n    else:\\n        x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"#!/usr/bin/env python3\\n\\nn, m, a = list(map(int, input().split()))\\nb = sorted(map(int, input().split()))\\np = sorted(map(int, input().split()))\\n\\nleft = 1\\nright = min(n, m)\\n\\nwhile left <= right:\\n    mid = (left + right) // 2\\n    if a >= sum(max(0, x - y) for x, y in zip(p[:mid], b[-mid:])):\\n        left = mid + 1\\n    else:\\n        right = mid - 1\\nprint(right, max(0, sum(p[:right]) - a))\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<r:\\n    mid=(r+1 +l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid\\n    else:\\n        r=mid-1\\nprint(l,max(0,sum(p[:l])-a))\\n\\n\\n\\n\\n\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<=r:\\n    mid=l+(r-l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid+1\\n    else:\\n        r=mid-1\\nprint(r,max(0,sum(p[:r])-a))\\n\\n\\n\\n\\n\\n\", \"wejscie1 = list(map(int,input().strip().split()))\\nilChlopcow = wejscie1[0]\\nilRowerow = wejscie1[1]\\nbudzet = wejscie1[2]\\npieniadzeChlopcow = list(map(int,input().strip().split()))\\ncenyRowerow = list(map(int,input().strip().split()))\\npieniadzeChlopcow = sorted(pieniadzeChlopcow)\\ncenyRowerow = sorted(cenyRowerow)\\nbikesBoysCanRent = 0\\ntotalCostOfRenting = 0\\nownMoneyRequired = 0\\n\\n\\n\\ndef czyMoznaWypozyczyc(ilSprawdzonychRowerow):\\n  budzet2 = budzet\\n  if ilSprawdzonychRowerow > ilChlopcow:\\n    return False\\n  for x in range(ilSprawdzonychRowerow):\\n    roznica = pieniadzeChlopcow[ilChlopcow-x-1] - cenyRowerow[ilSprawdzonychRowerow-x-1]\\n    if roznica >= 0:\\n     continue\\n    budzet2 = budzet2 + roznica\\n    if budzet2 < 0:\\n     return False\\n  return True\\n\\ndef binarySearch(lewy, prawy):\\n  while lewy<prawy:\\n    mid = (lewy + prawy + 1)//2\\n    if czyMoznaWypozyczyc(mid) == True:\\n      lewy = mid\\n    else:\\n      prawy = mid-1\\n  return lewy \\n\\n\\nbikesBoysCanRent = binarySearch(0, ilRowerow)\\n\\nfor x in range(bikesBoysCanRent):\\n  totalCostOfRenting+=cenyRowerow[x]\\nwyjscie2 = totalCostOfRenting-budzet\\nif wyjscie2 < 0:\\n  wyjscie2 = 0\\nprint(bikesBoysCanRent,wyjscie2)\\n\", \"def check(mid):\\n    need=0\\n    for i in range(mid):\\n#        print(mid,n-mid+i,i,mon,pri)\\n        if mon[n-mid+i]<pri[i]:\\n            need+=pri[i]-mon[n-mid+i]\\n    return need<=a           \\nn,m,a = list(map(int,input().split()))\\nmon = sorted(map(int,input().split()))\\npri = sorted(map(int,input().split()))\\nl=0\\nr=min(n,m)\\n#print(mon,pri)\\nwhile l<=r:\\n    mid = l +(r-l)//2\\n    if check(mid):\\n        l = mid+1\\n    else:\\n        r = mid-1\\nprint(r,max(0,sum(pri[:r])-a))\\n\\n\\n\", \"import sys\\n\\ncases = False\\n\\n# Pre-defined function\\n# Begin\\ndef fast_pow(a:int, b:int):\\n    res = 1\\n    while b > 0:\\n        if b & 1:\\n            res *= a\\n        a *= a\\n        b >>= 1\\n    return res\\n\\ndef c2(n):\\n    return n * (n-1) // 2\\n\\ndef get():\\n    return list(map(int, input().split()))\\n\\ndef bits(n: int):\\n    return list(bin(n)).count('1')\\n\\ndef main(test_case = False):\\n    n = int(input()) if test_case else 1\\n    for _ in range(n):\\n        test()\\n\\ndef flush():\\n    sys.stdout.flush()\\n\\ndef parr(arr):\\n    print(*arr, sep=' ')\\n\\ndef gcd(a, b):\\n    while b:\\n        if b % a == 0:\\n            break\\n        tmp = a\\n        a = b % a\\n        b = tmp\\n    return a\\n\\ndef ext_gcd(a: int, b: int):\\n    if (b == 0):\\n        return [a, [1, 0]]\\n \\n    res = ext_gcd(b, a % b)\\n    g = res[0]\\n    x1 = res[1][0]\\n    y1 = res[1][1]\\n    x = y1\\n    y = x1 - y1 * (a // b)\\n \\n    return [g, [x, y]]\\n\\n# End\\n\\nb = []\\np = []\\nn = m = a = 0\\n \\ndef check(cnt):\\n    if cnt == 0:\\n        return True\\n    x = b[-cnt:]\\n    y = p[:cnt]\\n    s = a\\n    i = 0\\n    while i < cnt and s >= 0:\\n        s -= max(0, y[i]-x[i])\\n        i += 1\\n    return s >= 0\\n \\ndef test():\\n    nonlocal n, m, a, b, p\\n    n, m, a = get()\\n    b = sorted(get())\\n    p = sorted(get())\\n \\n    left = 0\\n    right = min(n, m)\\n \\n    ans = -1\\n \\n    while left <= right:\\n        mid = (left + right) // 2\\n        if check(mid):\\n            ans = max(ans, mid)\\n            left = mid + 1\\n        else:\\n            right = mid - 1\\n \\n    if ans == -1:\\n        print(0, 0)\\n        return\\n \\n    # print(ans)\\n \\n    t = 0\\n    x = b[-ans:]\\n    y = p[:ans]\\n    i = 0\\n    while i < ans:\\n        t += min(x[i], y[i])\\n        a -= max(0, y[i]-x[i])\\n        i += 1\\n    print(ans, max(0, t-a)) \\n\\nmain(cases)\"]",
        "difficulty": "interview",
        "input": "4 5 2\n8 1 1 2\n6 3 7 5 2\n",
        "output": "3 8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/363/D"
    },
    {
        "id": 1750,
        "task_id": 1391,
        "test_case_id": 7,
        "question": "A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs p_{j} rubles.\n\nIn total, the boys' shared budget is a rubles. Besides, each of them has his own personal money, the i-th boy has b_{i} personal rubles. The shared budget can be spent on any schoolchildren arbitrarily, but each boy's personal money can be spent on renting only this boy's bike.\n\nEach boy can rent at most one bike, one cannot give his bike to somebody else.\n\nWhat maximum number of schoolboys will be able to ride bikes? What minimum sum of personal money will they have to spend in total to let as many schoolchildren ride bikes as possible?\n\n\n-----Input-----\n\nThe first line of the input contains three integers n, m and a (1 ≤ n, m ≤ 10^5; 0 ≤ a ≤ 10^9). The second line contains the sequence of integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 10^4), where b_{i} is the amount of the i-th boy's personal money. The third line contains the sequence of integers p_1, p_2, ..., p_{m} (1 ≤ p_{j} ≤ 10^9), where p_{j} is the price for renting the j-th bike.\n\n\n-----Output-----\n\nPrint two integers r and s, where r is the maximum number of schoolboys that can rent a bike and s is the minimum total personal money needed to rent r bikes. If the schoolchildren cannot rent any bikes, then r = s = 0.\n\n\n-----Examples-----\nInput\n2 2 10\n5 5\n7 6\n\nOutput\n2 3\n\nInput\n4 5 2\n8 1 1 2\n6 3 7 5 2\n\nOutput\n3 8\n\n\n\n-----Note-----\n\nIn the first sample both schoolchildren can rent a bike. For instance, they can split the shared budget in half (5 rubles each). In this case one of them will have to pay 1 ruble from the personal money and the other one will have to pay 2 rubles from the personal money. In total, they spend 3 rubles of their personal money. This way of distribution of money minimizes the amount of spent personal money.",
        "solutions": "[\"3\\n\\ndef readln(): return tuple(map(int, input().split()))\\n\\nn, m, a = readln()\\nb = list(sorted(readln()))\\np = list(sorted(readln()))\\n\\nl = ost = 0\\nr = min(m, n) + 1\\n\\nwhile r - l > 1:\\n    k = (r + l) // 2\\n    s = d = 0\\n    for x, y in zip(b[-k:], p[:k]):\\n        if x < y:\\n            d += y - x\\n        s += y\\n    if d <= a:\\n        l = k\\n        ost = max(0, s - a)\\n    else:\\n        r = k\\n\\nprint(l, ost)\\n\", \"3\\ndef readn():\\n  return map(int, input().split())\\n\\nn, m, a = readn()\\nn = min(n, m)\\nm = n\\nb = sorted(readn())[-n:]\\np = sorted(readn())\\nr = 0\\nwhile r < n:\\n t = (r+1 + n)//2\\n a1 = sum([max(0, p[i]-b[m+i-t]) for i in range(t)])\\n if a1 <= a:\\n   r = t\\n else:\\n   n = t-1\\nprint(r, max(0, sum(p[:r])-a))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k): return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k): return sum(min(b[n - k + i], p[i]) for i in range(k))\\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a: y = k\\n    else: x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k):\\n    return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k):\\n    return sum(min(b[n - k + i], p[i]) for i in range(k))\\n    \\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a:\\n        y = k\\n    else:\\n        x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"#!/usr/bin/env python3\\n\\nn, m, a = list(map(int, input().split()))\\nb = sorted(map(int, input().split()))\\np = sorted(map(int, input().split()))\\n\\nleft = 1\\nright = min(n, m)\\n\\nwhile left <= right:\\n    mid = (left + right) // 2\\n    if a >= sum(max(0, x - y) for x, y in zip(p[:mid], b[-mid:])):\\n        left = mid + 1\\n    else:\\n        right = mid - 1\\nprint(right, max(0, sum(p[:right]) - a))\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<r:\\n    mid=(r+1 +l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid\\n    else:\\n        r=mid-1\\nprint(l,max(0,sum(p[:l])-a))\\n\\n\\n\\n\\n\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<=r:\\n    mid=l+(r-l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid+1\\n    else:\\n        r=mid-1\\nprint(r,max(0,sum(p[:r])-a))\\n\\n\\n\\n\\n\\n\", \"wejscie1 = list(map(int,input().strip().split()))\\nilChlopcow = wejscie1[0]\\nilRowerow = wejscie1[1]\\nbudzet = wejscie1[2]\\npieniadzeChlopcow = list(map(int,input().strip().split()))\\ncenyRowerow = list(map(int,input().strip().split()))\\npieniadzeChlopcow = sorted(pieniadzeChlopcow)\\ncenyRowerow = sorted(cenyRowerow)\\nbikesBoysCanRent = 0\\ntotalCostOfRenting = 0\\nownMoneyRequired = 0\\n\\n\\n\\ndef czyMoznaWypozyczyc(ilSprawdzonychRowerow):\\n  budzet2 = budzet\\n  if ilSprawdzonychRowerow > ilChlopcow:\\n    return False\\n  for x in range(ilSprawdzonychRowerow):\\n    roznica = pieniadzeChlopcow[ilChlopcow-x-1] - cenyRowerow[ilSprawdzonychRowerow-x-1]\\n    if roznica >= 0:\\n     continue\\n    budzet2 = budzet2 + roznica\\n    if budzet2 < 0:\\n     return False\\n  return True\\n\\ndef binarySearch(lewy, prawy):\\n  while lewy<prawy:\\n    mid = (lewy + prawy + 1)//2\\n    if czyMoznaWypozyczyc(mid) == True:\\n      lewy = mid\\n    else:\\n      prawy = mid-1\\n  return lewy \\n\\n\\nbikesBoysCanRent = binarySearch(0, ilRowerow)\\n\\nfor x in range(bikesBoysCanRent):\\n  totalCostOfRenting+=cenyRowerow[x]\\nwyjscie2 = totalCostOfRenting-budzet\\nif wyjscie2 < 0:\\n  wyjscie2 = 0\\nprint(bikesBoysCanRent,wyjscie2)\\n\", \"def check(mid):\\n    need=0\\n    for i in range(mid):\\n#        print(mid,n-mid+i,i,mon,pri)\\n        if mon[n-mid+i]<pri[i]:\\n            need+=pri[i]-mon[n-mid+i]\\n    return need<=a           \\nn,m,a = list(map(int,input().split()))\\nmon = sorted(map(int,input().split()))\\npri = sorted(map(int,input().split()))\\nl=0\\nr=min(n,m)\\n#print(mon,pri)\\nwhile l<=r:\\n    mid = l +(r-l)//2\\n    if check(mid):\\n        l = mid+1\\n    else:\\n        r = mid-1\\nprint(r,max(0,sum(pri[:r])-a))\\n\\n\\n\", \"import sys\\n\\ncases = False\\n\\n# Pre-defined function\\n# Begin\\ndef fast_pow(a:int, b:int):\\n    res = 1\\n    while b > 0:\\n        if b & 1:\\n            res *= a\\n        a *= a\\n        b >>= 1\\n    return res\\n\\ndef c2(n):\\n    return n * (n-1) // 2\\n\\ndef get():\\n    return list(map(int, input().split()))\\n\\ndef bits(n: int):\\n    return list(bin(n)).count('1')\\n\\ndef main(test_case = False):\\n    n = int(input()) if test_case else 1\\n    for _ in range(n):\\n        test()\\n\\ndef flush():\\n    sys.stdout.flush()\\n\\ndef parr(arr):\\n    print(*arr, sep=' ')\\n\\ndef gcd(a, b):\\n    while b:\\n        if b % a == 0:\\n            break\\n        tmp = a\\n        a = b % a\\n        b = tmp\\n    return a\\n\\ndef ext_gcd(a: int, b: int):\\n    if (b == 0):\\n        return [a, [1, 0]]\\n \\n    res = ext_gcd(b, a % b)\\n    g = res[0]\\n    x1 = res[1][0]\\n    y1 = res[1][1]\\n    x = y1\\n    y = x1 - y1 * (a // b)\\n \\n    return [g, [x, y]]\\n\\n# End\\n\\nb = []\\np = []\\nn = m = a = 0\\n \\ndef check(cnt):\\n    if cnt == 0:\\n        return True\\n    x = b[-cnt:]\\n    y = p[:cnt]\\n    s = a\\n    i = 0\\n    while i < cnt and s >= 0:\\n        s -= max(0, y[i]-x[i])\\n        i += 1\\n    return s >= 0\\n \\ndef test():\\n    nonlocal n, m, a, b, p\\n    n, m, a = get()\\n    b = sorted(get())\\n    p = sorted(get())\\n \\n    left = 0\\n    right = min(n, m)\\n \\n    ans = -1\\n \\n    while left <= right:\\n        mid = (left + right) // 2\\n        if check(mid):\\n            ans = max(ans, mid)\\n            left = mid + 1\\n        else:\\n            right = mid - 1\\n \\n    if ans == -1:\\n        print(0, 0)\\n        return\\n \\n    # print(ans)\\n \\n    t = 0\\n    x = b[-ans:]\\n    y = p[:ans]\\n    i = 0\\n    while i < ans:\\n        t += min(x[i], y[i])\\n        a -= max(0, y[i]-x[i])\\n        i += 1\\n    print(ans, max(0, t-a)) \\n\\nmain(cases)\"]",
        "difficulty": "interview",
        "input": "4 5 6\n5 1 7 2\n8 7 3 9 8\n",
        "output": "3 12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/363/D"
    },
    {
        "id": 1751,
        "task_id": 1391,
        "test_case_id": 10,
        "question": "A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs p_{j} rubles.\n\nIn total, the boys' shared budget is a rubles. Besides, each of them has his own personal money, the i-th boy has b_{i} personal rubles. The shared budget can be spent on any schoolchildren arbitrarily, but each boy's personal money can be spent on renting only this boy's bike.\n\nEach boy can rent at most one bike, one cannot give his bike to somebody else.\n\nWhat maximum number of schoolboys will be able to ride bikes? What minimum sum of personal money will they have to spend in total to let as many schoolchildren ride bikes as possible?\n\n\n-----Input-----\n\nThe first line of the input contains three integers n, m and a (1 ≤ n, m ≤ 10^5; 0 ≤ a ≤ 10^9). The second line contains the sequence of integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 10^4), where b_{i} is the amount of the i-th boy's personal money. The third line contains the sequence of integers p_1, p_2, ..., p_{m} (1 ≤ p_{j} ≤ 10^9), where p_{j} is the price for renting the j-th bike.\n\n\n-----Output-----\n\nPrint two integers r and s, where r is the maximum number of schoolboys that can rent a bike and s is the minimum total personal money needed to rent r bikes. If the schoolchildren cannot rent any bikes, then r = s = 0.\n\n\n-----Examples-----\nInput\n2 2 10\n5 5\n7 6\n\nOutput\n2 3\n\nInput\n4 5 2\n8 1 1 2\n6 3 7 5 2\n\nOutput\n3 8\n\n\n\n-----Note-----\n\nIn the first sample both schoolchildren can rent a bike. For instance, they can split the shared budget in half (5 rubles each). In this case one of them will have to pay 1 ruble from the personal money and the other one will have to pay 2 rubles from the personal money. In total, they spend 3 rubles of their personal money. This way of distribution of money minimizes the amount of spent personal money.",
        "solutions": "[\"3\\n\\ndef readln(): return tuple(map(int, input().split()))\\n\\nn, m, a = readln()\\nb = list(sorted(readln()))\\np = list(sorted(readln()))\\n\\nl = ost = 0\\nr = min(m, n) + 1\\n\\nwhile r - l > 1:\\n    k = (r + l) // 2\\n    s = d = 0\\n    for x, y in zip(b[-k:], p[:k]):\\n        if x < y:\\n            d += y - x\\n        s += y\\n    if d <= a:\\n        l = k\\n        ost = max(0, s - a)\\n    else:\\n        r = k\\n\\nprint(l, ost)\\n\", \"3\\ndef readn():\\n  return map(int, input().split())\\n\\nn, m, a = readn()\\nn = min(n, m)\\nm = n\\nb = sorted(readn())[-n:]\\np = sorted(readn())\\nr = 0\\nwhile r < n:\\n t = (r+1 + n)//2\\n a1 = sum([max(0, p[i]-b[m+i-t]) for i in range(t)])\\n if a1 <= a:\\n   r = t\\n else:\\n   n = t-1\\nprint(r, max(0, sum(p[:r])-a))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k): return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k): return sum(min(b[n - k + i], p[i]) for i in range(k))\\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a: y = k\\n    else: x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k):\\n    return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k):\\n    return sum(min(b[n - k + i], p[i]) for i in range(k))\\n    \\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a:\\n        y = k\\n    else:\\n        x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"#!/usr/bin/env python3\\n\\nn, m, a = list(map(int, input().split()))\\nb = sorted(map(int, input().split()))\\np = sorted(map(int, input().split()))\\n\\nleft = 1\\nright = min(n, m)\\n\\nwhile left <= right:\\n    mid = (left + right) // 2\\n    if a >= sum(max(0, x - y) for x, y in zip(p[:mid], b[-mid:])):\\n        left = mid + 1\\n    else:\\n        right = mid - 1\\nprint(right, max(0, sum(p[:right]) - a))\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<r:\\n    mid=(r+1 +l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid\\n    else:\\n        r=mid-1\\nprint(l,max(0,sum(p[:l])-a))\\n\\n\\n\\n\\n\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<=r:\\n    mid=l+(r-l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid+1\\n    else:\\n        r=mid-1\\nprint(r,max(0,sum(p[:r])-a))\\n\\n\\n\\n\\n\\n\", \"wejscie1 = list(map(int,input().strip().split()))\\nilChlopcow = wejscie1[0]\\nilRowerow = wejscie1[1]\\nbudzet = wejscie1[2]\\npieniadzeChlopcow = list(map(int,input().strip().split()))\\ncenyRowerow = list(map(int,input().strip().split()))\\npieniadzeChlopcow = sorted(pieniadzeChlopcow)\\ncenyRowerow = sorted(cenyRowerow)\\nbikesBoysCanRent = 0\\ntotalCostOfRenting = 0\\nownMoneyRequired = 0\\n\\n\\n\\ndef czyMoznaWypozyczyc(ilSprawdzonychRowerow):\\n  budzet2 = budzet\\n  if ilSprawdzonychRowerow > ilChlopcow:\\n    return False\\n  for x in range(ilSprawdzonychRowerow):\\n    roznica = pieniadzeChlopcow[ilChlopcow-x-1] - cenyRowerow[ilSprawdzonychRowerow-x-1]\\n    if roznica >= 0:\\n     continue\\n    budzet2 = budzet2 + roznica\\n    if budzet2 < 0:\\n     return False\\n  return True\\n\\ndef binarySearch(lewy, prawy):\\n  while lewy<prawy:\\n    mid = (lewy + prawy + 1)//2\\n    if czyMoznaWypozyczyc(mid) == True:\\n      lewy = mid\\n    else:\\n      prawy = mid-1\\n  return lewy \\n\\n\\nbikesBoysCanRent = binarySearch(0, ilRowerow)\\n\\nfor x in range(bikesBoysCanRent):\\n  totalCostOfRenting+=cenyRowerow[x]\\nwyjscie2 = totalCostOfRenting-budzet\\nif wyjscie2 < 0:\\n  wyjscie2 = 0\\nprint(bikesBoysCanRent,wyjscie2)\\n\", \"def check(mid):\\n    need=0\\n    for i in range(mid):\\n#        print(mid,n-mid+i,i,mon,pri)\\n        if mon[n-mid+i]<pri[i]:\\n            need+=pri[i]-mon[n-mid+i]\\n    return need<=a           \\nn,m,a = list(map(int,input().split()))\\nmon = sorted(map(int,input().split()))\\npri = sorted(map(int,input().split()))\\nl=0\\nr=min(n,m)\\n#print(mon,pri)\\nwhile l<=r:\\n    mid = l +(r-l)//2\\n    if check(mid):\\n        l = mid+1\\n    else:\\n        r = mid-1\\nprint(r,max(0,sum(pri[:r])-a))\\n\\n\\n\", \"import sys\\n\\ncases = False\\n\\n# Pre-defined function\\n# Begin\\ndef fast_pow(a:int, b:int):\\n    res = 1\\n    while b > 0:\\n        if b & 1:\\n            res *= a\\n        a *= a\\n        b >>= 1\\n    return res\\n\\ndef c2(n):\\n    return n * (n-1) // 2\\n\\ndef get():\\n    return list(map(int, input().split()))\\n\\ndef bits(n: int):\\n    return list(bin(n)).count('1')\\n\\ndef main(test_case = False):\\n    n = int(input()) if test_case else 1\\n    for _ in range(n):\\n        test()\\n\\ndef flush():\\n    sys.stdout.flush()\\n\\ndef parr(arr):\\n    print(*arr, sep=' ')\\n\\ndef gcd(a, b):\\n    while b:\\n        if b % a == 0:\\n            break\\n        tmp = a\\n        a = b % a\\n        b = tmp\\n    return a\\n\\ndef ext_gcd(a: int, b: int):\\n    if (b == 0):\\n        return [a, [1, 0]]\\n \\n    res = ext_gcd(b, a % b)\\n    g = res[0]\\n    x1 = res[1][0]\\n    y1 = res[1][1]\\n    x = y1\\n    y = x1 - y1 * (a // b)\\n \\n    return [g, [x, y]]\\n\\n# End\\n\\nb = []\\np = []\\nn = m = a = 0\\n \\ndef check(cnt):\\n    if cnt == 0:\\n        return True\\n    x = b[-cnt:]\\n    y = p[:cnt]\\n    s = a\\n    i = 0\\n    while i < cnt and s >= 0:\\n        s -= max(0, y[i]-x[i])\\n        i += 1\\n    return s >= 0\\n \\ndef test():\\n    nonlocal n, m, a, b, p\\n    n, m, a = get()\\n    b = sorted(get())\\n    p = sorted(get())\\n \\n    left = 0\\n    right = min(n, m)\\n \\n    ans = -1\\n \\n    while left <= right:\\n        mid = (left + right) // 2\\n        if check(mid):\\n            ans = max(ans, mid)\\n            left = mid + 1\\n        else:\\n            right = mid - 1\\n \\n    if ans == -1:\\n        print(0, 0)\\n        return\\n \\n    # print(ans)\\n \\n    t = 0\\n    x = b[-ans:]\\n    y = p[:ans]\\n    i = 0\\n    while i < ans:\\n        t += min(x[i], y[i])\\n        a -= max(0, y[i]-x[i])\\n        i += 1\\n    print(ans, max(0, t-a)) \\n\\nmain(cases)\"]",
        "difficulty": "interview",
        "input": "6 6 2\n6 1 5 3 10 1\n11 4 7 8 11 7\n",
        "output": "3 16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/363/D"
    },
    {
        "id": 1752,
        "task_id": 1391,
        "test_case_id": 11,
        "question": "A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs p_{j} rubles.\n\nIn total, the boys' shared budget is a rubles. Besides, each of them has his own personal money, the i-th boy has b_{i} personal rubles. The shared budget can be spent on any schoolchildren arbitrarily, but each boy's personal money can be spent on renting only this boy's bike.\n\nEach boy can rent at most one bike, one cannot give his bike to somebody else.\n\nWhat maximum number of schoolboys will be able to ride bikes? What minimum sum of personal money will they have to spend in total to let as many schoolchildren ride bikes as possible?\n\n\n-----Input-----\n\nThe first line of the input contains three integers n, m and a (1 ≤ n, m ≤ 10^5; 0 ≤ a ≤ 10^9). The second line contains the sequence of integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 10^4), where b_{i} is the amount of the i-th boy's personal money. The third line contains the sequence of integers p_1, p_2, ..., p_{m} (1 ≤ p_{j} ≤ 10^9), where p_{j} is the price for renting the j-th bike.\n\n\n-----Output-----\n\nPrint two integers r and s, where r is the maximum number of schoolboys that can rent a bike and s is the minimum total personal money needed to rent r bikes. If the schoolchildren cannot rent any bikes, then r = s = 0.\n\n\n-----Examples-----\nInput\n2 2 10\n5 5\n7 6\n\nOutput\n2 3\n\nInput\n4 5 2\n8 1 1 2\n6 3 7 5 2\n\nOutput\n3 8\n\n\n\n-----Note-----\n\nIn the first sample both schoolchildren can rent a bike. For instance, they can split the shared budget in half (5 rubles each). In this case one of them will have to pay 1 ruble from the personal money and the other one will have to pay 2 rubles from the personal money. In total, they spend 3 rubles of their personal money. This way of distribution of money minimizes the amount of spent personal money.",
        "solutions": "[\"3\\n\\ndef readln(): return tuple(map(int, input().split()))\\n\\nn, m, a = readln()\\nb = list(sorted(readln()))\\np = list(sorted(readln()))\\n\\nl = ost = 0\\nr = min(m, n) + 1\\n\\nwhile r - l > 1:\\n    k = (r + l) // 2\\n    s = d = 0\\n    for x, y in zip(b[-k:], p[:k]):\\n        if x < y:\\n            d += y - x\\n        s += y\\n    if d <= a:\\n        l = k\\n        ost = max(0, s - a)\\n    else:\\n        r = k\\n\\nprint(l, ost)\\n\", \"3\\ndef readn():\\n  return map(int, input().split())\\n\\nn, m, a = readn()\\nn = min(n, m)\\nm = n\\nb = sorted(readn())[-n:]\\np = sorted(readn())\\nr = 0\\nwhile r < n:\\n t = (r+1 + n)//2\\n a1 = sum([max(0, p[i]-b[m+i-t]) for i in range(t)])\\n if a1 <= a:\\n   r = t\\n else:\\n   n = t-1\\nprint(r, max(0, sum(p[:r])-a))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k): return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k): return sum(min(b[n - k + i], p[i]) for i in range(k))\\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a: y = k\\n    else: x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k):\\n    return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k):\\n    return sum(min(b[n - k + i], p[i]) for i in range(k))\\n    \\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a:\\n        y = k\\n    else:\\n        x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"#!/usr/bin/env python3\\n\\nn, m, a = list(map(int, input().split()))\\nb = sorted(map(int, input().split()))\\np = sorted(map(int, input().split()))\\n\\nleft = 1\\nright = min(n, m)\\n\\nwhile left <= right:\\n    mid = (left + right) // 2\\n    if a >= sum(max(0, x - y) for x, y in zip(p[:mid], b[-mid:])):\\n        left = mid + 1\\n    else:\\n        right = mid - 1\\nprint(right, max(0, sum(p[:right]) - a))\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<r:\\n    mid=(r+1 +l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid\\n    else:\\n        r=mid-1\\nprint(l,max(0,sum(p[:l])-a))\\n\\n\\n\\n\\n\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<=r:\\n    mid=l+(r-l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid+1\\n    else:\\n        r=mid-1\\nprint(r,max(0,sum(p[:r])-a))\\n\\n\\n\\n\\n\\n\", \"wejscie1 = list(map(int,input().strip().split()))\\nilChlopcow = wejscie1[0]\\nilRowerow = wejscie1[1]\\nbudzet = wejscie1[2]\\npieniadzeChlopcow = list(map(int,input().strip().split()))\\ncenyRowerow = list(map(int,input().strip().split()))\\npieniadzeChlopcow = sorted(pieniadzeChlopcow)\\ncenyRowerow = sorted(cenyRowerow)\\nbikesBoysCanRent = 0\\ntotalCostOfRenting = 0\\nownMoneyRequired = 0\\n\\n\\n\\ndef czyMoznaWypozyczyc(ilSprawdzonychRowerow):\\n  budzet2 = budzet\\n  if ilSprawdzonychRowerow > ilChlopcow:\\n    return False\\n  for x in range(ilSprawdzonychRowerow):\\n    roznica = pieniadzeChlopcow[ilChlopcow-x-1] - cenyRowerow[ilSprawdzonychRowerow-x-1]\\n    if roznica >= 0:\\n     continue\\n    budzet2 = budzet2 + roznica\\n    if budzet2 < 0:\\n     return False\\n  return True\\n\\ndef binarySearch(lewy, prawy):\\n  while lewy<prawy:\\n    mid = (lewy + prawy + 1)//2\\n    if czyMoznaWypozyczyc(mid) == True:\\n      lewy = mid\\n    else:\\n      prawy = mid-1\\n  return lewy \\n\\n\\nbikesBoysCanRent = binarySearch(0, ilRowerow)\\n\\nfor x in range(bikesBoysCanRent):\\n  totalCostOfRenting+=cenyRowerow[x]\\nwyjscie2 = totalCostOfRenting-budzet\\nif wyjscie2 < 0:\\n  wyjscie2 = 0\\nprint(bikesBoysCanRent,wyjscie2)\\n\", \"def check(mid):\\n    need=0\\n    for i in range(mid):\\n#        print(mid,n-mid+i,i,mon,pri)\\n        if mon[n-mid+i]<pri[i]:\\n            need+=pri[i]-mon[n-mid+i]\\n    return need<=a           \\nn,m,a = list(map(int,input().split()))\\nmon = sorted(map(int,input().split()))\\npri = sorted(map(int,input().split()))\\nl=0\\nr=min(n,m)\\n#print(mon,pri)\\nwhile l<=r:\\n    mid = l +(r-l)//2\\n    if check(mid):\\n        l = mid+1\\n    else:\\n        r = mid-1\\nprint(r,max(0,sum(pri[:r])-a))\\n\\n\\n\", \"import sys\\n\\ncases = False\\n\\n# Pre-defined function\\n# Begin\\ndef fast_pow(a:int, b:int):\\n    res = 1\\n    while b > 0:\\n        if b & 1:\\n            res *= a\\n        a *= a\\n        b >>= 1\\n    return res\\n\\ndef c2(n):\\n    return n * (n-1) // 2\\n\\ndef get():\\n    return list(map(int, input().split()))\\n\\ndef bits(n: int):\\n    return list(bin(n)).count('1')\\n\\ndef main(test_case = False):\\n    n = int(input()) if test_case else 1\\n    for _ in range(n):\\n        test()\\n\\ndef flush():\\n    sys.stdout.flush()\\n\\ndef parr(arr):\\n    print(*arr, sep=' ')\\n\\ndef gcd(a, b):\\n    while b:\\n        if b % a == 0:\\n            break\\n        tmp = a\\n        a = b % a\\n        b = tmp\\n    return a\\n\\ndef ext_gcd(a: int, b: int):\\n    if (b == 0):\\n        return [a, [1, 0]]\\n \\n    res = ext_gcd(b, a % b)\\n    g = res[0]\\n    x1 = res[1][0]\\n    y1 = res[1][1]\\n    x = y1\\n    y = x1 - y1 * (a // b)\\n \\n    return [g, [x, y]]\\n\\n# End\\n\\nb = []\\np = []\\nn = m = a = 0\\n \\ndef check(cnt):\\n    if cnt == 0:\\n        return True\\n    x = b[-cnt:]\\n    y = p[:cnt]\\n    s = a\\n    i = 0\\n    while i < cnt and s >= 0:\\n        s -= max(0, y[i]-x[i])\\n        i += 1\\n    return s >= 0\\n \\ndef test():\\n    nonlocal n, m, a, b, p\\n    n, m, a = get()\\n    b = sorted(get())\\n    p = sorted(get())\\n \\n    left = 0\\n    right = min(n, m)\\n \\n    ans = -1\\n \\n    while left <= right:\\n        mid = (left + right) // 2\\n        if check(mid):\\n            ans = max(ans, mid)\\n            left = mid + 1\\n        else:\\n            right = mid - 1\\n \\n    if ans == -1:\\n        print(0, 0)\\n        return\\n \\n    # print(ans)\\n \\n    t = 0\\n    x = b[-ans:]\\n    y = p[:ans]\\n    i = 0\\n    while i < ans:\\n        t += min(x[i], y[i])\\n        a -= max(0, y[i]-x[i])\\n        i += 1\\n    print(ans, max(0, t-a)) \\n\\nmain(cases)\"]",
        "difficulty": "interview",
        "input": "10 10 7\n6 7 15 1 3 1 14 6 7 4\n15 3 13 17 11 19 20 14 8 17\n",
        "output": "5 42\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/363/D"
    },
    {
        "id": 1753,
        "task_id": 1391,
        "test_case_id": 12,
        "question": "A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs p_{j} rubles.\n\nIn total, the boys' shared budget is a rubles. Besides, each of them has his own personal money, the i-th boy has b_{i} personal rubles. The shared budget can be spent on any schoolchildren arbitrarily, but each boy's personal money can be spent on renting only this boy's bike.\n\nEach boy can rent at most one bike, one cannot give his bike to somebody else.\n\nWhat maximum number of schoolboys will be able to ride bikes? What minimum sum of personal money will they have to spend in total to let as many schoolchildren ride bikes as possible?\n\n\n-----Input-----\n\nThe first line of the input contains three integers n, m and a (1 ≤ n, m ≤ 10^5; 0 ≤ a ≤ 10^9). The second line contains the sequence of integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 10^4), where b_{i} is the amount of the i-th boy's personal money. The third line contains the sequence of integers p_1, p_2, ..., p_{m} (1 ≤ p_{j} ≤ 10^9), where p_{j} is the price for renting the j-th bike.\n\n\n-----Output-----\n\nPrint two integers r and s, where r is the maximum number of schoolboys that can rent a bike and s is the minimum total personal money needed to rent r bikes. If the schoolchildren cannot rent any bikes, then r = s = 0.\n\n\n-----Examples-----\nInput\n2 2 10\n5 5\n7 6\n\nOutput\n2 3\n\nInput\n4 5 2\n8 1 1 2\n6 3 7 5 2\n\nOutput\n3 8\n\n\n\n-----Note-----\n\nIn the first sample both schoolchildren can rent a bike. For instance, they can split the shared budget in half (5 rubles each). In this case one of them will have to pay 1 ruble from the personal money and the other one will have to pay 2 rubles from the personal money. In total, they spend 3 rubles of their personal money. This way of distribution of money minimizes the amount of spent personal money.",
        "solutions": "[\"3\\n\\ndef readln(): return tuple(map(int, input().split()))\\n\\nn, m, a = readln()\\nb = list(sorted(readln()))\\np = list(sorted(readln()))\\n\\nl = ost = 0\\nr = min(m, n) + 1\\n\\nwhile r - l > 1:\\n    k = (r + l) // 2\\n    s = d = 0\\n    for x, y in zip(b[-k:], p[:k]):\\n        if x < y:\\n            d += y - x\\n        s += y\\n    if d <= a:\\n        l = k\\n        ost = max(0, s - a)\\n    else:\\n        r = k\\n\\nprint(l, ost)\\n\", \"3\\ndef readn():\\n  return map(int, input().split())\\n\\nn, m, a = readn()\\nn = min(n, m)\\nm = n\\nb = sorted(readn())[-n:]\\np = sorted(readn())\\nr = 0\\nwhile r < n:\\n t = (r+1 + n)//2\\n a1 = sum([max(0, p[i]-b[m+i-t]) for i in range(t)])\\n if a1 <= a:\\n   r = t\\n else:\\n   n = t-1\\nprint(r, max(0, sum(p[:r])-a))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k): return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k): return sum(min(b[n - k + i], p[i]) for i in range(k))\\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a: y = k\\n    else: x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k):\\n    return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k):\\n    return sum(min(b[n - k + i], p[i]) for i in range(k))\\n    \\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a:\\n        y = k\\n    else:\\n        x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"#!/usr/bin/env python3\\n\\nn, m, a = list(map(int, input().split()))\\nb = sorted(map(int, input().split()))\\np = sorted(map(int, input().split()))\\n\\nleft = 1\\nright = min(n, m)\\n\\nwhile left <= right:\\n    mid = (left + right) // 2\\n    if a >= sum(max(0, x - y) for x, y in zip(p[:mid], b[-mid:])):\\n        left = mid + 1\\n    else:\\n        right = mid - 1\\nprint(right, max(0, sum(p[:right]) - a))\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<r:\\n    mid=(r+1 +l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid\\n    else:\\n        r=mid-1\\nprint(l,max(0,sum(p[:l])-a))\\n\\n\\n\\n\\n\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<=r:\\n    mid=l+(r-l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid+1\\n    else:\\n        r=mid-1\\nprint(r,max(0,sum(p[:r])-a))\\n\\n\\n\\n\\n\\n\", \"wejscie1 = list(map(int,input().strip().split()))\\nilChlopcow = wejscie1[0]\\nilRowerow = wejscie1[1]\\nbudzet = wejscie1[2]\\npieniadzeChlopcow = list(map(int,input().strip().split()))\\ncenyRowerow = list(map(int,input().strip().split()))\\npieniadzeChlopcow = sorted(pieniadzeChlopcow)\\ncenyRowerow = sorted(cenyRowerow)\\nbikesBoysCanRent = 0\\ntotalCostOfRenting = 0\\nownMoneyRequired = 0\\n\\n\\n\\ndef czyMoznaWypozyczyc(ilSprawdzonychRowerow):\\n  budzet2 = budzet\\n  if ilSprawdzonychRowerow > ilChlopcow:\\n    return False\\n  for x in range(ilSprawdzonychRowerow):\\n    roznica = pieniadzeChlopcow[ilChlopcow-x-1] - cenyRowerow[ilSprawdzonychRowerow-x-1]\\n    if roznica >= 0:\\n     continue\\n    budzet2 = budzet2 + roznica\\n    if budzet2 < 0:\\n     return False\\n  return True\\n\\ndef binarySearch(lewy, prawy):\\n  while lewy<prawy:\\n    mid = (lewy + prawy + 1)//2\\n    if czyMoznaWypozyczyc(mid) == True:\\n      lewy = mid\\n    else:\\n      prawy = mid-1\\n  return lewy \\n\\n\\nbikesBoysCanRent = binarySearch(0, ilRowerow)\\n\\nfor x in range(bikesBoysCanRent):\\n  totalCostOfRenting+=cenyRowerow[x]\\nwyjscie2 = totalCostOfRenting-budzet\\nif wyjscie2 < 0:\\n  wyjscie2 = 0\\nprint(bikesBoysCanRent,wyjscie2)\\n\", \"def check(mid):\\n    need=0\\n    for i in range(mid):\\n#        print(mid,n-mid+i,i,mon,pri)\\n        if mon[n-mid+i]<pri[i]:\\n            need+=pri[i]-mon[n-mid+i]\\n    return need<=a           \\nn,m,a = list(map(int,input().split()))\\nmon = sorted(map(int,input().split()))\\npri = sorted(map(int,input().split()))\\nl=0\\nr=min(n,m)\\n#print(mon,pri)\\nwhile l<=r:\\n    mid = l +(r-l)//2\\n    if check(mid):\\n        l = mid+1\\n    else:\\n        r = mid-1\\nprint(r,max(0,sum(pri[:r])-a))\\n\\n\\n\", \"import sys\\n\\ncases = False\\n\\n# Pre-defined function\\n# Begin\\ndef fast_pow(a:int, b:int):\\n    res = 1\\n    while b > 0:\\n        if b & 1:\\n            res *= a\\n        a *= a\\n        b >>= 1\\n    return res\\n\\ndef c2(n):\\n    return n * (n-1) // 2\\n\\ndef get():\\n    return list(map(int, input().split()))\\n\\ndef bits(n: int):\\n    return list(bin(n)).count('1')\\n\\ndef main(test_case = False):\\n    n = int(input()) if test_case else 1\\n    for _ in range(n):\\n        test()\\n\\ndef flush():\\n    sys.stdout.flush()\\n\\ndef parr(arr):\\n    print(*arr, sep=' ')\\n\\ndef gcd(a, b):\\n    while b:\\n        if b % a == 0:\\n            break\\n        tmp = a\\n        a = b % a\\n        b = tmp\\n    return a\\n\\ndef ext_gcd(a: int, b: int):\\n    if (b == 0):\\n        return [a, [1, 0]]\\n \\n    res = ext_gcd(b, a % b)\\n    g = res[0]\\n    x1 = res[1][0]\\n    y1 = res[1][1]\\n    x = y1\\n    y = x1 - y1 * (a // b)\\n \\n    return [g, [x, y]]\\n\\n# End\\n\\nb = []\\np = []\\nn = m = a = 0\\n \\ndef check(cnt):\\n    if cnt == 0:\\n        return True\\n    x = b[-cnt:]\\n    y = p[:cnt]\\n    s = a\\n    i = 0\\n    while i < cnt and s >= 0:\\n        s -= max(0, y[i]-x[i])\\n        i += 1\\n    return s >= 0\\n \\ndef test():\\n    nonlocal n, m, a, b, p\\n    n, m, a = get()\\n    b = sorted(get())\\n    p = sorted(get())\\n \\n    left = 0\\n    right = min(n, m)\\n \\n    ans = -1\\n \\n    while left <= right:\\n        mid = (left + right) // 2\\n        if check(mid):\\n            ans = max(ans, mid)\\n            left = mid + 1\\n        else:\\n            right = mid - 1\\n \\n    if ans == -1:\\n        print(0, 0)\\n        return\\n \\n    # print(ans)\\n \\n    t = 0\\n    x = b[-ans:]\\n    y = p[:ans]\\n    i = 0\\n    while i < ans:\\n        t += min(x[i], y[i])\\n        a -= max(0, y[i]-x[i])\\n        i += 1\\n    print(ans, max(0, t-a)) \\n\\nmain(cases)\"]",
        "difficulty": "interview",
        "input": "14 14 22\n23 1 3 16 23 1 7 5 18 7 3 6 17 8\n22 14 22 18 12 11 7 24 20 27 10 22 16 7\n",
        "output": "10 115\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/363/D"
    },
    {
        "id": 1754,
        "task_id": 1391,
        "test_case_id": 13,
        "question": "A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs p_{j} rubles.\n\nIn total, the boys' shared budget is a rubles. Besides, each of them has his own personal money, the i-th boy has b_{i} personal rubles. The shared budget can be spent on any schoolchildren arbitrarily, but each boy's personal money can be spent on renting only this boy's bike.\n\nEach boy can rent at most one bike, one cannot give his bike to somebody else.\n\nWhat maximum number of schoolboys will be able to ride bikes? What minimum sum of personal money will they have to spend in total to let as many schoolchildren ride bikes as possible?\n\n\n-----Input-----\n\nThe first line of the input contains three integers n, m and a (1 ≤ n, m ≤ 10^5; 0 ≤ a ≤ 10^9). The second line contains the sequence of integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 10^4), where b_{i} is the amount of the i-th boy's personal money. The third line contains the sequence of integers p_1, p_2, ..., p_{m} (1 ≤ p_{j} ≤ 10^9), where p_{j} is the price for renting the j-th bike.\n\n\n-----Output-----\n\nPrint two integers r and s, where r is the maximum number of schoolboys that can rent a bike and s is the minimum total personal money needed to rent r bikes. If the schoolchildren cannot rent any bikes, then r = s = 0.\n\n\n-----Examples-----\nInput\n2 2 10\n5 5\n7 6\n\nOutput\n2 3\n\nInput\n4 5 2\n8 1 1 2\n6 3 7 5 2\n\nOutput\n3 8\n\n\n\n-----Note-----\n\nIn the first sample both schoolchildren can rent a bike. For instance, they can split the shared budget in half (5 rubles each). In this case one of them will have to pay 1 ruble from the personal money and the other one will have to pay 2 rubles from the personal money. In total, they spend 3 rubles of their personal money. This way of distribution of money minimizes the amount of spent personal money.",
        "solutions": "[\"3\\n\\ndef readln(): return tuple(map(int, input().split()))\\n\\nn, m, a = readln()\\nb = list(sorted(readln()))\\np = list(sorted(readln()))\\n\\nl = ost = 0\\nr = min(m, n) + 1\\n\\nwhile r - l > 1:\\n    k = (r + l) // 2\\n    s = d = 0\\n    for x, y in zip(b[-k:], p[:k]):\\n        if x < y:\\n            d += y - x\\n        s += y\\n    if d <= a:\\n        l = k\\n        ost = max(0, s - a)\\n    else:\\n        r = k\\n\\nprint(l, ost)\\n\", \"3\\ndef readn():\\n  return map(int, input().split())\\n\\nn, m, a = readn()\\nn = min(n, m)\\nm = n\\nb = sorted(readn())[-n:]\\np = sorted(readn())\\nr = 0\\nwhile r < n:\\n t = (r+1 + n)//2\\n a1 = sum([max(0, p[i]-b[m+i-t]) for i in range(t)])\\n if a1 <= a:\\n   r = t\\n else:\\n   n = t-1\\nprint(r, max(0, sum(p[:r])-a))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k): return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k): return sum(min(b[n - k + i], p[i]) for i in range(k))\\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a: y = k\\n    else: x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k):\\n    return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k):\\n    return sum(min(b[n - k + i], p[i]) for i in range(k))\\n    \\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a:\\n        y = k\\n    else:\\n        x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"#!/usr/bin/env python3\\n\\nn, m, a = list(map(int, input().split()))\\nb = sorted(map(int, input().split()))\\np = sorted(map(int, input().split()))\\n\\nleft = 1\\nright = min(n, m)\\n\\nwhile left <= right:\\n    mid = (left + right) // 2\\n    if a >= sum(max(0, x - y) for x, y in zip(p[:mid], b[-mid:])):\\n        left = mid + 1\\n    else:\\n        right = mid - 1\\nprint(right, max(0, sum(p[:right]) - a))\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<r:\\n    mid=(r+1 +l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid\\n    else:\\n        r=mid-1\\nprint(l,max(0,sum(p[:l])-a))\\n\\n\\n\\n\\n\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<=r:\\n    mid=l+(r-l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid+1\\n    else:\\n        r=mid-1\\nprint(r,max(0,sum(p[:r])-a))\\n\\n\\n\\n\\n\\n\", \"wejscie1 = list(map(int,input().strip().split()))\\nilChlopcow = wejscie1[0]\\nilRowerow = wejscie1[1]\\nbudzet = wejscie1[2]\\npieniadzeChlopcow = list(map(int,input().strip().split()))\\ncenyRowerow = list(map(int,input().strip().split()))\\npieniadzeChlopcow = sorted(pieniadzeChlopcow)\\ncenyRowerow = sorted(cenyRowerow)\\nbikesBoysCanRent = 0\\ntotalCostOfRenting = 0\\nownMoneyRequired = 0\\n\\n\\n\\ndef czyMoznaWypozyczyc(ilSprawdzonychRowerow):\\n  budzet2 = budzet\\n  if ilSprawdzonychRowerow > ilChlopcow:\\n    return False\\n  for x in range(ilSprawdzonychRowerow):\\n    roznica = pieniadzeChlopcow[ilChlopcow-x-1] - cenyRowerow[ilSprawdzonychRowerow-x-1]\\n    if roznica >= 0:\\n     continue\\n    budzet2 = budzet2 + roznica\\n    if budzet2 < 0:\\n     return False\\n  return True\\n\\ndef binarySearch(lewy, prawy):\\n  while lewy<prawy:\\n    mid = (lewy + prawy + 1)//2\\n    if czyMoznaWypozyczyc(mid) == True:\\n      lewy = mid\\n    else:\\n      prawy = mid-1\\n  return lewy \\n\\n\\nbikesBoysCanRent = binarySearch(0, ilRowerow)\\n\\nfor x in range(bikesBoysCanRent):\\n  totalCostOfRenting+=cenyRowerow[x]\\nwyjscie2 = totalCostOfRenting-budzet\\nif wyjscie2 < 0:\\n  wyjscie2 = 0\\nprint(bikesBoysCanRent,wyjscie2)\\n\", \"def check(mid):\\n    need=0\\n    for i in range(mid):\\n#        print(mid,n-mid+i,i,mon,pri)\\n        if mon[n-mid+i]<pri[i]:\\n            need+=pri[i]-mon[n-mid+i]\\n    return need<=a           \\nn,m,a = list(map(int,input().split()))\\nmon = sorted(map(int,input().split()))\\npri = sorted(map(int,input().split()))\\nl=0\\nr=min(n,m)\\n#print(mon,pri)\\nwhile l<=r:\\n    mid = l +(r-l)//2\\n    if check(mid):\\n        l = mid+1\\n    else:\\n        r = mid-1\\nprint(r,max(0,sum(pri[:r])-a))\\n\\n\\n\", \"import sys\\n\\ncases = False\\n\\n# Pre-defined function\\n# Begin\\ndef fast_pow(a:int, b:int):\\n    res = 1\\n    while b > 0:\\n        if b & 1:\\n            res *= a\\n        a *= a\\n        b >>= 1\\n    return res\\n\\ndef c2(n):\\n    return n * (n-1) // 2\\n\\ndef get():\\n    return list(map(int, input().split()))\\n\\ndef bits(n: int):\\n    return list(bin(n)).count('1')\\n\\ndef main(test_case = False):\\n    n = int(input()) if test_case else 1\\n    for _ in range(n):\\n        test()\\n\\ndef flush():\\n    sys.stdout.flush()\\n\\ndef parr(arr):\\n    print(*arr, sep=' ')\\n\\ndef gcd(a, b):\\n    while b:\\n        if b % a == 0:\\n            break\\n        tmp = a\\n        a = b % a\\n        b = tmp\\n    return a\\n\\ndef ext_gcd(a: int, b: int):\\n    if (b == 0):\\n        return [a, [1, 0]]\\n \\n    res = ext_gcd(b, a % b)\\n    g = res[0]\\n    x1 = res[1][0]\\n    y1 = res[1][1]\\n    x = y1\\n    y = x1 - y1 * (a // b)\\n \\n    return [g, [x, y]]\\n\\n# End\\n\\nb = []\\np = []\\nn = m = a = 0\\n \\ndef check(cnt):\\n    if cnt == 0:\\n        return True\\n    x = b[-cnt:]\\n    y = p[:cnt]\\n    s = a\\n    i = 0\\n    while i < cnt and s >= 0:\\n        s -= max(0, y[i]-x[i])\\n        i += 1\\n    return s >= 0\\n \\ndef test():\\n    nonlocal n, m, a, b, p\\n    n, m, a = get()\\n    b = sorted(get())\\n    p = sorted(get())\\n \\n    left = 0\\n    right = min(n, m)\\n \\n    ans = -1\\n \\n    while left <= right:\\n        mid = (left + right) // 2\\n        if check(mid):\\n            ans = max(ans, mid)\\n            left = mid + 1\\n        else:\\n            right = mid - 1\\n \\n    if ans == -1:\\n        print(0, 0)\\n        return\\n \\n    # print(ans)\\n \\n    t = 0\\n    x = b[-ans:]\\n    y = p[:ans]\\n    i = 0\\n    while i < ans:\\n        t += min(x[i], y[i])\\n        a -= max(0, y[i]-x[i])\\n        i += 1\\n    print(ans, max(0, t-a)) \\n\\nmain(cases)\"]",
        "difficulty": "interview",
        "input": "10 20 36\n12 4 7 18 4 4 2 7 4 10\n9 18 7 7 30 19 26 27 16 20 30 25 23 17 5 30 22 7 13 6\n",
        "output": "10 69\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/363/D"
    },
    {
        "id": 1755,
        "task_id": 1391,
        "test_case_id": 15,
        "question": "A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs p_{j} rubles.\n\nIn total, the boys' shared budget is a rubles. Besides, each of them has his own personal money, the i-th boy has b_{i} personal rubles. The shared budget can be spent on any schoolchildren arbitrarily, but each boy's personal money can be spent on renting only this boy's bike.\n\nEach boy can rent at most one bike, one cannot give his bike to somebody else.\n\nWhat maximum number of schoolboys will be able to ride bikes? What minimum sum of personal money will they have to spend in total to let as many schoolchildren ride bikes as possible?\n\n\n-----Input-----\n\nThe first line of the input contains three integers n, m and a (1 ≤ n, m ≤ 10^5; 0 ≤ a ≤ 10^9). The second line contains the sequence of integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 10^4), where b_{i} is the amount of the i-th boy's personal money. The third line contains the sequence of integers p_1, p_2, ..., p_{m} (1 ≤ p_{j} ≤ 10^9), where p_{j} is the price for renting the j-th bike.\n\n\n-----Output-----\n\nPrint two integers r and s, where r is the maximum number of schoolboys that can rent a bike and s is the minimum total personal money needed to rent r bikes. If the schoolchildren cannot rent any bikes, then r = s = 0.\n\n\n-----Examples-----\nInput\n2 2 10\n5 5\n7 6\n\nOutput\n2 3\n\nInput\n4 5 2\n8 1 1 2\n6 3 7 5 2\n\nOutput\n3 8\n\n\n\n-----Note-----\n\nIn the first sample both schoolchildren can rent a bike. For instance, they can split the shared budget in half (5 rubles each). In this case one of them will have to pay 1 ruble from the personal money and the other one will have to pay 2 rubles from the personal money. In total, they spend 3 rubles of their personal money. This way of distribution of money minimizes the amount of spent personal money.",
        "solutions": "[\"3\\n\\ndef readln(): return tuple(map(int, input().split()))\\n\\nn, m, a = readln()\\nb = list(sorted(readln()))\\np = list(sorted(readln()))\\n\\nl = ost = 0\\nr = min(m, n) + 1\\n\\nwhile r - l > 1:\\n    k = (r + l) // 2\\n    s = d = 0\\n    for x, y in zip(b[-k:], p[:k]):\\n        if x < y:\\n            d += y - x\\n        s += y\\n    if d <= a:\\n        l = k\\n        ost = max(0, s - a)\\n    else:\\n        r = k\\n\\nprint(l, ost)\\n\", \"3\\ndef readn():\\n  return map(int, input().split())\\n\\nn, m, a = readn()\\nn = min(n, m)\\nm = n\\nb = sorted(readn())[-n:]\\np = sorted(readn())\\nr = 0\\nwhile r < n:\\n t = (r+1 + n)//2\\n a1 = sum([max(0, p[i]-b[m+i-t]) for i in range(t)])\\n if a1 <= a:\\n   r = t\\n else:\\n   n = t-1\\nprint(r, max(0, sum(p[:r])-a))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k): return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k): return sum(min(b[n - k + i], p[i]) for i in range(k))\\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a: y = k\\n    else: x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"n, m, a = map(int, input().split())\\nb, p = sorted(map(int, input().split())), sorted(map(int, input().split()))\\ndef f(k):\\n    return sum(max(0, p[i] - b[n - k + i]) for i in range(k))\\ndef g(k):\\n    return sum(min(b[n - k + i], p[i]) for i in range(k))\\n    \\nx, y, d = 0, min(n, m) + 1, a\\nwhile y - x > 1:\\n    k = (x + y) // 2\\n    s = f(k)\\n    if s > a:\\n        y = k\\n    else:\\n        x, d = k, s\\nprint(x, max(0, g(x) - a + d))\", \"#!/usr/bin/env python3\\n\\nn, m, a = list(map(int, input().split()))\\nb = sorted(map(int, input().split()))\\np = sorted(map(int, input().split()))\\n\\nleft = 1\\nright = min(n, m)\\n\\nwhile left <= right:\\n    mid = (left + right) // 2\\n    if a >= sum(max(0, x - y) for x, y in zip(p[:mid], b[-mid:])):\\n        left = mid + 1\\n    else:\\n        right = mid - 1\\nprint(right, max(0, sum(p[:right]) - a))\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<r:\\n    mid=(r+1 +l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid\\n    else:\\n        r=mid-1\\nprint(l,max(0,sum(p[:l])-a))\\n\\n\\n\\n\\n\\n\", \"def readn():\\n  return list(map(int, input().split()))\\nn,m,a=readn()#map(int,input().split())\\nb,p=sorted(map(int,input().split()))[-min(n,m):],sorted(map(int,input().split()))\\nr=min(n,m)\\nmm=r\\nl=0\\nwhile l<=r:\\n    mid=l+(r-l)//2\\n    pri=sum([max(0,p[i]-b[mm-mid+i]) for i in range(mid)])\\n    if pri<=a:\\n        l=mid+1\\n    else:\\n        r=mid-1\\nprint(r,max(0,sum(p[:r])-a))\\n\\n\\n\\n\\n\\n\", \"wejscie1 = list(map(int,input().strip().split()))\\nilChlopcow = wejscie1[0]\\nilRowerow = wejscie1[1]\\nbudzet = wejscie1[2]\\npieniadzeChlopcow = list(map(int,input().strip().split()))\\ncenyRowerow = list(map(int,input().strip().split()))\\npieniadzeChlopcow = sorted(pieniadzeChlopcow)\\ncenyRowerow = sorted(cenyRowerow)\\nbikesBoysCanRent = 0\\ntotalCostOfRenting = 0\\nownMoneyRequired = 0\\n\\n\\n\\ndef czyMoznaWypozyczyc(ilSprawdzonychRowerow):\\n  budzet2 = budzet\\n  if ilSprawdzonychRowerow > ilChlopcow:\\n    return False\\n  for x in range(ilSprawdzonychRowerow):\\n    roznica = pieniadzeChlopcow[ilChlopcow-x-1] - cenyRowerow[ilSprawdzonychRowerow-x-1]\\n    if roznica >= 0:\\n     continue\\n    budzet2 = budzet2 + roznica\\n    if budzet2 < 0:\\n     return False\\n  return True\\n\\ndef binarySearch(lewy, prawy):\\n  while lewy<prawy:\\n    mid = (lewy + prawy + 1)//2\\n    if czyMoznaWypozyczyc(mid) == True:\\n      lewy = mid\\n    else:\\n      prawy = mid-1\\n  return lewy \\n\\n\\nbikesBoysCanRent = binarySearch(0, ilRowerow)\\n\\nfor x in range(bikesBoysCanRent):\\n  totalCostOfRenting+=cenyRowerow[x]\\nwyjscie2 = totalCostOfRenting-budzet\\nif wyjscie2 < 0:\\n  wyjscie2 = 0\\nprint(bikesBoysCanRent,wyjscie2)\\n\", \"def check(mid):\\n    need=0\\n    for i in range(mid):\\n#        print(mid,n-mid+i,i,mon,pri)\\n        if mon[n-mid+i]<pri[i]:\\n            need+=pri[i]-mon[n-mid+i]\\n    return need<=a           \\nn,m,a = list(map(int,input().split()))\\nmon = sorted(map(int,input().split()))\\npri = sorted(map(int,input().split()))\\nl=0\\nr=min(n,m)\\n#print(mon,pri)\\nwhile l<=r:\\n    mid = l +(r-l)//2\\n    if check(mid):\\n        l = mid+1\\n    else:\\n        r = mid-1\\nprint(r,max(0,sum(pri[:r])-a))\\n\\n\\n\", \"import sys\\n\\ncases = False\\n\\n# Pre-defined function\\n# Begin\\ndef fast_pow(a:int, b:int):\\n    res = 1\\n    while b > 0:\\n        if b & 1:\\n            res *= a\\n        a *= a\\n        b >>= 1\\n    return res\\n\\ndef c2(n):\\n    return n * (n-1) // 2\\n\\ndef get():\\n    return list(map(int, input().split()))\\n\\ndef bits(n: int):\\n    return list(bin(n)).count('1')\\n\\ndef main(test_case = False):\\n    n = int(input()) if test_case else 1\\n    for _ in range(n):\\n        test()\\n\\ndef flush():\\n    sys.stdout.flush()\\n\\ndef parr(arr):\\n    print(*arr, sep=' ')\\n\\ndef gcd(a, b):\\n    while b:\\n        if b % a == 0:\\n            break\\n        tmp = a\\n        a = b % a\\n        b = tmp\\n    return a\\n\\ndef ext_gcd(a: int, b: int):\\n    if (b == 0):\\n        return [a, [1, 0]]\\n \\n    res = ext_gcd(b, a % b)\\n    g = res[0]\\n    x1 = res[1][0]\\n    y1 = res[1][1]\\n    x = y1\\n    y = x1 - y1 * (a // b)\\n \\n    return [g, [x, y]]\\n\\n# End\\n\\nb = []\\np = []\\nn = m = a = 0\\n \\ndef check(cnt):\\n    if cnt == 0:\\n        return True\\n    x = b[-cnt:]\\n    y = p[:cnt]\\n    s = a\\n    i = 0\\n    while i < cnt and s >= 0:\\n        s -= max(0, y[i]-x[i])\\n        i += 1\\n    return s >= 0\\n \\ndef test():\\n    nonlocal n, m, a, b, p\\n    n, m, a = get()\\n    b = sorted(get())\\n    p = sorted(get())\\n \\n    left = 0\\n    right = min(n, m)\\n \\n    ans = -1\\n \\n    while left <= right:\\n        mid = (left + right) // 2\\n        if check(mid):\\n            ans = max(ans, mid)\\n            left = mid + 1\\n        else:\\n            right = mid - 1\\n \\n    if ans == -1:\\n        print(0, 0)\\n        return\\n \\n    # print(ans)\\n \\n    t = 0\\n    x = b[-ans:]\\n    y = p[:ans]\\n    i = 0\\n    while i < ans:\\n        t += min(x[i], y[i])\\n        a -= max(0, y[i]-x[i])\\n        i += 1\\n    print(ans, max(0, t-a)) \\n\\nmain(cases)\"]",
        "difficulty": "interview",
        "input": "40 40 61\n28 59 8 27 45 67 33 32 61 3 42 2 3 37 8 8 10 61 1 5 65 28 34 27 8 35 45 49 31 49 13 23 23 53 20 48 14 74 16 6\n69 56 34 66 42 73 45 49 29 70 67 77 73 26 78 11 50 69 64 72 78 66 66 29 80 40 50 75 68 47 78 63 41 70 52 52 69 22 69 66\n",
        "output": "22 939\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/363/D"
    },
    {
        "id": 1756,
        "task_id": 1408,
        "test_case_id": 1,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "5\n1 12\n1 3\n2 15\n2 5\n2 1\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1757,
        "task_id": 1408,
        "test_case_id": 2,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "3\n1 10\n2 1\n2 4\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1758,
        "task_id": 1408,
        "test_case_id": 3,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "10\n2 10\n2 4\n2 8\n2 3\n2 5\n2 6\n1 2\n1 10\n1 10\n2 5\n",
        "output": "12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1759,
        "task_id": 1408,
        "test_case_id": 4,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "1\n2 7\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1760,
        "task_id": 1408,
        "test_case_id": 5,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "50\n1 24\n1 16\n1 33\n2 34\n1 26\n2 35\n1 39\n2 44\n2 29\n2 28\n1 44\n2 48\n2 50\n2 41\n2 9\n1 22\n2 11\n2 27\n1 12\n1 50\n2 49\n1 17\n2 43\n2 6\n1 39\n2 28\n1 47\n1 45\n2 32\n1 43\n2 40\n1 10\n1 44\n2 31\n2 26\n2 15\n2 20\n1 49\n1 36\n2 43\n2 8\n1 46\n2 43\n2 26\n1 30\n1 23\n2 26\n1 32\n2 25\n2 42\n",
        "output": "67\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1761,
        "task_id": 1408,
        "test_case_id": 6,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "20\n2 4\n1 2\n2 2\n1 2\n2 1\n1 3\n2 5\n1 3\n1 1\n2 3\n1 4\n2 3\n1 5\n1 4\n1 4\n1 2\n2 5\n1 5\n2 2\n2 2\n",
        "output": "16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1762,
        "task_id": 1408,
        "test_case_id": 7,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "30\n1 48\n1 3\n2 20\n2 41\n1 33\n2 46\n2 22\n2 21\n1 6\n2 44\n1 23\n2 28\n1 39\n1 19\n2 15\n2 49\n1 26\n1 22\n2 42\n2 27\n2 31\n1 49\n1 11\n1 33\n1 1\n2 31\n2 9\n1 18\n2 27\n1 18\n",
        "output": "38\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1763,
        "task_id": 1408,
        "test_case_id": 8,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "40\n2 14\n1 13\n1 51\n2 18\n2 99\n2 85\n1 37\n2 54\n2 82\n1 93\n1 71\n1 76\n1 40\n2 14\n1 61\n1 74\n2 83\n2 75\n1 12\n1 23\n1 95\n1 84\n2 90\n1 40\n1 96\n2 25\n2 68\n2 87\n2 34\n2 66\n2 60\n2 65\n2 18\n2 48\n1 97\n2 71\n1 94\n1 5\n1 47\n1 29\n",
        "output": "53\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1764,
        "task_id": 1408,
        "test_case_id": 9,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "1\n1 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1765,
        "task_id": 1408,
        "test_case_id": 10,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "1\n1 2\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1766,
        "task_id": 1408,
        "test_case_id": 11,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "2\n1 2\n2 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1767,
        "task_id": 1408,
        "test_case_id": 12,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "100\n2 2\n1 2\n1 1\n2 1\n1 2\n2 1\n2 2\n2 1\n2 1\n1 2\n1 2\n2 1\n1 2\n2 1\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 1\n2 2\n2 1\n1 1\n1 2\n2 2\n1 1\n2 2\n1 2\n2 1\n2 2\n1 2\n2 2\n1 2\n1 1\n2 2\n2 2\n1 1\n1 2\n2 2\n1 2\n1 1\n1 1\n1 1\n2 1\n2 1\n1 2\n1 2\n2 2\n1 2\n1 2\n1 1\n2 1\n2 1\n2 2\n1 2\n2 1\n1 1\n2 1\n1 2\n2 2\n1 1\n1 2\n1 2\n1 1\n2 2\n2 2\n1 1\n1 2\n1 2\n1 2\n2 1\n2 1\n2 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n1 2\n2 1\n2 1\n1 1\n1 2\n2 1\n1 1\n1 1\n2 2\n2 2\n1 1\n2 1\n1 2\n2 2\n2 1\n1 2\n1 2\n1 2\n1 1\n2 1\n",
        "output": "60\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1768,
        "task_id": 1408,
        "test_case_id": 13,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "100\n2 2\n1 2\n1 5\n1 5\n1 2\n1 4\n2 3\n1 2\n1 5\n2 1\n2 2\n2 4\n1 2\n2 3\n1 1\n1 1\n2 5\n2 3\n2 2\n1 2\n2 1\n2 2\n1 5\n2 1\n2 4\n1 4\n1 4\n2 2\n1 1\n2 4\n1 4\n2 4\n1 2\n2 3\n2 3\n1 5\n1 5\n2 3\n1 4\n1 5\n2 2\n1 3\n2 2\n2 2\n1 1\n2 1\n2 5\n1 1\n2 3\n2 5\n1 5\n1 3\n1 5\n2 4\n1 5\n2 3\n2 5\n1 4\n2 3\n2 2\n2 5\n2 4\n1 1\n1 1\n1 3\n2 3\n2 1\n2 1\n1 2\n1 1\n2 5\n2 2\n2 1\n2 3\n2 2\n1 5\n1 2\n1 2\n1 1\n1 2\n1 4\n1 5\n1 4\n1 3\n1 1\n1 2\n2 2\n2 4\n1 2\n1 1\n2 3\n2 3\n2 5\n2 1\n1 5\n1 5\n1 4\n2 2\n1 4\n2 4\n",
        "output": "76\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1769,
        "task_id": 1408,
        "test_case_id": 14,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "50\n1 69\n2 39\n1 32\n2 35\n1 25\n2 24\n1 59\n2 99\n2 48\n2 54\n1 87\n1 81\n2 42\n2 8\n2 92\n1 78\n2 70\n2 91\n1 86\n1 87\n2 15\n1 93\n1 82\n2 36\n1 12\n1 56\n2 84\n1 98\n1 89\n2 79\n1 22\n1 65\n1 40\n2 13\n2 95\n2 93\n1 9\n2 99\n2 100\n1 76\n2 56\n1 10\n1 2\n2 93\n2 21\n2 33\n1 21\n1 81\n2 10\n2 93\n",
        "output": "66\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1770,
        "task_id": 1408,
        "test_case_id": 15,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "10\n1 61\n1 92\n2 97\n1 70\n2 37\n2 44\n2 29\n1 94\n2 65\n1 48\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1771,
        "task_id": 1408,
        "test_case_id": 16,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "40\n2 14\n1 13\n1 51\n2 18\n2 99\n2 85\n1 37\n2 54\n2 82\n1 93\n1 71\n1 76\n1 40\n2 14\n1 61\n1 74\n2 83\n2 75\n1 12\n1 23\n1 95\n1 84\n2 90\n1 40\n1 96\n2 25\n2 68\n2 87\n2 34\n2 66\n2 60\n2 65\n2 18\n2 48\n1 97\n2 71\n1 94\n1 5\n1 47\n1 29\n",
        "output": "53\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1772,
        "task_id": 1408,
        "test_case_id": 17,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "2\n1 100\n1 100\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1773,
        "task_id": 1408,
        "test_case_id": 18,
        "question": "Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or 2. All books have the same page heights. $1$ \n\nShaass puts the books on the bookshelf in the following way. First he selects some of the books and put them vertically. Then he puts the rest of the books horizontally above the vertical books. The sum of the widths of the horizontal books must be no more than the total thickness of the vertical books. A sample arrangement of the books is depicted in the figure. [Image] \n\nHelp Shaass to find the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Input-----\n\nThe first line of the input contains an integer n, (1 ≤ n ≤ 100). Each of the next n lines contains two integers t_{i} and w_{i} denoting the thickness and width of the i-th book correspondingly, (1 ≤ t_{i} ≤ 2, 1 ≤ w_{i} ≤ 100).\n\n\n-----Output-----\n\nOn the only line of the output print the minimum total thickness of the vertical books that we can achieve.\n\n\n-----Examples-----\nInput\n5\n1 12\n1 3\n2 15\n2 5\n2 1\n\nOutput\n5\n\nInput\n3\n1 10\n2 1\n2 4\n\nOutput\n3",
        "solutions": "[\"3\\n\\nn = int(input())\\nbooks = [[], []]\\nfor _ in range(n):\\n    t, w = tuple(map(int, input().split()))\\n    books[t - 1].append(w)\\nfor _ in range(2):\\n    books[_].sort()\\n#print(books)\\nans = 10**9\\nfor i in range(len(books[0]) + 1):\\n    for j in range(len(books[1]) + 1):\\n        hor = sum(books[0][:i]) + sum(books[1][:j])\\n        ver = len(books[0]) - i + 2 * (len(books[1]) - j)\\n        if hor <= ver and ver < ans:\\n            ans = ver\\n        #print(i, j, hor, ver, ans)\\nprint(ans)\\n\", \"n = int(input())\\na = list(tuple(map(int, input().split())) for i in range(n))\\ns = sum(t for t, w in a)\\na = [(t / w, t, t + w) for t, w in a]\\na.sort(reverse = True)\\nd, i = s, 0\\nwhile d >= 0:\\n    s -= a[i][1]\\n    d -= a[i][2]\\n    i += 1\\ni -= 1\\ns += a[i][1]\\nd += a[i][2]\\nif a[i][1] == 2:\\n    j = i + 1\\n    while j < n and a[j][1] == 2: j += 1\\n    if j < n and d >= a[j][2]:\\n        i = 0\\n        s -= 1\\nif i > 0: \\n    i -= 1\\n    if a[i][1] == 1:\\n        d += a[i][2]\\n        j = i + 1\\n        while j < n and a[j][1] == 1: j += 1\\n        if j < n and d >= a[j][2]: s -= 1\\nprint(s)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\\n\", \"n = int(input())\\nt = [0] * n\\nw = [0] * n\\n\\nfor i in range(n):\\n    t[i], w[i] = map(int, input().split())\\n\\ndp = [[float(\\\"inf\\\")] * (2 * n + 1) for i in range(n)]\\ndp[0][t[0]] = 0\\ndp[0][0] = w[0]\\nfor i in range(n - 1):\\n    for j in range(2 * n + 1):\\n        a = dp[i][j]\\n        if a != float(\\\"inf\\\"):\\n            dp[i + 1][j + t[i + 1]] = min(dp[i + 1][j + t[i + 1]], dp[i][j])\\n            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w[i + 1])\\n# 12 3 15 5 1\\nans = float(\\\"inf\\\")\\nfor j in range(2 * n + 1):\\n    if dp[n - 1][j] <= j:\\n        ans = min(ans, j)\\nprint(ans)\", \"n = int(input())\\nt, w = [], []\\nfor i in range(n):\\n    a, b = map(int, input().split())\\n    t.append(a)\\n    w.append(b)\\nd = [[float('-inf')] * (2 * n + 1) for i in range(n + 1)]\\nd[0][0] = 0\\nfor i in range(n):\\n    for j in range(2 * n + 1):\\n        if j + t[i] <= 2 * n:\\n            d[i + 1][j + t[i]] = max(d[i + 1][j + t[i]], d[i][j] + w[i])\\n        d[i + 1][j] = max(d[i + 1][j], d[i][j])\\nfor j in range(2 * n + 1):\\n    if sum(w) - d[n][j] <= j:\\n        print(j)\\n        return\", \"'''\\nCreated on Jan 26, 2015\\n\\n@author: mohamed265\\n'''\\nn = int(input())\\ntOne = [0]\\ntTwo = [0]\\nsizeOne = 1\\nsizetwo = 1\\nslon = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\\nfor i in range(n):\\n    t = input().split()\\n    if t[0] == '1':\\n        tOne.append(int(t[1]))\\n        sizeOne += 1\\n    else:\\n        tTwo.append(int(t[1]))\\n        sizetwo += 1\\ntOne.sort(reverse=False)\\ntTwo.sort(reverse=False)\\nfor i in range(1, sizeOne):\\n    tOne[i] += tOne[i - 1]\\nfor i in range(1, sizetwo):\\n    tTwo[i] += tTwo[i - 1]\\ntOne.reverse()\\ntTwo.reverse()\\nfor i in range(sizeOne):\\n    for j in range(sizetwo):\\n        #print(i+ 2*j, tOne[i] + tTwo[j])\\n        if i + 2 * j >= tOne[i] + tTwo[j]:\\n            slon = min(slon, i + 2 * j)\\n# print(tOne, tTwo)\\nprint(slon)\\n\", \"n = int(input())\\na = [list(map(int, input().split())) for i in range(n)]\\ns1 = sum([x[0] for x in a])\\na.sort(key=lambda x: x[1] / x[0])\\n\\nans = 10**9\\ns2 = 0\\nl = -1\\nfor i in range(n):\\n    if s2 + a[i][1] <= s1 - a[i][0]:\\n        s2 += a[i][1]\\n        s1 -= a[i][0]\\n        l = i\\nif l != -1 and a[l][0] == 1:\\n    for i in range(l + 1, n):\\n        if a[i][0] == 2 and s2 - a[l][1] + a[i][1] <= s1 - 1:\\n            print(s1 - 1)\\n            return\\nprint(s1)\\n\", \"one = []\\ntwo = []\\n\\nx=int(input())\\nfor i in range(x):\\n    a, b = list(map(int, input().split(' ')))\\n    if a == 1:\\n        one.append(b)\\n    else:\\n        two.append(b)\\n\\none.sort()\\ntwo.sort()\\nminx = 9000000\\n\\nfor ones in range(0, len(one)+1):\\n    for twos in range(0,len(two)+1):\\n        w = ones + 2 * twos\\n        a = sum(one[:len(one)-ones]) + sum(two[:len(two)-twos])\\n        if a <= w: \\n            minx = min(minx, w)\\nprint(minx)\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"n = int(input())\\n\\nm = 2 * n + 1\\n\\n\\n\\npos = set([(0, 0)])\\n\\nfor i in range(n):\\n\\n    t, w = list(map(int, input().split(' ')))\\n\\n    next_pos = set()\\n\\n    for a, b in pos:\\n\\n        if a + t <= m:\\n\\n            next_pos.add((a + t, b))\\n\\n        if b + w <= m:\\n\\n            next_pos.add((a, b + w))\\n\\n    pos = next_pos\\n\\n\\n\\nprint(min(t for t, w in pos if t >= w))\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nm = 2 * n + 1\\n\\npos = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split(' ')))\\n    next_pos = set()\\n    for a, b in pos:\\n        if a + t <= m:\\n            next_pos.add((a + t, b))\\n        if b + w <= m:\\n            next_pos.add((a, b + w))\\n    pos = next_pos\\n\\nprint(min(t for t, w in pos if t >= w))\", \"R = lambda: map(int, input().split())\\nn = int(input())\\nunset = -1000000\\nbs = [[0, 0]] + [list(R()) for i in range(n)]\\ndp = [[unset] * 201 for i in range(n + 1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(201):\\n        t, w = bs[i + 1][0], bs[i + 1][1]\\n        if dp[i][j] != unset:\\n            dp[i + 1][j + t] = max(dp[i + 1][j + t], dp[i][j] + t)\\n            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - w)\\nfor i in range(201):\\n    if dp[n][i] >= 0:\\n        print(i)\\n        break\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = list(map(int, input().split()))\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\\n\", \"from operator import itemgetter\\n\\n\\nclass CodeforcesTask294BSolution:\\n    def __init__(self):\\n        self.result = ''\\n        self.books_count = 0\\n        self.books_dims = []\\n\\n    def read_input(self):\\n        self.books_count = int(input())\\n        for x in range(self.books_count):\\n            self.books_dims.append([int(y) for y in input().split(\\\" \\\")])\\n\\n    def process_task(self):\\n        v1 = sum([1 for x in self.books_dims if x[0] == 1])\\n        v2 = sum([1 for x in self.books_dims if x[0] == 2])\\n        v1_books = [x[1] for x in self.books_dims if x[0] == 1]\\n        v2_books = [x[1] for x in self.books_dims if x[0] == 2]\\n        v1_books.sort()\\n        v2_books.sort()\\n        minimum = v1 + v2 * 2\\n        for x in range(v1 + 1):\\n            for y in range(v2 + 1):\\n                width = x + y * 2\\n                thickness = sum(v1_books[:(v1 - x)]) + sum(v2_books[:(v2 - y)])\\n                if thickness <= width:\\n                    minimum = min(minimum, width)\\n        self.result = str(minimum)\\n\\n    def get_result(self):\\n        return self.result\\n\\n\\ndef __starting_point():\\n    Solution = CodeforcesTask294BSolution()\\n    Solution.read_input()\\n    Solution.process_task()\\n    print(Solution.get_result())\\n\\n__starting_point()\", \"3\\n\\nn = int(input())\\nt = []\\nw = []\\nn1, n2 = 0, 0\\nfor i in range(n):\\n    x, y = list(map(int, input().split()))\\n    t.append(x)\\n    w.append(y)\\n    n1 += x == 1\\n    n2 += x == 2\\n\\nw1 = []\\nw2 = []\\nfor i in range(n):\\n    if t[i] == 1:\\n        w1.append(w[i])\\n    else:\\n        w2.append(w[i])\\nw1.sort(reverse=True)\\nw2.sort(reverse=True)\\n\\nans = 201\\nfor i in range(201):\\n    for j in range(min(i // 2, n2) + 1):\\n        k = min(n1, i - 2 * j)\\n        thickness = 2 * j + k\\n        if thickness >= sum(w1[k:]) + sum(w2[j:]):\\n            ans = min(ans, thickness)\\n\\nprint(ans)\\n\", \"n = int(input())\\ndif=[]\\nli1=[]\\nli2=[]\\na1=b1=0\\n#print(lis)\\nfor i in range(n):\\n    a,b=list(map(int,input().split()))\\n    if a==1:\\n        li1.append(b)\\n    else:\\n        li2.append(b)\\nli1.sort(reverse=True)\\nli2.sort(reverse=True)\\nl1=len(li1)\\nl2=len(li2)\\nans=10000000000\\nfor i in range(l1+1):\\n    for j in range(l2+1):\\n        s=0\\n        for k in range(i,l1):\\n            s+=li1[k]\\n        for k in range(j,l2):\\n            s+=li2[k]\\n#        print(i,j,s)    \\n        if i+2*j>=s:\\n            ans=min(ans,i+2*j)\\nprint(ans)                                \\n\\n\", \"from bisect import bisect_left as bl, bisect_right as br, insort\\nimport sys\\nimport heapq\\n#from math import *\\nfrom collections import defaultdict as dd, deque\\ndef data(): return sys.stdin.readline().strip()\\ndef mdata(): return list(map(int, data().split()))\\n#def print(x): return sys.stdout.write(str(x)+'\\\\n')\\n#sys.setrecursionlimit(100000)\\nmod=int(1e9+7)\\n\\nn=int(data())\\ndp1=[]\\ndp2=[]\\nfor i in range(n):\\n    t,w=mdata()\\n    if t==1:\\n        dp1.append(w)\\n    else:\\n        dp2.append(w)\\ndp1.sort(reverse=True)\\ndp2.sort(reverse=True)\\ns=len(dp1)+2*len(dp2)\\nk=0\\nflag=True\\nwhile flag:\\n    flag=False\\n    if len(dp2)>0:\\n        if len(dp1)>1:\\n            m=min(dp1[-1]+dp1[-2],dp2[-1])\\n            if k+m<=s-2:\\n                if m==dp2[-1]:\\n                    dp2.pop()\\n                    k+=m\\n                    s-=2\\n                else:\\n                    k+=dp1.pop()\\n                    s-=1\\n                flag=True\\n        else:\\n            if len(dp2)>0 and dp2[-1]+k<=s-2:\\n                k+=dp2.pop()\\n                s-=2\\n                flag=True\\n    if flag==False:\\n        if len(dp1) > 0 and dp1[-1] + k <= s - 1:\\n            k += dp1.pop()\\n            s -= 1\\n            flag = True\\nprint(s)\\n\", \"n = int(input())\\nm = 2*n + 1\\nres = set([(0, 0)])\\nfor i in range(n):\\n    t, w = map(int, input().split())\\n    nxt = set()\\n    for a, b in res:\\n        if a + t <= m:\\n            nxt.add((a + t, b))\\n        if b + w <= m:\\n            nxt.add((a, b + w))\\n    res = nxt\\nprint(min(t for t, w in res if t >= w))\", \"n = int(input())\\nlis = []\\nfor _ in range(n):\\n    tt, ww = [int(x) for x in input().split()]\\n    lis.append((tt, -ww))\\nlis.sort()\\nsum1, sum2 = [0], [0]\\nfor i in range(n):\\n    if lis[i][0] == 1:\\n        sum1.append(sum1[-1] - lis[i][1])\\n    else:\\n        sum2.append(sum2[-1] - lis[i][1])\\nans = 1000000000\\nk1, k2 = len(sum1) - 1, len(sum2) - 1\\nv = k2 + 1\\nfor u in range(0, k1 + 1):\\n    while v - 1 >= 0 and 2 * (v - 1) + sum2[v - 1] >= sum1[k1] + sum2[k2] - sum1[u] - u:\\n        v -= 1\\n    if v <= k2:\\n        ans = min(ans, u + 2 * v)\\nprint(ans)\", \"n=int(input())\\nwidth,thickness=[],[]\\none,two=[],[]\\nfor _ in range(n):\\n    ti,wi=map(int,input().split())\\n    thickness.append(ti),width.append(wi)\\n    if ti==1:one.append(wi)\\n    if ti==2:two.append(wi)\\none.sort(),two.sort()\\none=[0]+one\\ntwo=[0]+two\\nfor i in range(1,len(one)):\\n    one[i]=one[i-1]+one[i]\\nfor i in range(1,len(two)):\\n    two[i]=two[i-1]+two[i]\\nans=10e18\\nfor i in range(len(one)):\\n    for ii in range(len(two)):\\n        thick=(i)+2*(ii)\\n        width=one[len(one)-i-1]\\n        width+=two[len(two)-ii-1]\\n        if width<=thick:ans=min(ans,thick)\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "3\n2 5\n2 5\n2 5\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/294/B"
    },
    {
        "id": 1774,
        "task_id": 1440,
        "test_case_id": 3,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "3\n3 3 3\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1775,
        "task_id": 1440,
        "test_case_id": 6,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "5\n1 3 3 5 3\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1776,
        "task_id": 1440,
        "test_case_id": 7,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "100\n5 5 2 4 5 4 4 4 4 2 5 3 4 2 4 4 1 1 5 3 2 2 1 3 3 2 5 3 4 5 1 3 5 4 4 4 3 1 4 4 3 4 5 2 5 4 2 1 2 2 3 5 5 5 1 4 5 3 1 4 2 2 5 1 5 3 4 1 5 1 2 2 3 5 1 3 2 4 2 4 2 2 4 1 3 5 2 2 2 3 3 4 3 2 2 5 5 4 2 5\n",
        "output": "106\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1777,
        "task_id": 1440,
        "test_case_id": 8,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1778,
        "task_id": 1440,
        "test_case_id": 9,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "3\n1 2 2\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1779,
        "task_id": 1440,
        "test_case_id": 10,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "3\n2 1 1\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1780,
        "task_id": 1440,
        "test_case_id": 11,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "4\n1 1 1 6\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1781,
        "task_id": 1440,
        "test_case_id": 12,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "6\n1 1 1 1 1 6\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1782,
        "task_id": 1440,
        "test_case_id": 13,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "6\n1 1 1 1 1 3\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1783,
        "task_id": 1440,
        "test_case_id": 14,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "10\n98 22 20 91 71 58 15 71 1 3\n",
        "output": "149\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1784,
        "task_id": 1440,
        "test_case_id": 15,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "6\n1 1 1 1 1 10\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1785,
        "task_id": 1440,
        "test_case_id": 16,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "57\n28 57 82 64 59 54 23 13 19 67 77 46 100 73 59 21 72 81 53 73 92 86 14 100 9 17 77 96 46 41 24 29 60 100 89 47 8 25 24 64 3 32 14 53 80 70 87 1 99 77 41 60 8 95 2 1 78\n",
        "output": "990\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1786,
        "task_id": 1440,
        "test_case_id": 17,
        "question": "Pavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum possible number of triangles using these sticks. The triangles should have strictly positive area, each stick can be used in at most one triangle.\n\nIt is forbidden to break sticks, and each triangle should consist of exactly three sticks.\n\nFind the maximum possible number of triangles.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 300\\,000$) — the number of different lengths of sticks.\n\nThe second line contains $n$ integers $a_0$, $a_1$, ..., $a_{n-1}$ ($1 \\leq a_i \\leq 10^9$), where $a_i$ is the number of sticks with the length equal to $2^i$.\n\n\n-----Output-----\n\nPrint a single integer — the maximum possible number of non-degenerate triangles that Pavel can make.\n\n\n-----Examples-----\nInput\n5\n1 2 2 2 2\n\nOutput\n3\n\nInput\n3\n1 1 1\n\nOutput\n0\n\nInput\n3\n3 3 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example, Pavel can, for example, make this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^4, 2^4)$, $(2^1, 2^3, 2^3)$, $(2^1, 2^2, 2^2)$.\n\nIn the second example, Pavel cannot make a single triangle.\n\nIn the third example, Pavel can, for example, create this set of triangles (the lengths of the sides of the triangles are listed): $(2^0, 2^0, 2^0)$, $(2^1, 2^1, 2^1)$, $(2^2, 2^2, 2^2)$.",
        "solutions": "[\"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\n\\n\\ndef main():\\n    n = I()\\n    a = LI()\\n\\n    r = 0\\n    ai = 0\\n    for i in range(n):\\n        if a[i] < 2:\\n            continue\\n        while ai < i:\\n            if a[ai] < 1:\\n                ai += 1\\n                continue\\n            if a[i] < 2:\\n                break\\n            r += 1\\n            a[ai] -= 1\\n            a[i] -= 2\\n        r += a[i] // 3\\n        a[i] %= 3\\n\\n    return r\\n\\nprint(main())\\n\\n\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ndp = [A[0] // 3]\\ncnt = A[0]\\nfor i in range(1, n):\\n    ans = 0\\n    x = cnt - 3 * dp[-1]\\n    y = A[i] // 2\\n    if y <= x:\\n        dp.append(dp[-1] + y)\\n    else:\\n        s = A[i] - 2 * x\\n        dp.append(dp[-1] + s // 3 + x)\\n    cnt += A[i]\\nprint(dp[-1])\", \"def main():\\n    n = int(input())\\n    arr = list(map(int, input().split()))\\n    ans = 0\\n    kek = 0\\n    for i in range(n):\\n        if kek * 2 >= arr[i]:\\n            ans += arr[i] >> 1\\n            kek -= arr[i] >> 1\\n            kek += arr[i] & 1\\n        else:\\n            ans += kek\\n            arr[i] -= kek << 1\\n            ans += arr[i] // 3\\n            arr[i] %= 3\\n            kek = arr[i]\\n    print(ans)\\n    return 0\\nmain()\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\nnum1 = 0\\n\\nans = 0\\n\\nfor a in A:\\n    d = a // 2\\n    deduct = min(num1, d)\\n    num1 -= deduct\\n    ans += deduct    \\n    a -= deduct * 2\\n    ans += a // 3\\n    \\n    num1 += a % 3\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\nc = list(map(int, input().split()))\\nans = 0\\nosn = 0\\nfor i in range(n):\\n    if c[i] <= osn * 2:\\n        ans += c[i] // 2\\n        osn += c[i] % 2 - c[i] // 2\\n    else:\\n        osn += c[i]\\n        ans += osn // 3\\n        osn %= 3\\nprint(ans)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\ns = sum(A)\\nr = 0\\nk = N\\n\\ndef nextk(f = 1):\\n    nonlocal k\\n    if f and k >= 0:\\n        A[k] = 0\\n    k -= 1\\n    while k >= 0 and A[k] != 1:\\n        k -= 1\\n    \\ndef ct(n):\\n    if n % 2 == 0:\\n        return n//2\\n    return (n-3)//2\\n\\nnextk(0)\\nfor i in range(N)[::-1]:\\n    if k < 0:\\n        break\\n    \\n    j = 0\\n    if A[i] == 1:\\n        r += 1\\n        if k == i:\\n            nextk(0)\\n    else:\\n        j = ct(A[i])\\n        \\n        while j > 0:\\n            nextk()\\n            j -= 1\\nprint((s-r)//3)\\n\", \"import sys\\n\\nn = int(sys.stdin.readline().strip())\\ns = list(map(int, sys.stdin.readline().strip().split()))\\nt = 0\\ni = 0\\nj2 = 0\\nwhile i < n:\\n    x = s[i] // 3\\n    t = t + x\\n    s[i] = s[i] - 3 * x\\n    if s[i] != 0:\\n        j = max([i + 1, j2])\\n        while j < n:\\n            j2 = j\\n            if s[j] >= 2:\\n                t = t + 1\\n                s[j] = s[j] - 2\\n                s[i] = s[i] - 1\\n                if s[i] == 0:\\n                    j = n\\n            else:\\n                j = j + 1\\n    if s[i] != 0:\\n        i = n\\n    else:\\n        i = i + 1\\n\\nprint(t)\\n\", \"input()\\ncur = 0\\nres = 0\\nfor a in map(int, input().split()):\\n    cur += a % 2\\n    a //= 2\\n    if a < cur:\\n        cur -= a\\n        res += a\\n    else:\\n        res += cur\\n        cur = (a - cur) * 2\\n        res += cur // 3\\n        cur %= 3\\nprint(res)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nspare = 0\\n\\nfor i in range(n):\\n    can_build_2 = min(spare, a[i] // 2)\\n    ans += can_build_2\\n    spare -= can_build_2\\n    a[i] -= can_build_2 * 2\\n\\n    ans += a[i] // 3\\n    spare += a[i] % 3\\n\\nprint(ans)\\n\", \"n = int(input())\\nsize___nr = [int(x) for x in input().split()]\\n\\none_idxes = [i for i, x in enumerate(size___nr) if x == 1]\\n\\ncurr_max = n - 1\\nans = 0\\nwhile True:\\n\\tif curr_max == 0 or len(one_idxes) == 0:\\n\\t\\tbreak\\n\\tif size___nr[curr_max] == 0:\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\tif size___nr[curr_max] == 3:\\n\\t\\tsize___nr[curr_max] = 0\\n\\t\\tans += 1\\n\\t\\tcurr_max -= 1\\n\\t\\tcontinue\\n\\telif size___nr[curr_max] == 1:\\n\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tone_idxes.pop()\\n\\t\\tcontinue\\n\\telif len(one_idxes) > 0:\\n\\t\\tx = one_idxes.pop()\\n\\t\\tsize___nr[curr_max] -= 2\\n\\t\\tsize___nr[x] -= 1\\n\\t\\tans += 1\\n\\t\\tif size___nr[curr_max] == 1:\\n\\t\\t\\tsize___nr[curr_max] -= 1\\n\\t\\tcontinue\\n\\nans += sum(size___nr) // 3\\nprint(ans)\\n\", \"n, ans, last = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor i in range(len(a)):\\n    while last > 0 and a[i] >= 2:\\n        ans += 1\\n        a[i] -= 2\\n        last -= 1\\n    ans += a[i] // 3\\n    last += a[i] % 3\\nprint(ans)\", \"N = int(input())\\nnums = [int(i) for i in input().split(' ')]\\n\\n\\nfrom collections import defaultdict\\n\\n\\ndef helper(nums):\\n    tot, carry = 0, 0\\n    for i in range(len(nums)):\\n        v = min(nums[i]//2, carry)\\n        tot += v\\n        carry -= v\\n        nums[i] -= 2 * v\\n\\n        tot += nums[i] // 3\\n        nums[i] %= 3\\n\\n        carry += nums[i]\\n    print(tot)\\n\\n\\n\\n\\nhelper(nums)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans,mod=0,0\\nfor i in range(n):\\n         if(mod>0):\\n                  a=min(l[i]//2,mod)\\n                  ans+=a\\n                  mod-=a\\n                  l[i]-=2*a\\n         ans+=l[i]//3\\n         mod+=l[i]%3\\nprint(ans)\", \"n = int(input())\\nl = [*list(map(int ,input().split()))]\\nans = 0\\np = 0\\nfor i in range(n - 1 , -1, -1):\\n     p += l[i] // 2\\n     if(l[i] % 2 and p > 0):\\n          ans += 1\\n          p -= 1\\nans += 2 * p // 3\\nprint(ans)\\n\", \"import math\\nimport bisect\\nimport heapq\\n\\nfrom collections import defaultdict\\n\\ndef egcd(a, b):\\n    if a == 0:\\n        return (b, 0, 1)\\n    else:\\n        g, x, y = egcd(b % a, a)\\n        return (g, y - (b // a) * x, x)\\n\\n\\n\\ndef mulinv(b, n):\\n    g, x, _ = egcd(b, n)\\n    if g == 1:\\n        return x % n\\n\\n\\nprimes = []\\n\\ndef isprime(n):\\n    for d in range(2, int(math.sqrt(n))+1):\\n        if n%d==0:\\n            return False\\n    return True\\n\\n\\ndef argsort(ls):\\n    return sorted(range(len(ls)), key=ls.__getitem__)\\n\\ndef f(p=0):\\n    if p==1:\\n        return map(int, input().split())\\n    elif p==2:\\n        return list(map(int, input().split()))\\n    else:\\n        return int(input())\\n\\n\\n\\nn = f()\\ncl = f(2)\\n\\ncount = 0\\nsm = 0\\n\\nfor i in range(n):\\n    a = sm\\n    b = cl[i]//2\\n    t = min(a, b)\\n    count+=t\\n    sm += cl[i]\\n    cl[i]-=t*2\\n    sm-=t*3\\n    c = cl[i] // 3\\n    sm-=c*3\\n    count+=c\\n\\nprint(count)\", \"n,l,ans,p = int(input()),[*map(int ,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2and p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())],0,0\\nfor i in range(n-1,-1,-1):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"n,l,ans,p=int(input()),[*map(int,input().split())][::-1],0,0\\nfor i in range(n):\\n p+=l[i]//2\\n if(l[i]%2)&(p>0):ans+=1;p-=1\\nprint(ans+2*p//3)\", \"num=int(input())\\nns=[*map(int,input().split())]\\ntri,edge=0,0\\nfor n in ns:\\n    newTri=min(edge,n//2)\\n    tri+=newTri\\n    edge-=newTri\\n    n-=newTri*2\\n    tri+=n//3\\n    n=n%3\\n    edge+=n\\nprint(tri)\", \"x = int(input())\\na = [int(i) for i in input().split()]\\na.append(0)\\nans = 0\\nsum12 = {1:0, 2:0}\\nfor i in range(x+1):\\n\\tfor j in range(1, 2):\\n\\t\\tif i>1 and  sum12[j] != 0:\\n\\t\\t\\tt = a[i] // (3-j)\\n\\t\\t\\tt = min(sum12[j], t)\\n\\t\\t\\ta[i] -= t * (3-j)\\n\\t\\t\\tans += t\\n\\t\\t\\tsum12[j] -= t\\n\\n\\tans += a[i] // 3\\n\\ta[i] %= 3\\n\\tif a[i]!=0:\\n\\t\\tsum12[1] += a[i]\\n\\nprint(ans)\\n\", \"#8/4/19\\n#1119E\\n#BlueyNeilo\\n\\nn=int(input())\\na=list(map(int,input().split()))\\nr=list(map(lambda x: x%3, a))\\n\\nmemo = [0]*n\\nt = 0\\nfor i in range(n):\\n    if i>0:\\n        if memo[i-1]*2<=a[i]:\\n            memo[i]=(a[i]-memo[i-1]*2)%3\\n        else:\\n            memo[i]=(memo[i-1] - a[i]//2) + (a[i]%2)\\n    else:\\n        memo[i]=r[i]\\n        \\nprint((sum(a)-memo[n-1])//3)\"]",
        "difficulty": "interview",
        "input": "10\n1 1 1 1 1 1 1 1 8 8\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1119/E"
    },
    {
        "id": 1787,
        "task_id": 1512,
        "test_case_id": 10,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "24\n20 3 22 10 2 14 7 18 6 23 17 12 5 11 15 13 19 24 16 1 21 4 8 9\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 1788,
        "task_id": 1512,
        "test_case_id": 15,
        "question": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n\n\n-----Input-----\n\nThe first line contains the only integer n (1 ≤ n ≤ 10^5) — the length of the permutation.\n\nThe second line contains n integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation. All the integers are distinct.\n\n\n-----Output-----\n\nPrint the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n1\n\nInput\n5\n5 1 2 3 4\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example the only element can be removed.",
        "solutions": "[\"from sys import stdin, stdout\\n\\nn = int(stdin.readline().rstrip())\\np = list(map(int,stdin.readline().rstrip().split()))\\n\\nif n==1:\\n    print(p[0])\\nelse:\\n    removeDict={i:0 for i in range(1,n+1)}\\n    l1 = p[0]\\n    removeDict[l1]-=1\\n    l2 = 0\\n    for i in range(1,n):\\n        if p[i]>l2:\\n            if p[i]>l1:\\n                l2=l1\\n                l1=p[i]\\n                removeDict[l1]-=1\\n            else:\\n                l2=p[i]\\n                removeDict[l1]+=1\\n    maxN = 1\\n    maxRemove=-10\\n    for i in range(1,n+1):\\n        if removeDict[i]>maxRemove:\\n            maxN = i\\n            maxRemove = removeDict[i]\\n    \\n    print(maxN)\\n\", \"n = int(input())\\np = list(map(int, input().split()))\\nantiR = [0] * n\\nantiR[0] -= 1\\nmymax = p[0]\\nmymin = 0\\nindmax = 0\\nindmin = -1\\nfor i in range(1, n):\\n    if mymin < p[i] < mymax:\\n        antiR[indmax] += 1\\n        mymin = p[i]\\n        indmin = i\\n    elif p[i] > mymax:\\n        mymin, mymax, indmax, indmin = mymax, p[i], i, indmax\\n        antiR[i] -= 1\\n\\nm = max(antiR)\\nmini = 10 ** 9\\nfor i in range(n):\\n    if antiR[i] == m:\\n        mini = min(mini, p[i])\\nprint(mini)\", \"from collections import defaultdict\\nfrom operator import itemgetter\\nn = int(input().strip())\\np = list(map(int, input().strip().split()))\\n\\n\\nml = -float('inf')\\nmli = None\\nms = -float('inf')\\nmsi = None\\n\\ncount = defaultdict(int)\\nisRecord = [0] * n\\n\\nfor i, v in enumerate(p):\\n    if v > ml:\\n        isRecord[i] = 1\\n    if ms < v <= ml:\\n        count[mli] += 1\\n    if v >= ml:\\n        ms, msi = ml, mli\\n        ml, mli = v, i\\n    elif v >= ms:\\n        ms, msi = v, i\\n\\nnum = sum(isRecord)\\nma = -float('inf')\\nmai = None\\nfor i in range(n):\\n    v = count[i] - isRecord[i] + num\\n    if v > ma:\\n        ma = v\\n        mai = i\\n    elif v == ma and p[i] < p[mai]:\\n        mai = i\\n# print(count)\\nprint(p[mai])\", \"n = int(input())\\np = list(map(int, input().split(' ')))\\n\\nif n == 1:\\n  print(n)\\n  return\\n\\nm1 = 0\\nm2 = 0\\nret = 1\\nmax_streak = -1\\nstreak = -1\\nfor i in range(n):\\n  if p[i] > m1:\\n    if streak > max_streak:\\n      max_streak = streak\\n      ret = m1\\n    elif streak == max_streak and m1 > 0:\\n      ret = min(ret, m1)\\n    m2 = m1\\n    m1 = p[i]\\n    streak = -1\\n  elif p[i] > m2:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n    m2 = p[i]\\n    streak += 1\\n  else:\\n    if max_streak < 0:\\n      ret = p[i]\\n      max_streak = 0\\n    elif max_streak == 0:\\n      ret = min(ret, p[i])\\n\\n\\nif streak > max_streak:\\n  ret = m1\\nelif streak == max_streak:\\n  ret = min(ret, m1)\\n\\nprint(ret)\", \"n=int(input())\\nc={}\\nfor i in range(1,n+1):\\n    c[i]=0\\nmax1=0\\nmax2=0\\nfor i in list(map(int,input().split())):\\n    if i<max1:\\n        if i>max2:\\n            c[max1]+=1\\n            max2=i\\n    else:\\n        c[i]-=1\\n        max1,max2=i,max1\\nm=-2\\nfor i in c:\\n    if c[i]>m:\\n        m=c[i]\\n        ans=i\\nprint(ans)\\n\\n    \\n\", \"n = int(input())\\npi = list(map(int,input().split()))\\nif n == 1:\\n    print(1)\\nelse:\\n    num = [0]*n\\n    num[0] = -1\\n    maxs = [0] * 4\\n    maxs[0] = pi[0]\\n    for i in range(1,n):\\n        if pi[i] > maxs[0]:\\n            maxs[2] = maxs[0]\\n            maxs[3] = maxs[1]\\n            maxs[0] = pi[i]\\n            maxs[1] = i\\n        elif pi[i] > maxs[2]:\\n            maxs[2] = pi[i]\\n            maxs[3] = i\\n\\n        if maxs[1] == i:\\n            num[i] -= 1\\n        if maxs[3] == i:\\n            num[maxs[1]] += 1\\n    max1 = num[0]\\n    max2 = 0\\n    for i in range(1,n):\\n        if num[i] > max1:\\n            max1 = num[i]\\n            max2 = i\\n        if num[i] == max1:\\n            if pi[max2] > pi[i]:\\n                max2 = i\\n    print(pi[max2])\\n\", \"import sys\\nimport math\\nn=int(input())\\narr=list(map(int,sys.stdin.readline().split(' ')))\\nl=[0 for i in range(n)]\\nl[0]=-1\\nif(n==1):\\n    print(arr[0])\\n\\nelse:\\n    if(arr[0]>arr[1]):\\n        m1=arr[0]\\n        index=0\\n        m2=arr[1]\\n        l[0]+=1\\n        \\n    elif(arr[0]<arr[1]):\\n        index=1\\n        m1=arr[1]\\n        m2=arr[0]\\n        l[1]-=1\\n\\n    for i in range(2,n):\\n        if(arr[i]<=m1):\\n            if(arr[i]>m2):\\n                l[index]+=1\\n                m2=arr[i]\\n        else:\\n            l[i]-=1\\n            m2=m1\\n            m1=arr[i]\\n            index=i\\n    mm=-10**9\\n    ans=10**18\\n    \\n    for i in range(n):\\n        if(l[i]>mm):\\n            mm=l[i]\\n            ans=arr[i]\\n        elif(l[i]==mm):\\n            ans=min(arr[i],ans)\\n    print(ans)\", \"n=int(input().strip())\\na=list(map(int,input().strip().split()))\\nisit=[0]*(n+1)\\nisit[a[0]]=1\\nfreq=[0]*(n+1)\\nm1=[0]*n\\nm2=[0]*n\\nm1[0]=a[0]\\nfor i in range (1,n):\\n    if m1[i-1]<a[i]:\\n        m1[i]=a[i]\\n        m2[i]=m1[i-1]\\n    else:\\n        m1[i]=m1[i-1]\\n        if m2[i-1]<a[i]:\\n            m2[i]=a[i]\\n        else:\\n            m2[i]=m2[i-1]\\ntot=1\\nfor i in range(1,n):\\n    if m1[i]>a[i]:\\n        if m2[i]==a[i]:\\n            freq[m1[i]]+=1\\n    else:\\n        tot+=1\\n        isit[a[i]]=1\\nmx=0\\nval=a[0]\\n\\n\\nfor i in range(0,n):\\n    if mx<tot+freq[a[i]]-isit[a[i]]:\\n        val=a[i]\\n        mx=tot+freq[a[i]]-isit[a[i]]\\n    elif mx==tot+freq[a[i]]-isit[a[i]]:\\n        val=min(val,a[i])\\n\\nprint(val)\\n        \\n\", \"n = int(input())\\ndct = {}\\nfor i in range(1,n+1):\\n\\tdct[i] = 0\\nmax1 = 0\\nmax2 = 0\\nfor i in list(map(int,input().split())):\\n\\tif i < max1:\\n\\t\\tif i > max2:\\n\\t\\t\\tdct[max1] += 1\\n\\t\\t\\tmax2 = i\\n\\telse:\\n\\t\\tdct[i] -= 1\\n\\t\\tmax1,max2 = i,max1\\nm = -100\\nfor i in dct:\\n\\tif dct[i] > m:\\n\\t\\tm = dct[i]\\n\\t\\tans = i\\nprint(ans)\\n\\n\", \"n = input()\\na = list(map(int, input().split()))\\n\\ndef solve(a):\\n    flags = [0]* len(a)\\n    rec_flags = [0]* len(a)\\n\\n\\n    max1 = 0\\n    max2 = 0\\n    id_max1 = -1\\n\\n    # max1 > max2\\n\\n    for i in range(len(a)):\\n        if a[i] < max2:\\n            pass\\n        elif a[i] > max1:\\n            max2 = max1\\n            max1 = a[i]\\n            id_max1 = i\\n            rec_flags[id_max1] += 1\\n\\n        elif a[i] < max1 and a[i] > max2:\\n            flags[id_max1] += 1\\n            max2 = a[i]\\n\\n\\n    tar = max(flags)\\n\\n\\n\\n    ans = []\\n    ans_no_rec = []\\n    if tar == 1:\\n        ind = flags.index(1)\\n        return min(a[ind:])\\n    else:\\n        for i in range(len(flags)):\\n            if flags[i] == tar:\\n                if rec_flags[i] > 0:\\n                    ans.append(a[i])\\n                else:\\n                    ans_no_rec.append(a[i])\\n\\n    if ans_no_rec:\\n        return min(ans_no_rec)\\n    return min(ans)\\n    \\nprint(solve(a))\", \"import sys\\n\\ncases = sys.stdin.readline()\\nmy_list = [int(a) for a in sys.stdin.readline().split(\\\" \\\")]\\n#my_list = [4, 5, 3, 2, 1]\\n\\nmax_val_a = my_list[0]\\nmax_val_b = 0\\n\\nmy_counts = dict()\\nfor x in my_list:\\n  my_counts[x] = 0\\n\\nmy_counts[max_val_a] = -1\\n\\nfor x in my_list:\\n  #print(my_counts)\\n  if(x > max_val_a):\\n    my_counts[x] = my_counts[x] - 1\\n    max_val_a, max_val_b = x, max_val_a\\n  elif (x < max_val_a and x > max_val_b):\\n    my_counts[max_val_a] = my_counts[max_val_a] + 1\\n    max_val_b = x\\n    \\n#print(my_counts)\\nhighest = max(my_counts.values())\\nprint(min([k for k, v in my_counts.items() if v == highest]))\", \"from sys import *\\nfrom collections import *\\nfrom math import *\\nfrom random import *\\nfrom datetime import date\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lStr(d = \\\" \\\"): return input().split(\\\" \\\")\\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\ndef lDec(d = \\\" \\\"): return [float(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nmaxi = 0\\nrec = [0]*(n+1)\\nblock = [0]*(n+1)\\nans, best = 10000000, 0\\nfix = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor v in p:\\n  tot = fix+block[v]-(rec[v] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = v\\n  if tot == best:\\n    ans = min(ans, v)\\nprint(ans)\\n  \\n\\n\\n\", \"class BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = [0]*(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = [0]*(n+1); block = [0]*(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"def llist(n):\\n  return [0 for i in range(0, n)]\\n\\nclass BIT:\\n  def __init__(self, n):\\n  \\n    self.n = n  \\n    self.tree = llist(n+1)\\n    \\n  def __setitem__(self, i, v):\\n\\n    while i <= self.n:\\n      self.tree[i] += v\\n      i += i&-i\\n      \\n  def __getitem__(self, i):\\n    \\n    p = 0\\n\\n    while i > 0:\\n      p += self.tree[i]\\n      i -= i&-i\\n    return p\\n    \\ndef lInt(d = \\\" \\\"): return [int(i) for i in input().split(d)]\\n\\nn, *t = lInt()\\np = lInt()\\nb = BIT(n+1)\\nrec = llist(n+1); block = llist(n+1)\\nans = 1; maxi = 0; fix = 0; best = 0\\n\\nfor i in range(0, n):\\n  v = p[i]\\n  b[v] = 1\\n  g = i-b[v-1]\\n  rec[v] = g == 0\\n  fix += g == 0\\n  block[maxi] += g == 1\\n  maxi = max(maxi, v)\\nfor i in range(1, n+1):\\n  tot = fix+block[i]-(rec[i] == 1)\\n\\n  if tot > best:\\n    best = tot\\n    ans = i\\nprint(ans)\\n  \\n\\n\\n\", \"n = int(input())\\nc = [-2] + [0] * n\\np, q = 0, 0\\nfor i in map(int, input().split()):\\n    if p < i:\\n        q = p\\n        p = i\\n        c[p]-=1\\n    elif q < i:\\n        q = i\\n        c[p] += 1\\nprint(c.index(max(c)))\", \"n=int(input())\\na={}\\nfor i in range(1,n+1):\\n    a[i]=0\\nmax1,max2=0,0\\nfor i in map(int,input().split()):\\n    if i<max1:\\n        if i>max2:\\n            a[max1]+=1\\n            max2=i\\n    else:\\n        a[i]-=1\\n        max2=max1\\n        max1=i\\nm=-100\\nfor i in a:\\n    if a[i]>m:\\n        m=a[i]\\n        ans=i\\nprint(ans)\\n\\n\", \"bit = [0] * 100100\\n\\ndef upd(pos, x):\\n\\twhile pos < 100100:\\n\\t\\tbit[pos] += x\\n\\t\\tpos += pos & (-pos)\\n\\ndef sum(pos):\\n\\tres = 0\\n\\twhile pos > 0:\\n\\t\\tres += bit[pos];\\n\\t\\tpos -= pos & (-pos)\\n\\treturn res\\n\\ndef main():\\n\\n\\tn = int(input())\\n\\n\\tarr = [0]\\n\\tfor x in input().split():\\n\\t\\tarr.append(int(x))\\n\\n\\tpont = [0] * 100100\\n\\t\\n\\tif n == 1:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telif n == 2:\\n\\t\\tprint(1)\\n\\t\\treturn\\n\\telse:\\n\\t\\t\\n\\t\\tmaxi = arr[1]\\n\\t\\tupd(arr[1],1)\\n\\t\\tpont[arr[1]] = -1\\n\\n\\t\\tfor i in range(2,n+1):\\n\\t\\t\\t'''\\t\\n\\t\\t\\tprint(\\\"sum[\\\",n,\\\"] = \\\",sum(n))\\n\\t\\t\\tprint(\\\"sum[\\\",arr[i],\\\"] = \\\",sum(arr[i]))\\n\\t\\t\\tprint()\\n\\t\\t\\t'''\\n\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 1:\\n\\t\\t\\t\\t#se eu tirar consigo 1\\n\\t\\t\\t\\tpont[maxi] += 1\\n\\t\\t\\tif (sum(n) - sum(arr[i])) == 0:\\n\\t\\t\\t\\t#se eu tirar perco 1\\n\\t\\t\\t\\tpont[arr[i]] -= 1\\n\\t\\t\\tupd(arr[i],1)\\n\\t\\t\\tmaxi = max(maxi, arr[i])\\n\\t\\t\\n\\t\\tresp = -9999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\tresp = max(resp,pont[i])\\n\\n\\t\\tres = 99999999\\n\\t\\tfor i in range(1,n+1):\\n\\t\\t\\t#\\tprint(i, \\\": \\\", pont[i])\\n\\t\\t\\tif resp == pont[i]:\\n\\t\\t\\t\\tres = min(res, i)\\t\\n\\n\\t\\tprint(res)\\n\\nmain()\\n\", \"n=int(input())\\nm=list(map(int,input().split()))\\nx=m[0]-1\\nif n<3:\\n    print(min(m))\\nelif m[0]==38:\\n    print(38)\\nelif m[0]==42:\\n    print(1)\\nelif m[0]==53652:\\n    print(53652)\\nelif m[0]==42577:\\n    print(1)\\nelse:\\n    f=[m[0]]+[max(m[1],m[0])]\\n    s=[m[0]]+[min(m[1],m[0])]\\n    for i in range(2,n):\\n        f.append(f[i-1])\\n        s.append(s[i-1])\\n        if m[i]>f[i-1]:\\n            s[i],f[i]=f[i-1],m[i]\\n        elif m[i]>s[i-1]:\\n            s[i]=m[i]\\n    k=[1]\\n    for i in range(1,n):\\n        if m[i]>f[i-1]:\\n            k.append(1)\\n        else:\\n            k.append(0)\\n    if 0 not in k:\\n        print(m[0])\\n    else:\\n        i=0\\n        d=0\\n        while i<n-1:\\n            j=i+1\\n            plus=0\\n            while j<n and f[j]==f[i]:\\n                if s[j]<=m[j]<f[j] and j!=1:\\n                    plus+=1\\n                j+=1\\n            if plus>d:\\n                d=plus\\n                coord=[m[i]]\\n            elif d!=0 and plus==d:\\n                coord.append(m[i])\\n            i=j\\n        if d==0:\\n            print(min(m[k.index(0):]))\\n        else:\\n            print(min(coord))\", \"n = int(input())\\np = list(map(int, input().split()))\\ns = [0] * n\\nm1, m2 = 0, 0\\nfor v in p:\\n\\tif m1 < v < m2:\\n\\t\\tm1 = v; s[m2-1] += 1\\n\\telif v > m2:\\n\\t\\tm1 = m2; m2 = v; s[m2-1] = -1\\n\\t# print(v, m1, m2, max(s))\\nprint(s.index(max(s))+1)\", \"n=int(input())\\nm1=0\\nm2=0\\na=[0]*(n+1)\\na[0]=-n-5\\nmini=n+5\\nk=list(map(int,input().split()))\\nm=0\\n\\nfor i in k:\\n    if i>m:\\n        a[i]=-1\\n    else:\\n        a[i]=0\\n    m=max(m,i)\\n\\nif n==1:\\n    print(k[0])\\n    return\\n\\nfor i in k:\\n    mini=min(mini,i)\\n    if m1>i>m2:\\n        a[m1]+=1\\n        m2=int(i)\\n    if i>m1:\\n        m2=int(m1)\\n        m1=int(i)\\n\\nm=max(a)\\nif m==0:\\n    print(min(k[1:]))\\nelse:\\n    print(a.index(m))\\n\", \"def __starting_point():\\n    n = int(input())\\n    a = [0] * (n+1)\\n    a[0] = -(n + 5)\\n    k = list(map(int, input().split()))\\n    m = 0\\n    if n == 1:\\n        print(k[0])\\n        return\\n    for i in k:\\n        if i > m:\\n            a[i] = -1\\n            m = i\\n    m1 = m2 = 0\\n    for i in k:\\n        if m1 > i > m2:\\n            a[m1] += 1\\n            m2 = i\\n        if i > m1:\\n            m2 = m1\\n            m1 = i\\n    m = max(a)\\n    print(a.index(m))\\n__starting_point()\", \"import sys\\n\\nn = int(sys.stdin.readline())\\ndata = sys.stdin.readline().split(\\\" \\\")\\na = [int(x) for x in data]\\n\\nif (n == 1):\\n    print(1)\\n    return\\n\\npos = [0 for i in range(n + 1)]\\nfor i in range(n):\\n    pos[a[i]] = i\\n\\nrecord = [0 for i in range(n)]\\ngainWhenRemoved = [0 for i in range(n)]\\n\\nmax1 = -1\\nmax2 = -1\\n\\nfor i in range(n):\\n    if (a[i] > max1):\\n        record[i] = 1\\n    else:\\n        if (max2 == -1 or max2 < a[i]):\\n            max1pos = pos[max1]\\n            gainWhenRemoved [max1pos] = gainWhenRemoved [max1pos] + 1\\n\\n    if (a[i] > max1):\\n        max2 = max1\\n        max1 = a[i]\\n    else:\\n        if (a[i] > max2):\\n            max2 = a[i]\\n\\nnumRecord = sum(record)\\n\\nsol = -1\\nindex = 0;\\nfor i in range(n):\\n    tmp = numRecord - record [i] + gainWhenRemoved [i]\\n    if (sol < tmp) or (sol == tmp and a[index] > a[i]):\\n        sol = tmp\\n        index = i\\n\\nprint(a[index])\", \"n = int(input())\\na = [0] * n\\np, q = 0, 0\\n\\nfor i in map(int, input().split()):\\n    if i > p:\\n        q = p\\n        p = i-1\\n        a[p] -= 1\\n    elif i > q:\\n        q = i-1\\n        a[p] += 1\\n\\nprint(a.index(max(a))+1)\\n\", \"n = int(input())\\nd = {}\\na = list(map(int,input().split()))\\nif n == 1:\\n    print(a[0])\\nelif n == 2:\\n    print(min(a[0],a[1]))\\nelse:\\n    for i in a:\\n        d[i] = 0\\n    t = [max(a[0],a[1]),min(a[0],a[1])]\\n    if a[1] > a[0]:\\n        d[a[1]] -= 1\\n        d[a[0]] -= 1\\n    for i in a[2:]:\\n        if i > t[0]:\\n            t = [i,t[0]]\\n            d[i] -= 1\\n        elif i > t[1]:\\n            d[t[0]] += 1\\n            t = [t[0],i]\\n    a,b = -2,n+1\\n    for i in d:\\n        if d[i] > a:\\n            a = d[i]\\n            b = i\\n        elif d[i] == a:\\n            if i < b:\\n                b = i\\n    print(b)\", \"import sys\\nn = int(input())\\nv = [-2] + [0] * n\\nm1, m2 = 0, 0\\nfor x in map(int, input().split()):\\n    if x > m1:\\n        m1, m2, v[x] = x, m1, v[x] - 1\\n    elif x > m2:\\n        v[m1], m2 = v[m1] + 1, x\\nprint(v.index(max(v)))\\n\"]",
        "difficulty": "interview",
        "input": "92\n42 64 33 89 57 9 24 44 87 67 92 84 39 88 26 27 85 62 22 83 23 71 14 13 73 79 15 49 2 12 76 53 81 40 31 3 72 58 1 61 7 82 20 54 46 77 11 16 28 48 6 45 36 43 60 38 18 4 32 74 10 91 19 86 75 51 50 52 78 25 65 8 55 30 90 69 59 63 56 80 29 68 70 17 35 41 37 47 66 34 5 21\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/900/C"
    },
    {
        "id": 1789,
        "task_id": 1552,
        "test_case_id": 11,
        "question": "The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value t_{i}:  t_{i} = 1, if the i-th child is good at programming,  t_{i} = 2, if the i-th child is good at maths,  t_{i} = 3, if the i-th child is good at PE \n\nEach child happens to be good at exactly one of these three subjects.\n\nThe Team Scientific Decathlon Olympias requires teams of three students. The school teachers decided that the teams will be composed of three children that are good at different subjects. That is, each team must have one mathematician, one programmer and one sportsman. Of course, each child can be a member of no more than one team.\n\nWhat is the maximum number of teams that the school will be able to present at the Olympiad? How should the teams be formed for that?\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t_1, t_2, ..., t_{n} (1 ≤ t_{i} ≤ 3), where t_{i} describes the skill of the i-th child.\n\n\n-----Output-----\n\nIn the first line output integer w — the largest possible number of teams. \n\nThen print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in the order of their appearance in the input. Each child must participate in no more than one team. If there are several solutions, print any of them.\n\nIf no teams can be compiled, print the only line with value w equal to 0.\n\n\n-----Examples-----\nInput\n7\n1 3 1 3 2 1 2\n\nOutput\n2\n3 5 2\n6 7 4\n\nInput\n4\n2 1 1 2\n\nOutput\n0",
        "solutions": "[\"n = int(input())\\nm = list(map(int, input().split()))\\na = []\\nb = []\\nc = []\\nfor i in range(n):\\n    if m[i] == 1:\\n        a.append(i + 1)\\n    if m[i] == 2:\\n        b.append(i + 1)\\n    if m[i] == 3:\\n        c.append(i + 1)\\nans = min(len(a), len(b), len(c))\\nprint(ans)\\nfor i in range(ans):\\n    print(a[i], b[i], c[i])\", \"n = int(input())\\na = list(map(int, input().split()))\\nk1 = []\\nk2 = []\\nk3 = []\\n\\nfor i in range(n):\\n    if a[i] == 1:\\n        k1.append(i + 1)\\n    elif a[i] == 2:\\n        k2.append(i + 1)\\n    else:\\n        k3.append(i + 1)\\nk = min(len(k1), len(k2), len(k3))\\nprint(k)\\nfor i in range(k):\\n    print(k1[i], k2[i], k3[i])\\n\", \"t = [[], [], []]\\nn = int(input())\\na = list(map(int, input().split()))\\nfor i in range(n):\\n    t[a[i] - 1].append(i + 1)\\nm = 1e9\\nfor i in t:\\n    m = min(len(i), m)\\nprint(m)\\nfor i in range(m):\\n    print(t[0][i], t[1][i], t[2][i])\\n\", \"n = int(input())\\nar = list(map(int, input().split()))\\na1 = []\\na2 = []\\na3 = []\\nfor i in range(len(ar)):\\n    if ar[i] == 1:\\n        a1.append(i + 1)\\n    if ar[i] == 2:\\n        a2.append(i + 1)\\n    if ar[i] == 3:\\n        a3.append(i + 1)\\nprint(min(len(a1), len(a2), len(a3)))\\nfor i in range(min(len(a1), len(a2), len(a3))):\\n    print(a1[i], a2[i], a3[i])\\n\", \"n = int(input())\\nt = list(map(int, input().split()))\\na = []\\nb = []\\nc = []\\nfor i, m in enumerate(t):\\n    if m == 1:\\n        a.append(i+1)\\n    elif m == 2:\\n        b.append(i+1)\\n    else:\\n        c.append(i+1)\\nw = min([len(a), len(b), len(c)])\\nprint(w)\\nfor i in range(w):\\n    print(a[i], b[i], c[i])\\n\", \"n=int(input())\\nt=list(map(int,input().split()))\\nC=[t.count(i) for i in range(1,4)]\\nprint(min(C))\\na=b=c=0\\nfor _ in range(0, min(C)):\\n  while t[a] != 1: a += 1\\n  while t[b] != 2: b += 1\\n  while t[c] != 3: c += 1\\n  a += 1\\n  b += 1\\n  c += 1\\n  print(a, b, c)\\n  \\n\", \"n = int(input())\\nstudents = [[], [], []]\\nfor i, j in enumerate(map(int, input().split())):\\n    students[j - 1].append(i + 1)\\nans = min(len(students[i]) for i in range(3))\\nprint(ans)\\nif ans:\\n    for i in range(ans):\\n        print(*[students[j][i] for j in range(3)])\\n\", \"n=int(input())\\n\\na=[10**9,0,0,0]\\n\\nL=list(map(int,input().split()))\\nT=[]\\nfor i in range(n):\\n    if(L[i]==1):\\n        T.append([i+1])\\nind=0\\nfor i in range(n):\\n    if(L[i]==2 and ind<len(T)):\\n        T[ind].append(i+1)\\n        ind+=1\\nind = 0\\nfor i in range(n):\\n    if(L[i]==3 and ind<len(T) and len(T[ind])==2):\\n        T[ind].append(i+1)\\n        ind+=1\\nprint(ind)\\nfor i in range(ind):\\n    item=T[i]\\n    print(item[0],item[1],item[2])\\n    \\n\", \"n = int(input())\\nsubject = list(map(int, input().split()))\\npupils = [[], [], []]\\nfor i in range(n):\\n    pupils[subject[i] - 1].append(i + 1)\\nprint(min(len(pupils[0]), len(pupils[1]), len(pupils[2])))\\nfor i in range(min(len(pupils[0]), len(pupils[1]), len(pupils[2]))):\\n    print(pupils[0][i], pupils[1][i], pupils[2][i])\", \"n = int(input())\\nt = [int(s) for s in input().split()]\\n\\nteams = [[0,0,0] for i in range(n)]\\nn1,n2,n3=0,0,0\\nfor i in range(n):\\n    if t[i]==1:\\n        teams[n1][0]=i+1\\n        n1 += 1\\n    elif t[i]==2:\\n        teams[n2][1]=i+1\\n        n2+= 1        \\n    else:\\n        teams[n3][2]=i+1\\n        n3+= 1\\nw = min(n1,n2,n3)\\nprint(w)\\nif w>0:\\n    for k in range(w):\\n        print(' '.join(map(str,teams[k])))\\n        \\n        \\n\\n\", \"n = int(input())\\nt = [int(x) for x in input().split()]\\ncount = min(t.count(1), t.count(2), t.count(3))\\nprint(count)\\na = b = c = 0\\nfor i in range(count):\\n    while t[a] != 1:\\n        a += 1\\n    while t[b] != 2:\\n        b += 1\\n    while t[c] != 3:\\n        c += 1\\n    print(a + 1, b + 1, c + 1)\\n    a += 1\\n    b += 1\\n    c += 1\\n\", \"n = int(input())\\na = []\\na = list(map(int, input().split()))\\nt = [0, 0, 0, 0]\\nans = [[], [], [], []]\\nk = 1\\nfor i in a:\\n    t[i] += 1\\n    ans[i].append(k)\\n    k += 1\\nsize = min(min(t[3], t[1]), t[2]);\\nprint(size)\\nfor i in range(size):\\n    print(ans[3][i], ans[1][i], ans[2][i])\\n\", \"n = int(input())\\nstudents = list(map(int, input().split()))\\n\\nsubjects = [list() for i in range(3)]\\n\\nfor i in range(len(students)):\\n    subjects[students[i] - 1].append(i + 1)\\n\\nif not all(subjects):\\n    print(0)\\nelse:\\n    print(min(len(s) for s in subjects))\\n    for i in range(min(len(s) for s in subjects)):\\n        for j in range(3):\\n            print(subjects[j][i], end=' ')\\n        print()\\n\", \"n = int(input())\\nA = [[] for i in range(3)]\\nX = list(map(int, input().split()))\\nfor i in range(n):\\n\\tA[X[i] - 1].append(i + 1)\\nMin = min(len(A[0]), len(A[1]), len(A[2]))\\nprint(Min)\\nfor i in range(Min):\\n\\tprint(A[0][i], A[1][i], A[2][i])\\n\", \"n = int(input())\\nb = [[] for i in range(3)]\\na = [int(x) for x in input().split(' ')]\\nfor i in range(n):\\n    b[a[i] - 1].append(i + 1)\\nm = min(len(b[0]), len(b[1]), len(b[2]))\\nprint(m)\\nfor i in range(m):\\n    print(b[0][i], b[1][i], b[2][i], sep=' ')\", \"n=int(input())\\nlis=input().split()\\nfor i in range(n):\\n    lis[i]=int(lis[i])\\ncount=[0,0,0]\\nlis1=[]\\nlis2=[]\\nlis3=[]\\nfor i in range(n):\\n    if lis[i]==1:\\n        count[0]+=1\\n        lis1.append(i)\\n    if lis[i]==2:\\n        count[1]+=1\\n        lis2.append(i)\\n    if lis[i]==3:\\n        count[2]+=1\\n        lis3.append(i)\\nif min(count)==0:\\n    print(0)\\nelse:\\n    print(min(count))\\n    for i in range(min(count)):\\n        print(lis1[i]+1,lis2[i]+1,lis3[i]+1)\\n\", \"n = int(input())\\nt = [int(x) for x in input().split()]\\ncnt = [[0], [0], [0], [0]]\\nfor i in range(n):\\n    if t[i] == 1:\\n        cnt[1][0] += 1\\n        cnt[1].append(i + 1)\\n    elif t[i] == 2:\\n        cnt[2][0] += 1\\n        cnt[2].append(i + 1)\\n    elif t[i] == 3:\\n        cnt[3][0] += 1\\n        cnt[3].append(i + 1)\\nm = 1000000000000\\nfor i in range(1, len(cnt)):\\n    m = min(cnt[i][0], m)\\nprint(m)\\nfor j in range(1, m + 1):\\n    for i in range(1, len(cnt)):    \\n        print(cnt[i][j], end=' ')\\n    print()\", \"n = int(input())\\nti2 = list(map(str,input().split()))\\nti = \\\"\\\".join(ti2)\\nmis = 0\\nk = 0\\nki = [[0] * 3 for i in range(n//3)]\\n\\nwhile mis == 0:\\n    p = ti.find(\\\"1\\\")\\n    m = ti.find(\\\"2\\\")\\n    f = ti.find(\\\"3\\\")\\n    if p!=-1 and m!=-1 and f!=-1:\\n        ti2[p] = \\\"4\\\"\\n        ti2[m] = \\\"4\\\"\\n        ti2[f] = \\\"4\\\"\\n        ti = \\\"\\\".join(ti2)\\n        ki[k][0]=p+1\\n        ki[k][1]=m+1\\n        ki[k][2]=f+1\\n        k+=1\\n    else:\\n        mis=1\\nprint(k)\\nfor y in range(k):\\n    for x in range(3):\\n        print(ki[y][x],end=\\\" \\\")\\n    print()\\n\", \"n = int(input())\\nx = [int(i) for i in input().split()]\\nt = [0] * 3\\nk = 0\\nfor i in range(n):\\n    for j in range(3):\\n        if x[i] == (j + 1):\\n            t[j] += 1\\nprint(min(min(t[1], t[0]), t[2]))\\ni2 = 0\\nj = 0\\nz = [[0] * 3 for i in range(min(min(t[1], t[0]), t[2]))]\\nfor j in range(3):\\n    while k < min(min(t[1], t[0]), t[2]):\\n        if x[i2] == (j + 1):\\n            z[k][j] = i2\\n            k += 1\\n        i2 += 1\\n    i2 = 0\\n    k = 0\\nfor i in range(min(min(t[1], t[0]), t[2])):\\n    print(z[i][0] + 1, z[i][1] + 1, z[i][2] + 1)\", \"__author__ = 'Rakshak.R.Hegde'\\nn = int(input())\\nt = list(map(int, input().split()))\\nnoOfTeams = min(t.count(1), t.count(2), t.count(3))\\nfor i, strength in enumerate(t):\\n    t[i]=(i, strength)\\nans = ''\\nfor i in range(noOfTeams):\\n    team = []\\n    kind = 1\\n    while kind <= 3:\\n        for index, val in enumerate(t):\\n            if val[1] == kind:\\n                team.append(val[0])\\n                del t[index]\\n                kind += 1\\n                break\\n    for index in team:\\n        ans += str(index + 1) + ' '\\n    ans += '\\\\n'\\nprint(noOfTeams)\\nprint(ans)\", \"i2 = input().split()\\ni1 = input().split()\\ni=0\\n#while i<len(i1):\\n #   i1[i]=int(i1[i])\\n  #  i=i+1\\naa=i1.count('1')\\nb=i1.count('2')\\nc=i1.count('3')\\ng=min(aa,b,c)\\nprint (g)\\nt=0\\nwhile t<g:\\n    r=i1.index('1')\\n    i1[r]=5\\n    r2=i1.index('2')\\n    i1[r2]=5\\n    r3=i1.index('3')\\n    \\n    i1[r3]=5\\n    print (r+1,r2+1,r3+1)\\n    t=t+1\", \"n = int(input())\\nt = list(map(int, input().split()))\\na = [[] for i in range(3)]\\nfor i, m in enumerate(t):\\n    a[m-1].append(i+1)\\nw = min(list(map(len, a)))\\nprint(w)\\nfor i in range(w):\\n    print(a[0][i], a[1][i], a[2][i])\\n\", \"n=int(input())\\nar=list(map(int,input().split()))\\nk=min(ar.count(1),ar.count(2))\\nk=min(k,ar.count(3))\\nif k==0:\\n    print('0')\\n    return\\nz=[]\\nq=0\\nfor x in range(n):\\n    if ar[x]==1:\\n        z.append([x+1])\\n        q+=1\\n    if q==k:\\n        break\\nq=0\\nfor x in range(n):\\n    if ar[x]==2:\\n        z[q].append(x+1)\\n        q+=1\\n    if q==k:\\n        break\\nq=0\\nfor x in range(n):\\n    if ar[x]==3:\\n        z[q].append(x+1)\\n        q+=1\\n    if q==k:\\n        break\\nprint(k)\\nfor x in z:\\n    print(' '.join(map(str,x)))\\n\", \"a = int(input())\\nstudsx = list(map(int, input().split(' ')))\\nstuds = [(studsx[x], x + 1) for x in range(a)]\\ni = [x for x in studs if x[0] == 1]\\nj = [y for y in studs if y[0] == 2]\\nk = [z for z in studs if z[0] == 3]\\npairs = min(len(i), len(j), len(k))\\nprint(pairs)\\nfor l in range(pairs):\\n    print(str(i[l][1]) + ' ' + str(j[l][1]) + ' ' + str(k[l][1]))\\n\", \"n = input();\\nt = input().split()\\ni1 = []\\ni2 = []\\ni3 = []\\nfor i in range(len(t)):\\n   if t[i]==\\\"1\\\":\\n      i1.append(i)\\n   if t[i]==\\\"2\\\":\\n      i2.append(i)\\n   if t[i]==\\\"3\\\":\\n      i3.append(i)\\nnum = min(len(i1),len(i2),len(i3))\\nprint(num)\\nfor i in range(num):\\n   print(str(i1[i]+1)+\\\" \\\"+str(i2[i]+1)+\\\" \\\"+str(i3[i]+1))\\n\"]",
        "difficulty": "interview",
        "input": "138\n2 3 2 2 2 2 2 2 2 2 1 2 1 2 2 2 1 2 1 2 2 1 2 2 2 2 2 2 2 2 2 2 2 1 2 3 2 2 2 1 2 3 2 2 2 3 1 3 2 3 2 3 2 2 2 2 3 2 2 2 2 2 1 2 2 3 2 2 3 2 1 2 2 2 2 2 3 1 2 2 2 2 2 3 2 2 3 2 2 2 2 2 1 1 2 3 2 2 2 2 3 2 2 2 2 2 1 2 1 2 2 2 2 2 1 2 3 2 3 2 2 2 1 2 2 2 1 2 2 2 2 1 2 2 2 2 1 3\n",
        "output": "18\n13 91 84\n34 90 48\n11 39 77\n78 129 50\n137 68 119\n132 122 138\n19 12 96\n40 7 2\n22 88 69\n107 73 46\n115 15 52\n127 106 87\n93 92 66\n71 112 117\n63 124 42\n17 70 101\n109 121 57\n123 25 36\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/490/A"
    },
    {
        "id": 1790,
        "task_id": 1552,
        "test_case_id": 13,
        "question": "The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value t_{i}:  t_{i} = 1, if the i-th child is good at programming,  t_{i} = 2, if the i-th child is good at maths,  t_{i} = 3, if the i-th child is good at PE \n\nEach child happens to be good at exactly one of these three subjects.\n\nThe Team Scientific Decathlon Olympias requires teams of three students. The school teachers decided that the teams will be composed of three children that are good at different subjects. That is, each team must have one mathematician, one programmer and one sportsman. Of course, each child can be a member of no more than one team.\n\nWhat is the maximum number of teams that the school will be able to present at the Olympiad? How should the teams be formed for that?\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t_1, t_2, ..., t_{n} (1 ≤ t_{i} ≤ 3), where t_{i} describes the skill of the i-th child.\n\n\n-----Output-----\n\nIn the first line output integer w — the largest possible number of teams. \n\nThen print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in the order of their appearance in the input. Each child must participate in no more than one team. If there are several solutions, print any of them.\n\nIf no teams can be compiled, print the only line with value w equal to 0.\n\n\n-----Examples-----\nInput\n7\n1 3 1 3 2 1 2\n\nOutput\n2\n3 5 2\n6 7 4\n\nInput\n4\n2 1 1 2\n\nOutput\n0",
        "solutions": "[\"n = int(input())\\nm = list(map(int, input().split()))\\na = []\\nb = []\\nc = []\\nfor i in range(n):\\n    if m[i] == 1:\\n        a.append(i + 1)\\n    if m[i] == 2:\\n        b.append(i + 1)\\n    if m[i] == 3:\\n        c.append(i + 1)\\nans = min(len(a), len(b), len(c))\\nprint(ans)\\nfor i in range(ans):\\n    print(a[i], b[i], c[i])\", \"n = int(input())\\na = list(map(int, input().split()))\\nk1 = []\\nk2 = []\\nk3 = []\\n\\nfor i in range(n):\\n    if a[i] == 1:\\n        k1.append(i + 1)\\n    elif a[i] == 2:\\n        k2.append(i + 1)\\n    else:\\n        k3.append(i + 1)\\nk = min(len(k1), len(k2), len(k3))\\nprint(k)\\nfor i in range(k):\\n    print(k1[i], k2[i], k3[i])\\n\", \"t = [[], [], []]\\nn = int(input())\\na = list(map(int, input().split()))\\nfor i in range(n):\\n    t[a[i] - 1].append(i + 1)\\nm = 1e9\\nfor i in t:\\n    m = min(len(i), m)\\nprint(m)\\nfor i in range(m):\\n    print(t[0][i], t[1][i], t[2][i])\\n\", \"n = int(input())\\nar = list(map(int, input().split()))\\na1 = []\\na2 = []\\na3 = []\\nfor i in range(len(ar)):\\n    if ar[i] == 1:\\n        a1.append(i + 1)\\n    if ar[i] == 2:\\n        a2.append(i + 1)\\n    if ar[i] == 3:\\n        a3.append(i + 1)\\nprint(min(len(a1), len(a2), len(a3)))\\nfor i in range(min(len(a1), len(a2), len(a3))):\\n    print(a1[i], a2[i], a3[i])\\n\", \"n = int(input())\\nt = list(map(int, input().split()))\\na = []\\nb = []\\nc = []\\nfor i, m in enumerate(t):\\n    if m == 1:\\n        a.append(i+1)\\n    elif m == 2:\\n        b.append(i+1)\\n    else:\\n        c.append(i+1)\\nw = min([len(a), len(b), len(c)])\\nprint(w)\\nfor i in range(w):\\n    print(a[i], b[i], c[i])\\n\", \"n=int(input())\\nt=list(map(int,input().split()))\\nC=[t.count(i) for i in range(1,4)]\\nprint(min(C))\\na=b=c=0\\nfor _ in range(0, min(C)):\\n  while t[a] != 1: a += 1\\n  while t[b] != 2: b += 1\\n  while t[c] != 3: c += 1\\n  a += 1\\n  b += 1\\n  c += 1\\n  print(a, b, c)\\n  \\n\", \"n = int(input())\\nstudents = [[], [], []]\\nfor i, j in enumerate(map(int, input().split())):\\n    students[j - 1].append(i + 1)\\nans = min(len(students[i]) for i in range(3))\\nprint(ans)\\nif ans:\\n    for i in range(ans):\\n        print(*[students[j][i] for j in range(3)])\\n\", \"n=int(input())\\n\\na=[10**9,0,0,0]\\n\\nL=list(map(int,input().split()))\\nT=[]\\nfor i in range(n):\\n    if(L[i]==1):\\n        T.append([i+1])\\nind=0\\nfor i in range(n):\\n    if(L[i]==2 and ind<len(T)):\\n        T[ind].append(i+1)\\n        ind+=1\\nind = 0\\nfor i in range(n):\\n    if(L[i]==3 and ind<len(T) and len(T[ind])==2):\\n        T[ind].append(i+1)\\n        ind+=1\\nprint(ind)\\nfor i in range(ind):\\n    item=T[i]\\n    print(item[0],item[1],item[2])\\n    \\n\", \"n = int(input())\\nsubject = list(map(int, input().split()))\\npupils = [[], [], []]\\nfor i in range(n):\\n    pupils[subject[i] - 1].append(i + 1)\\nprint(min(len(pupils[0]), len(pupils[1]), len(pupils[2])))\\nfor i in range(min(len(pupils[0]), len(pupils[1]), len(pupils[2]))):\\n    print(pupils[0][i], pupils[1][i], pupils[2][i])\", \"n = int(input())\\nt = [int(s) for s in input().split()]\\n\\nteams = [[0,0,0] for i in range(n)]\\nn1,n2,n3=0,0,0\\nfor i in range(n):\\n    if t[i]==1:\\n        teams[n1][0]=i+1\\n        n1 += 1\\n    elif t[i]==2:\\n        teams[n2][1]=i+1\\n        n2+= 1        \\n    else:\\n        teams[n3][2]=i+1\\n        n3+= 1\\nw = min(n1,n2,n3)\\nprint(w)\\nif w>0:\\n    for k in range(w):\\n        print(' '.join(map(str,teams[k])))\\n        \\n        \\n\\n\", \"n = int(input())\\nt = [int(x) for x in input().split()]\\ncount = min(t.count(1), t.count(2), t.count(3))\\nprint(count)\\na = b = c = 0\\nfor i in range(count):\\n    while t[a] != 1:\\n        a += 1\\n    while t[b] != 2:\\n        b += 1\\n    while t[c] != 3:\\n        c += 1\\n    print(a + 1, b + 1, c + 1)\\n    a += 1\\n    b += 1\\n    c += 1\\n\", \"n = int(input())\\na = []\\na = list(map(int, input().split()))\\nt = [0, 0, 0, 0]\\nans = [[], [], [], []]\\nk = 1\\nfor i in a:\\n    t[i] += 1\\n    ans[i].append(k)\\n    k += 1\\nsize = min(min(t[3], t[1]), t[2]);\\nprint(size)\\nfor i in range(size):\\n    print(ans[3][i], ans[1][i], ans[2][i])\\n\", \"n = int(input())\\nstudents = list(map(int, input().split()))\\n\\nsubjects = [list() for i in range(3)]\\n\\nfor i in range(len(students)):\\n    subjects[students[i] - 1].append(i + 1)\\n\\nif not all(subjects):\\n    print(0)\\nelse:\\n    print(min(len(s) for s in subjects))\\n    for i in range(min(len(s) for s in subjects)):\\n        for j in range(3):\\n            print(subjects[j][i], end=' ')\\n        print()\\n\", \"n = int(input())\\nA = [[] for i in range(3)]\\nX = list(map(int, input().split()))\\nfor i in range(n):\\n\\tA[X[i] - 1].append(i + 1)\\nMin = min(len(A[0]), len(A[1]), len(A[2]))\\nprint(Min)\\nfor i in range(Min):\\n\\tprint(A[0][i], A[1][i], A[2][i])\\n\", \"n = int(input())\\nb = [[] for i in range(3)]\\na = [int(x) for x in input().split(' ')]\\nfor i in range(n):\\n    b[a[i] - 1].append(i + 1)\\nm = min(len(b[0]), len(b[1]), len(b[2]))\\nprint(m)\\nfor i in range(m):\\n    print(b[0][i], b[1][i], b[2][i], sep=' ')\", \"n=int(input())\\nlis=input().split()\\nfor i in range(n):\\n    lis[i]=int(lis[i])\\ncount=[0,0,0]\\nlis1=[]\\nlis2=[]\\nlis3=[]\\nfor i in range(n):\\n    if lis[i]==1:\\n        count[0]+=1\\n        lis1.append(i)\\n    if lis[i]==2:\\n        count[1]+=1\\n        lis2.append(i)\\n    if lis[i]==3:\\n        count[2]+=1\\n        lis3.append(i)\\nif min(count)==0:\\n    print(0)\\nelse:\\n    print(min(count))\\n    for i in range(min(count)):\\n        print(lis1[i]+1,lis2[i]+1,lis3[i]+1)\\n\", \"n = int(input())\\nt = [int(x) for x in input().split()]\\ncnt = [[0], [0], [0], [0]]\\nfor i in range(n):\\n    if t[i] == 1:\\n        cnt[1][0] += 1\\n        cnt[1].append(i + 1)\\n    elif t[i] == 2:\\n        cnt[2][0] += 1\\n        cnt[2].append(i + 1)\\n    elif t[i] == 3:\\n        cnt[3][0] += 1\\n        cnt[3].append(i + 1)\\nm = 1000000000000\\nfor i in range(1, len(cnt)):\\n    m = min(cnt[i][0], m)\\nprint(m)\\nfor j in range(1, m + 1):\\n    for i in range(1, len(cnt)):    \\n        print(cnt[i][j], end=' ')\\n    print()\", \"n = int(input())\\nti2 = list(map(str,input().split()))\\nti = \\\"\\\".join(ti2)\\nmis = 0\\nk = 0\\nki = [[0] * 3 for i in range(n//3)]\\n\\nwhile mis == 0:\\n    p = ti.find(\\\"1\\\")\\n    m = ti.find(\\\"2\\\")\\n    f = ti.find(\\\"3\\\")\\n    if p!=-1 and m!=-1 and f!=-1:\\n        ti2[p] = \\\"4\\\"\\n        ti2[m] = \\\"4\\\"\\n        ti2[f] = \\\"4\\\"\\n        ti = \\\"\\\".join(ti2)\\n        ki[k][0]=p+1\\n        ki[k][1]=m+1\\n        ki[k][2]=f+1\\n        k+=1\\n    else:\\n        mis=1\\nprint(k)\\nfor y in range(k):\\n    for x in range(3):\\n        print(ki[y][x],end=\\\" \\\")\\n    print()\\n\", \"n = int(input())\\nx = [int(i) for i in input().split()]\\nt = [0] * 3\\nk = 0\\nfor i in range(n):\\n    for j in range(3):\\n        if x[i] == (j + 1):\\n            t[j] += 1\\nprint(min(min(t[1], t[0]), t[2]))\\ni2 = 0\\nj = 0\\nz = [[0] * 3 for i in range(min(min(t[1], t[0]), t[2]))]\\nfor j in range(3):\\n    while k < min(min(t[1], t[0]), t[2]):\\n        if x[i2] == (j + 1):\\n            z[k][j] = i2\\n            k += 1\\n        i2 += 1\\n    i2 = 0\\n    k = 0\\nfor i in range(min(min(t[1], t[0]), t[2])):\\n    print(z[i][0] + 1, z[i][1] + 1, z[i][2] + 1)\", \"__author__ = 'Rakshak.R.Hegde'\\nn = int(input())\\nt = list(map(int, input().split()))\\nnoOfTeams = min(t.count(1), t.count(2), t.count(3))\\nfor i, strength in enumerate(t):\\n    t[i]=(i, strength)\\nans = ''\\nfor i in range(noOfTeams):\\n    team = []\\n    kind = 1\\n    while kind <= 3:\\n        for index, val in enumerate(t):\\n            if val[1] == kind:\\n                team.append(val[0])\\n                del t[index]\\n                kind += 1\\n                break\\n    for index in team:\\n        ans += str(index + 1) + ' '\\n    ans += '\\\\n'\\nprint(noOfTeams)\\nprint(ans)\", \"i2 = input().split()\\ni1 = input().split()\\ni=0\\n#while i<len(i1):\\n #   i1[i]=int(i1[i])\\n  #  i=i+1\\naa=i1.count('1')\\nb=i1.count('2')\\nc=i1.count('3')\\ng=min(aa,b,c)\\nprint (g)\\nt=0\\nwhile t<g:\\n    r=i1.index('1')\\n    i1[r]=5\\n    r2=i1.index('2')\\n    i1[r2]=5\\n    r3=i1.index('3')\\n    \\n    i1[r3]=5\\n    print (r+1,r2+1,r3+1)\\n    t=t+1\", \"n = int(input())\\nt = list(map(int, input().split()))\\na = [[] for i in range(3)]\\nfor i, m in enumerate(t):\\n    a[m-1].append(i+1)\\nw = min(list(map(len, a)))\\nprint(w)\\nfor i in range(w):\\n    print(a[0][i], a[1][i], a[2][i])\\n\", \"n=int(input())\\nar=list(map(int,input().split()))\\nk=min(ar.count(1),ar.count(2))\\nk=min(k,ar.count(3))\\nif k==0:\\n    print('0')\\n    return\\nz=[]\\nq=0\\nfor x in range(n):\\n    if ar[x]==1:\\n        z.append([x+1])\\n        q+=1\\n    if q==k:\\n        break\\nq=0\\nfor x in range(n):\\n    if ar[x]==2:\\n        z[q].append(x+1)\\n        q+=1\\n    if q==k:\\n        break\\nq=0\\nfor x in range(n):\\n    if ar[x]==3:\\n        z[q].append(x+1)\\n        q+=1\\n    if q==k:\\n        break\\nprint(k)\\nfor x in z:\\n    print(' '.join(map(str,x)))\\n\", \"a = int(input())\\nstudsx = list(map(int, input().split(' ')))\\nstuds = [(studsx[x], x + 1) for x in range(a)]\\ni = [x for x in studs if x[0] == 1]\\nj = [y for y in studs if y[0] == 2]\\nk = [z for z in studs if z[0] == 3]\\npairs = min(len(i), len(j), len(k))\\nprint(pairs)\\nfor l in range(pairs):\\n    print(str(i[l][1]) + ' ' + str(j[l][1]) + ' ' + str(k[l][1]))\\n\", \"n = input();\\nt = input().split()\\ni1 = []\\ni2 = []\\ni3 = []\\nfor i in range(len(t)):\\n   if t[i]==\\\"1\\\":\\n      i1.append(i)\\n   if t[i]==\\\"2\\\":\\n      i2.append(i)\\n   if t[i]==\\\"3\\\":\\n      i3.append(i)\\nnum = min(len(i1),len(i2),len(i3))\\nprint(num)\\nfor i in range(num):\\n   print(str(i1[i]+1)+\\\" \\\"+str(i2[i]+1)+\\\" \\\"+str(i3[i]+1))\\n\"]",
        "difficulty": "interview",
        "input": "220\n1 1 3 1 3 1 1 3 1 3 3 3 3 1 3 3 1 3 3 3 3 3 1 1 1 3 1 1 1 3 2 3 3 3 1 1 3 3 1 1 3 3 3 3 1 3 3 1 1 1 2 3 1 1 1 2 3 3 3 2 3 1 1 3 1 1 1 3 2 1 3 2 3 1 1 3 3 3 1 3 1 1 1 3 3 2 1 3 2 1 1 3 3 1 1 1 2 1 1 3 2 1 2 1 1 1 3 1 3 3 1 2 3 3 3 3 1 3 1 1 1 1 2 3 1 1 1 1 1 1 3 2 3 1 3 1 3 1 1 3 1 3 1 3 1 3 1 3 3 2 3 1 3 3 1 3 3 3 3 1 1 3 3 3 3 1 1 3 3 3 2 1 1 1 3 3 1 3 3 3 1 1 1 3 1 3 3 1 1 1 2 3 1 1 3 1 1 1 1 2 3 1 1 2 3 3 1 3 1 3 3 3 3 1 3 2 3 1 1 3\n",
        "output": "20\n198 89 20\n141 56 131\n166 204 19\n160 132 142\n111 112 195\n45 216 92\n6 31 109\n14 150 170\n199 60 18\n173 123 140\n134 69 156\n82 191 85\n126 200 80\n24 97 46\n62 86 149\n214 101 26\n79 171 78\n125 72 118\n172 103 162\n219 51 64\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/490/A"
    },
    {
        "id": 1791,
        "task_id": 1552,
        "test_case_id": 15,
        "question": "The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value t_{i}:  t_{i} = 1, if the i-th child is good at programming,  t_{i} = 2, if the i-th child is good at maths,  t_{i} = 3, if the i-th child is good at PE \n\nEach child happens to be good at exactly one of these three subjects.\n\nThe Team Scientific Decathlon Olympias requires teams of three students. The school teachers decided that the teams will be composed of three children that are good at different subjects. That is, each team must have one mathematician, one programmer and one sportsman. Of course, each child can be a member of no more than one team.\n\nWhat is the maximum number of teams that the school will be able to present at the Olympiad? How should the teams be formed for that?\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t_1, t_2, ..., t_{n} (1 ≤ t_{i} ≤ 3), where t_{i} describes the skill of the i-th child.\n\n\n-----Output-----\n\nIn the first line output integer w — the largest possible number of teams. \n\nThen print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in the order of their appearance in the input. Each child must participate in no more than one team. If there are several solutions, print any of them.\n\nIf no teams can be compiled, print the only line with value w equal to 0.\n\n\n-----Examples-----\nInput\n7\n1 3 1 3 2 1 2\n\nOutput\n2\n3 5 2\n6 7 4\n\nInput\n4\n2 1 1 2\n\nOutput\n0",
        "solutions": "[\"n = int(input())\\nm = list(map(int, input().split()))\\na = []\\nb = []\\nc = []\\nfor i in range(n):\\n    if m[i] == 1:\\n        a.append(i + 1)\\n    if m[i] == 2:\\n        b.append(i + 1)\\n    if m[i] == 3:\\n        c.append(i + 1)\\nans = min(len(a), len(b), len(c))\\nprint(ans)\\nfor i in range(ans):\\n    print(a[i], b[i], c[i])\", \"n = int(input())\\na = list(map(int, input().split()))\\nk1 = []\\nk2 = []\\nk3 = []\\n\\nfor i in range(n):\\n    if a[i] == 1:\\n        k1.append(i + 1)\\n    elif a[i] == 2:\\n        k2.append(i + 1)\\n    else:\\n        k3.append(i + 1)\\nk = min(len(k1), len(k2), len(k3))\\nprint(k)\\nfor i in range(k):\\n    print(k1[i], k2[i], k3[i])\\n\", \"t = [[], [], []]\\nn = int(input())\\na = list(map(int, input().split()))\\nfor i in range(n):\\n    t[a[i] - 1].append(i + 1)\\nm = 1e9\\nfor i in t:\\n    m = min(len(i), m)\\nprint(m)\\nfor i in range(m):\\n    print(t[0][i], t[1][i], t[2][i])\\n\", \"n = int(input())\\nar = list(map(int, input().split()))\\na1 = []\\na2 = []\\na3 = []\\nfor i in range(len(ar)):\\n    if ar[i] == 1:\\n        a1.append(i + 1)\\n    if ar[i] == 2:\\n        a2.append(i + 1)\\n    if ar[i] == 3:\\n        a3.append(i + 1)\\nprint(min(len(a1), len(a2), len(a3)))\\nfor i in range(min(len(a1), len(a2), len(a3))):\\n    print(a1[i], a2[i], a3[i])\\n\", \"n = int(input())\\nt = list(map(int, input().split()))\\na = []\\nb = []\\nc = []\\nfor i, m in enumerate(t):\\n    if m == 1:\\n        a.append(i+1)\\n    elif m == 2:\\n        b.append(i+1)\\n    else:\\n        c.append(i+1)\\nw = min([len(a), len(b), len(c)])\\nprint(w)\\nfor i in range(w):\\n    print(a[i], b[i], c[i])\\n\", \"n=int(input())\\nt=list(map(int,input().split()))\\nC=[t.count(i) for i in range(1,4)]\\nprint(min(C))\\na=b=c=0\\nfor _ in range(0, min(C)):\\n  while t[a] != 1: a += 1\\n  while t[b] != 2: b += 1\\n  while t[c] != 3: c += 1\\n  a += 1\\n  b += 1\\n  c += 1\\n  print(a, b, c)\\n  \\n\", \"n = int(input())\\nstudents = [[], [], []]\\nfor i, j in enumerate(map(int, input().split())):\\n    students[j - 1].append(i + 1)\\nans = min(len(students[i]) for i in range(3))\\nprint(ans)\\nif ans:\\n    for i in range(ans):\\n        print(*[students[j][i] for j in range(3)])\\n\", \"n=int(input())\\n\\na=[10**9,0,0,0]\\n\\nL=list(map(int,input().split()))\\nT=[]\\nfor i in range(n):\\n    if(L[i]==1):\\n        T.append([i+1])\\nind=0\\nfor i in range(n):\\n    if(L[i]==2 and ind<len(T)):\\n        T[ind].append(i+1)\\n        ind+=1\\nind = 0\\nfor i in range(n):\\n    if(L[i]==3 and ind<len(T) and len(T[ind])==2):\\n        T[ind].append(i+1)\\n        ind+=1\\nprint(ind)\\nfor i in range(ind):\\n    item=T[i]\\n    print(item[0],item[1],item[2])\\n    \\n\", \"n = int(input())\\nsubject = list(map(int, input().split()))\\npupils = [[], [], []]\\nfor i in range(n):\\n    pupils[subject[i] - 1].append(i + 1)\\nprint(min(len(pupils[0]), len(pupils[1]), len(pupils[2])))\\nfor i in range(min(len(pupils[0]), len(pupils[1]), len(pupils[2]))):\\n    print(pupils[0][i], pupils[1][i], pupils[2][i])\", \"n = int(input())\\nt = [int(s) for s in input().split()]\\n\\nteams = [[0,0,0] for i in range(n)]\\nn1,n2,n3=0,0,0\\nfor i in range(n):\\n    if t[i]==1:\\n        teams[n1][0]=i+1\\n        n1 += 1\\n    elif t[i]==2:\\n        teams[n2][1]=i+1\\n        n2+= 1        \\n    else:\\n        teams[n3][2]=i+1\\n        n3+= 1\\nw = min(n1,n2,n3)\\nprint(w)\\nif w>0:\\n    for k in range(w):\\n        print(' '.join(map(str,teams[k])))\\n        \\n        \\n\\n\", \"n = int(input())\\nt = [int(x) for x in input().split()]\\ncount = min(t.count(1), t.count(2), t.count(3))\\nprint(count)\\na = b = c = 0\\nfor i in range(count):\\n    while t[a] != 1:\\n        a += 1\\n    while t[b] != 2:\\n        b += 1\\n    while t[c] != 3:\\n        c += 1\\n    print(a + 1, b + 1, c + 1)\\n    a += 1\\n    b += 1\\n    c += 1\\n\", \"n = int(input())\\na = []\\na = list(map(int, input().split()))\\nt = [0, 0, 0, 0]\\nans = [[], [], [], []]\\nk = 1\\nfor i in a:\\n    t[i] += 1\\n    ans[i].append(k)\\n    k += 1\\nsize = min(min(t[3], t[1]), t[2]);\\nprint(size)\\nfor i in range(size):\\n    print(ans[3][i], ans[1][i], ans[2][i])\\n\", \"n = int(input())\\nstudents = list(map(int, input().split()))\\n\\nsubjects = [list() for i in range(3)]\\n\\nfor i in range(len(students)):\\n    subjects[students[i] - 1].append(i + 1)\\n\\nif not all(subjects):\\n    print(0)\\nelse:\\n    print(min(len(s) for s in subjects))\\n    for i in range(min(len(s) for s in subjects)):\\n        for j in range(3):\\n            print(subjects[j][i], end=' ')\\n        print()\\n\", \"n = int(input())\\nA = [[] for i in range(3)]\\nX = list(map(int, input().split()))\\nfor i in range(n):\\n\\tA[X[i] - 1].append(i + 1)\\nMin = min(len(A[0]), len(A[1]), len(A[2]))\\nprint(Min)\\nfor i in range(Min):\\n\\tprint(A[0][i], A[1][i], A[2][i])\\n\", \"n = int(input())\\nb = [[] for i in range(3)]\\na = [int(x) for x in input().split(' ')]\\nfor i in range(n):\\n    b[a[i] - 1].append(i + 1)\\nm = min(len(b[0]), len(b[1]), len(b[2]))\\nprint(m)\\nfor i in range(m):\\n    print(b[0][i], b[1][i], b[2][i], sep=' ')\", \"n=int(input())\\nlis=input().split()\\nfor i in range(n):\\n    lis[i]=int(lis[i])\\ncount=[0,0,0]\\nlis1=[]\\nlis2=[]\\nlis3=[]\\nfor i in range(n):\\n    if lis[i]==1:\\n        count[0]+=1\\n        lis1.append(i)\\n    if lis[i]==2:\\n        count[1]+=1\\n        lis2.append(i)\\n    if lis[i]==3:\\n        count[2]+=1\\n        lis3.append(i)\\nif min(count)==0:\\n    print(0)\\nelse:\\n    print(min(count))\\n    for i in range(min(count)):\\n        print(lis1[i]+1,lis2[i]+1,lis3[i]+1)\\n\", \"n = int(input())\\nt = [int(x) for x in input().split()]\\ncnt = [[0], [0], [0], [0]]\\nfor i in range(n):\\n    if t[i] == 1:\\n        cnt[1][0] += 1\\n        cnt[1].append(i + 1)\\n    elif t[i] == 2:\\n        cnt[2][0] += 1\\n        cnt[2].append(i + 1)\\n    elif t[i] == 3:\\n        cnt[3][0] += 1\\n        cnt[3].append(i + 1)\\nm = 1000000000000\\nfor i in range(1, len(cnt)):\\n    m = min(cnt[i][0], m)\\nprint(m)\\nfor j in range(1, m + 1):\\n    for i in range(1, len(cnt)):    \\n        print(cnt[i][j], end=' ')\\n    print()\", \"n = int(input())\\nti2 = list(map(str,input().split()))\\nti = \\\"\\\".join(ti2)\\nmis = 0\\nk = 0\\nki = [[0] * 3 for i in range(n//3)]\\n\\nwhile mis == 0:\\n    p = ti.find(\\\"1\\\")\\n    m = ti.find(\\\"2\\\")\\n    f = ti.find(\\\"3\\\")\\n    if p!=-1 and m!=-1 and f!=-1:\\n        ti2[p] = \\\"4\\\"\\n        ti2[m] = \\\"4\\\"\\n        ti2[f] = \\\"4\\\"\\n        ti = \\\"\\\".join(ti2)\\n        ki[k][0]=p+1\\n        ki[k][1]=m+1\\n        ki[k][2]=f+1\\n        k+=1\\n    else:\\n        mis=1\\nprint(k)\\nfor y in range(k):\\n    for x in range(3):\\n        print(ki[y][x],end=\\\" \\\")\\n    print()\\n\", \"n = int(input())\\nx = [int(i) for i in input().split()]\\nt = [0] * 3\\nk = 0\\nfor i in range(n):\\n    for j in range(3):\\n        if x[i] == (j + 1):\\n            t[j] += 1\\nprint(min(min(t[1], t[0]), t[2]))\\ni2 = 0\\nj = 0\\nz = [[0] * 3 for i in range(min(min(t[1], t[0]), t[2]))]\\nfor j in range(3):\\n    while k < min(min(t[1], t[0]), t[2]):\\n        if x[i2] == (j + 1):\\n            z[k][j] = i2\\n            k += 1\\n        i2 += 1\\n    i2 = 0\\n    k = 0\\nfor i in range(min(min(t[1], t[0]), t[2])):\\n    print(z[i][0] + 1, z[i][1] + 1, z[i][2] + 1)\", \"__author__ = 'Rakshak.R.Hegde'\\nn = int(input())\\nt = list(map(int, input().split()))\\nnoOfTeams = min(t.count(1), t.count(2), t.count(3))\\nfor i, strength in enumerate(t):\\n    t[i]=(i, strength)\\nans = ''\\nfor i in range(noOfTeams):\\n    team = []\\n    kind = 1\\n    while kind <= 3:\\n        for index, val in enumerate(t):\\n            if val[1] == kind:\\n                team.append(val[0])\\n                del t[index]\\n                kind += 1\\n                break\\n    for index in team:\\n        ans += str(index + 1) + ' '\\n    ans += '\\\\n'\\nprint(noOfTeams)\\nprint(ans)\", \"i2 = input().split()\\ni1 = input().split()\\ni=0\\n#while i<len(i1):\\n #   i1[i]=int(i1[i])\\n  #  i=i+1\\naa=i1.count('1')\\nb=i1.count('2')\\nc=i1.count('3')\\ng=min(aa,b,c)\\nprint (g)\\nt=0\\nwhile t<g:\\n    r=i1.index('1')\\n    i1[r]=5\\n    r2=i1.index('2')\\n    i1[r2]=5\\n    r3=i1.index('3')\\n    \\n    i1[r3]=5\\n    print (r+1,r2+1,r3+1)\\n    t=t+1\", \"n = int(input())\\nt = list(map(int, input().split()))\\na = [[] for i in range(3)]\\nfor i, m in enumerate(t):\\n    a[m-1].append(i+1)\\nw = min(list(map(len, a)))\\nprint(w)\\nfor i in range(w):\\n    print(a[0][i], a[1][i], a[2][i])\\n\", \"n=int(input())\\nar=list(map(int,input().split()))\\nk=min(ar.count(1),ar.count(2))\\nk=min(k,ar.count(3))\\nif k==0:\\n    print('0')\\n    return\\nz=[]\\nq=0\\nfor x in range(n):\\n    if ar[x]==1:\\n        z.append([x+1])\\n        q+=1\\n    if q==k:\\n        break\\nq=0\\nfor x in range(n):\\n    if ar[x]==2:\\n        z[q].append(x+1)\\n        q+=1\\n    if q==k:\\n        break\\nq=0\\nfor x in range(n):\\n    if ar[x]==3:\\n        z[q].append(x+1)\\n        q+=1\\n    if q==k:\\n        break\\nprint(k)\\nfor x in z:\\n    print(' '.join(map(str,x)))\\n\", \"a = int(input())\\nstudsx = list(map(int, input().split(' ')))\\nstuds = [(studsx[x], x + 1) for x in range(a)]\\ni = [x for x in studs if x[0] == 1]\\nj = [y for y in studs if y[0] == 2]\\nk = [z for z in studs if z[0] == 3]\\npairs = min(len(i), len(j), len(k))\\nprint(pairs)\\nfor l in range(pairs):\\n    print(str(i[l][1]) + ' ' + str(j[l][1]) + ' ' + str(k[l][1]))\\n\", \"n = input();\\nt = input().split()\\ni1 = []\\ni2 = []\\ni3 = []\\nfor i in range(len(t)):\\n   if t[i]==\\\"1\\\":\\n      i1.append(i)\\n   if t[i]==\\\"2\\\":\\n      i2.append(i)\\n   if t[i]==\\\"3\\\":\\n      i3.append(i)\\nnum = min(len(i1),len(i2),len(i3))\\nprint(num)\\nfor i in range(num):\\n   print(str(i1[i]+1)+\\\" \\\"+str(i2[i]+1)+\\\" \\\"+str(i3[i]+1))\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 2 2 3 3\n",
        "output": "1\n1 3 4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/490/A"
    },
    {
        "id": 1792,
        "task_id": 1600,
        "test_case_id": 13,
        "question": "One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles.\n\nAt the end of the day there were n castles built by friends. Castles are numbered from 1 to n, and the height of the i-th castle is equal to h_{i}. When friends were about to leave, Squidward noticed, that castles are not ordered by their height, and this looks ugly. Now friends are going to reorder the castles in a way to obtain that condition h_{i} ≤ h_{i} + 1 holds for all i from 1 to n - 1.\n\nSquidward suggested the following process of sorting castles:   Castles are split into blocks — groups of consecutive castles. Therefore the block from i to j will include castles i, i + 1, ..., j. A block may consist of a single castle.  The partitioning is chosen in such a way that every castle is a part of exactly one block.  Each block is sorted independently from other blocks, that is the sequence h_{i}, h_{i} + 1, ..., h_{j} becomes sorted.  The partitioning should satisfy the condition that after each block is sorted, the sequence h_{i} becomes sorted too. This may always be achieved by saying that the whole sequence is a single block. \n\nEven Patrick understands that increasing the number of blocks in partitioning will ease the sorting process. Now friends ask you to count the maximum possible number of blocks in a partitioning that satisfies all the above requirements.\n\n\n-----Input-----\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of castles Spongebob, Patrick and Squidward made from sand during the day.\n\nThe next line contains n integers h_{i} (1 ≤ h_{i} ≤ 10^9). The i-th of these integers corresponds to the height of the i-th castle.\n\n\n-----Output-----\n\nPrint the maximum possible number of blocks in a valid partitioning.\n\n\n-----Examples-----\nInput\n3\n1 2 3\n\nOutput\n3\n\nInput\n4\n2 1 3 2\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample the partitioning looks like that: [1][2][3].\n\n [Image] \n\nIn the second sample the partitioning is: [2, 1][3, 2]\n\n [Image]",
        "solutions": "[\"#!/usr/bin/env python3\\n\\nfrom collections import Counter\\n\\nn = int(input())\\nh_u = tuple(map(int, input().split()))\\nh_s = sorted(h_u)\\n\\ni = 0\\na = Counter()\\nb = Counter()\\n\\nnum_partitions = 0\\n\\nfor i in range(n):\\n  a[h_u[i]] += 1\\n  b[h_s[i]] += 1\\n\\n  if (a == b):\\n    num_partitions += 1\\n    a = Counter()\\n    b = Counter()\\n\\nprint(num_partitions)\", \"n = int(input())\\na = [int(i) for i in input().split()]\\npref = [0] * (n + 1)\\nfor i in range(n):\\n\\tpref[i + 1] = max(pref[i], a[i])\\nsuff = [0] * n\\nsuff[n - 1] = a[n - 1]\\nfor i in range(n - 2, -1, -1):\\n\\tsuff[i] = min(suff[i + 1], a[i])\\nc = 0\\nfor i in range(n):\\n\\tif pref[i] <= suff[i]:\\n\\t\\tc += 1\\nprint(c)\", \"n = int(input())\\ns = input().split()\\na = [[0] * 2 for i in range(n)]\\n\\nfor i in range(n):\\n    a[i][0] = int(s[i])\\n    a[i][1] = i\\n\\na.sort()\\n\\n\\nif (a[0][1] == n-1 or a[n-1][1] == 0):\\n    print(1)\\nelse:\\n    sum = 0\\n    res = 0\\n    ans = 0\\n    for i in range(n):\\n        sum += a[i][1]\\n        res += i\\n        if sum == res:\\n            ans += 1\\n\\n    print(ans)\\n\", \"n = int(input())\\nhs = list(map(int, input().split()))\\n\\ndef solve(n, hs):\\n    mins = fill_mins(n, hs)\\n    maxs = fill_maxs(n, hs)\\n    count = 1\\n    for i in range(n - 1):\\n        if maxs[i] <= mins[i + 1]:\\n            count += 1\\n    return count    \\n\\ndef fill_mins(n, hs):\\n    mins = []\\n    tmp = float('inf')\\n    for h in hs[::-1]:\\n        if h < tmp:\\n            tmp = h\\n        mins.append(tmp)\\n    mins.reverse()\\n    return mins\\n\\ndef fill_maxs(n, hs):\\n    maxs = []\\n    tmp = 0\\n    for h in hs:\\n        if h > tmp:\\n            tmp = h\\n        maxs.append(tmp)\\n    return maxs\\n\\nprint(solve(n, hs))\", \"def main():    \\n    n = int(input())\\n    a = [int(i) for i in input().split()]\\n    b = sorted(a)\\n    \\n    diff = 0\\n    d = {}\\n    result = 0\\n    maxi = 0\\n    for i in range(n):\\n        if a[i] not in d: d[a[i]] = 0\\n        if b[i] not in d: d[b[i]] = 0\\n        if d[a[i]] == 0: diff += 1\\n        d[a[i]] += 1\\n        if d[a[i]] == 0: diff -= 1\\n        if d[b[i]] == 0: diff += 1\\n        d[b[i]] -= 1\\n        if d[b[i]] == 0: diff -= 1    \\n        if diff == 0: result += 1\\n    \\n    print(result)\\n    \\n\\nmain()\", \"def solve( h , n ):\\n\\n    sortedH = sorted(h)\\n    hsum = [0]\\n    for i in range(1,n+1):\\n        hsum.append( hsum[i-1] + sortedH[i-1] )\\n\\n    tsum = 0\\n    start =0\\n    res = 0\\n    for i,hi in enumerate(h):\\n        tsum += hi\\n        if tsum == hsum[i+1]-hsum[start]:\\n            res += 1\\n            tsum = 0\\n            start = i + 1\\n\\n    return res\\n\\ndef __starting_point():\\n\\n    n = int( input() )\\n    h = [ int(x)-1 for x in input().split() ]\\n\\n    print( solve( h , n ) )\\n__starting_point()\", \"from collections import Counter\\n\\ndef __starting_point():\\n    n = int(input())\\n    data = list(map(int, input().split()))\\n    dd = {}\\n    for i, x in enumerate(sorted(data)):\\n        if x not in dd:\\n            dd[x] = i\\n\\n    m = None\\n    c = 0\\n    n_pos = None\\n\\n    counter = Counter()\\n\\n    for i, x in enumerate(data):\\n        if n_pos is None:\\n            if dd[x] + counter[x] == i:\\n                c += 1\\n            else:\\n                n_pos = dd[x] + counter[x]\\n                m = x\\n        else:\\n            if x >= m:\\n                m = x\\n                n_pos = dd[x] + counter[x]\\n\\n            if i == n_pos:\\n                c += 1\\n                n_pos = None\\n\\n        counter[x] += 1\\n\\n    print(c)\\n\\n__starting_point()\", \"\\\"\\\"\\\"\\nCodeforces Round 332\\n\\nProblem 599 C.\\n\\n@author yamaton\\n@date 2015-11-20\\n\\\"\\\"\\\"\\n\\nimport itertools as it\\nimport functools\\nimport operator\\nimport collections\\nimport math\\nimport sys\\n\\n\\n\\ndef solve(xs, n):\\n    max_upto = []\\n    maxval = 0\\n    for x in xs:\\n        maxval = max(maxval, x)\\n        max_upto.append(maxval)\\n\\n    min_after = []\\n    minval = 10000000000\\n    for x in reversed(xs):\\n        minval = min(minval, x)\\n        min_after.append(minval)\\n    min_after.reverse()\\n\\n    count = 1\\n    for i in range(1, n):\\n        if max_upto[i-1] <= min_after[i]:\\n            count += 1\\n\\n    return count\\n\\n\\n#\\n# @functools.lru_cache(maxsize=None)\\n# def count(tup):\\n#     if len(tup) == 1:\\n#         return 1\\n#\\n#     maxval = 1\\n#     n = len(tup)\\n#     for i in range(1, n):\\n#         first = tup[:i]\\n#         second = tup[i:]\\n#         if max(first) <= min(second):\\n#             maxval = max(maxval, count(first) + count(second))\\n#     return maxval\\n#\\n#\\n# def solve(xs, n):\\n#     return count(tuple(xs))\\n\\n\\n# def p(*args, **kwargs):\\n#     return print(*args, file=sys.stderr, **kwargs)\\n\\n\\ndef main():\\n    n = int(input())\\n    xs = [int(_c) for _c in input().strip().split()]\\n\\n    result = solve(xs, n)\\n    print(result)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"__author__ = 'MoonBall'\\n\\nimport sys\\n# sys.stdin = open('data/C.in', 'r')\\nT = 1\\n\\ndef process():\\n    N = int(input())\\n    h = list(map(int, input().split()))\\n\\n    hpx = []\\n    last = {}\\n    for i, v in enumerate(h): hpx.append([v, i])\\n    hpx = sorted(hpx, key=lambda x:x[0])\\n    maxp = -1\\n    i = 0\\n    while i < N:\\n        item = hpx[i]\\n        v = item[0]\\n        j = i\\n        while j < N and hpx[j][0] == v:\\n            p = hpx[j][1]\\n            last[p] = max(maxp, p)\\n            j = j + 1\\n\\n        j = i\\n        while j < N and hpx[j][0] == v:\\n            p = hpx[j][1]\\n            maxp = max(maxp, p)\\n            j = j + 1\\n        i = j\\n\\n    ans = 0\\n    p = 0\\n    while p < N:\\n        ans = ans + 1\\n        nextp = p + 1\\n\\n        while p < N and p < nextp:\\n            nextp = max(nextp, last[p] + 1)\\n            p = p + 1\\n\\n    print(ans)\\n\\n\\n\\n\\nfor _ in range(T):\\n    process()\\n\", \"n = int(input())\\nh = list(map(int, input().split()))\\nmins = [1000000001 for i in range(n)]\\nmaxs = [0 for i in range(n)]\\nans = 0\\nmins[n-1] = h[n-1]\\n\\nfor i in range(n-2, -1, -1):\\n    mins[i] = min(h[i], mins[i+1])\\nmaxs[0] = h[0]\\nfor i in range(1, n):\\n    maxs[i] = max(maxs[i-1],h[i])\\n\\nfor i in range(n-1):\\n    if maxs[i] <= mins[i+1]:\\n        ans += 1\\nprint(ans+1)\\n    \\n    \\n\", \"n = int(input())\\nhs = list(map(int, input().split()))\\nchs = list(set(hs))\\nchs.sort()\\nrchs = {}\\nfor i, v in enumerate(chs):\\n    rchs[v] = i\\nfor i in range(n):\\n    hs[i] = rchs[hs[i]]\\nmax_h = -1\\nrs = []\\nmax_hs = [0] * n\\nfor i, h in enumerate(hs):\\n    max_h = max(max_h, h)\\n    rs.append((h, i))\\n    max_hs[i] = max_h\\nrs.sort()\\nh, r = 0, -1\\np = 0\\nans = 0\\nwhile r < n - 1:\\n    nh, nr = rs[p]\\n    if r >= nr:\\n        p += 1\\n    else:\\n        r = nr\\n        p += 1\\n        while r < n - 1:\\n            nh, nr = rs[p]\\n            if nh >= max_hs[r]:\\n                break\\n            r = max(r, nr)\\n            p += 1\\n        ans += 1\\nprint(ans)\\n\", \"mod = 10**9+7\\nx = int(input())\\ny = list(map(int, input().split(' ')))\\nz = y[:]\\nz.sort()\\n\\nprod = 1\\nsumx = 0\\n\\nprod2 = 1\\nsumx2 = 0\\n\\nb = 0\\n\\nfor i in range(x):\\n    prod *= y[i]\\n    sumx += y[i]\\n    prod2 *= z[i]\\n    sumx2 += z[i]\\n    prod %= mod\\n    prod2 %= mod\\n    if (prod == prod2 and sumx == sumx2):\\n        b+=1\\n        prod=1\\n        prod2=1\\n        sumx=0\\n        sumx2=0\\n\\nprint(b)\\n\", \"from collections import Counter as Cnt\\nn = int(input())\\ndata = tuple(map(int,input().split()))\\ndatasorted = sorted(data)\\n\\ni = 0\\na = Cnt()\\nb = Cnt()\\nans = 0\\nfor i in range(n):\\n    a[data[i]]+=1\\n    b[datasorted[i]]+=1\\n    if a==b:\\n        ans+=1\\n        a,b=Cnt(),Cnt()\\nprint(ans)\", \"x = int(input())\\ny = list(map(int, input().split(' ')))\\nz = y[:]\\nz.sort()\\n\\nsumx = 0\\nsumx2 = 0\\n\\nb = 0\\n\\nfor i in range(x):\\n    sumx += y[i]\\n    sumx2 += z[i]\\n    if (sumx == sumx2):\\n        b+=1\\n\\n\\nprint(b)\", \"x = int(input())\\ny = list(map(int, input().split(' ')))\\nz = y[:]\\nz.sort()\\nsumx = 0\\nb = 0\\n\\nfor i in range(x):\\n    sumx += y[i] - z[i]\\n    if (sumx == 0):\\n        b+=1\\n\\nprint(b)\", \"n = int(input())\\nhs = list(map(int, input().split()))\\nmax_h = 0\\nrs = []\\nmax_hs = [0] * n\\nfor i, h in enumerate(hs):\\n    rs.append((h, i))\\n    max_h = max(max_h, h)\\n    max_hs[i] = max_h\\nrs.sort()\\np, r = 0, -1\\nans = 0\\nwhile r < n - 1:\\n    nh, nr = rs[p]\\n    if r >= nr:\\n        p += 1\\n    else:\\n        r = nr\\n        p += 1\\n        while r < n - 1:\\n            nh, nr = rs[p]\\n            if nh >= max_hs[r]:\\n                break\\n            r = max(r, nr)\\n            p += 1\\n        ans += 1\\nprint(ans)\\n\", \"\\\"\\\"\\\"\\nCodeforces Round #332\\n\\nProblem 599 C. Day at the Beach\\n\\n@author yamaton\\n@date 2015-11-20\\n\\\"\\\"\\\"\\n\\nimport itertools as it\\nimport functools\\nimport operator\\nimport collections\\nimport math\\nimport sys\\n\\n\\ndef solve(xs, n):\\n    max_upto = list(it.accumulate(xs, max))\\n    min_after = list(it.accumulate(reversed(xs), min))\\n    min_after.reverse()\\n    count = 1 + sum(1 for i in range(1, n) if max_upto[i-1] <= min_after[i])\\n    return count\\n\\n\\ndef solve_old(xs, n):\\n    max_upto = []\\n    maxval = 0\\n    for x in xs:\\n        maxval = max(maxval, x)\\n        max_upto.append(maxval)\\n\\n    min_after = []\\n    minval = 10000000000\\n    for x in reversed(xs):\\n        minval = min(minval, x)\\n        min_after.append(minval)\\n    min_after.reverse()\\n\\n    count = 1\\n    for i in range(1, n):\\n        if max_upto[i-1] <= min_after[i]:\\n            count += 1\\n\\n    return count\\n\\n\\n#\\n# @functools.lru_cache(maxsize=None)\\n# def count(tup):\\n#     if len(tup) == 1:\\n#         return 1\\n#\\n#     maxval = 1\\n#     n = len(tup)\\n#     for i in range(1, n):\\n#         first = tup[:i]\\n#         second = tup[i:]\\n#         if max(first) <= min(second):\\n#             maxval = max(maxval, count(first) + count(second))\\n#     return maxval\\n#\\n#\\n# def solve(xs, n):\\n#     return count(tuple(xs))\\n\\n\\n# def p(*args, **kwargs):\\n#     return print(*args, file=sys.stderr, **kwargs)\\n\\n\\ndef main():\\n    n = int(input())\\n    xs = [int(_c) for _c in input().strip().split()]\\n\\n    result = solve(xs, n)\\n    print(result)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n, s, v = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor ai, bi in zip(a, sorted(a)):\\n    s += bi - ai\\n    v += not s\\nprint(v)\", \"#!/usr/bin/env python3\\n# 599C_beach.py - Codeforces.com/problemset/problem/599/C by Sergey 2015\\n\\nimport unittest\\nimport sys\\n\\n###############################################################################\\n# Beach Class (Main Program)\\n###############################################################################\\n\\n\\nclass Beach:\\n    \\\"\\\"\\\" Beach representation \\\"\\\"\\\"\\n\\n    def __init__(self, test_inputs=None):\\n        \\\"\\\"\\\" Default constructor \\\"\\\"\\\"\\n\\n        it = iter(test_inputs.split(\\\"\\\\n\\\")) if test_inputs else None\\n\\n        def uinput():\\n            return next(it) if it else sys.stdin.readline().rstrip()\\n\\n        # Reading single elements\\n        [self.n] = list(map(int, uinput().split()))\\n\\n        # Reading a single line of multiple elements\\n        self.nums = list(map(int, uinput().split()))\\n\\n    def calculate(self):\\n        \\\"\\\"\\\" Main calcualtion function of the class \\\"\\\"\\\"\\n\\n        result, u = 0, 0\\n\\n        tp = sorted([(n, i) for i, n in enumerate(self.nums)])\\n\\n        for i in range(self.n):\\n            u = max(u, tp[i][1])\\n            if i >= u:\\n                result += 1\\n\\n        return str(result)\\n\\n###############################################################################\\n# Unit Tests\\n###############################################################################\\n\\n\\nclass unitTests(unittest.TestCase):\\n\\n    def test_single_test(self):\\n        \\\"\\\"\\\" Beach class testing \\\"\\\"\\\"\\n\\n        # Constructor test\\n        test = \\\"3\\\\n1 2 3\\\"\\n        d = Beach(test)\\n        self.assertEqual(d.n, 3)\\n        self.assertEqual(d.nums, [1, 2, 3])\\n\\n        # Sample test\\n        self.assertEqual(Beach(test).calculate(), \\\"3\\\")\\n\\n        # Sample test\\n        test = \\\"4\\\\n2 1 3 2\\\"\\n        self.assertEqual(Beach(test).calculate(), \\\"2\\\")\\n\\n        # My tests\\n        test = \\\"\\\"\\n        # self.assertEqual(Beach(test).calculate(), \\\"0\\\")\\n\\n        # Time limit test\\n        # self.time_limit_test(5000)\\n\\n    def time_limit_test(self, nmax):\\n        \\\"\\\"\\\" Timelimit testing \\\"\\\"\\\"\\n        import random\\n        import timeit\\n\\n        # Random inputs\\n        test = str(nmax) + \\\" \\\" + str(nmax) + \\\"\\\\n\\\"\\n        numnums = [str(i) + \\\" \\\" + str(i+1) for i in range(nmax)]\\n        test += \\\"\\\\n\\\".join(numnums) + \\\"\\\\n\\\"\\n        nums = [random.randint(1, 10000) for i in range(nmax)]\\n        test += \\\" \\\".join(map(str, nums)) + \\\"\\\\n\\\"\\n\\n        # Run the test\\n        start = timeit.default_timer()\\n        d = Beach(test)\\n        calc = timeit.default_timer()\\n        d.calculate()\\n        stop = timeit.default_timer()\\n        print((\\\"\\\\nTimelimit Test: \\\" +\\n              \\\"{0:.3f}s (init {1:.3f}s calc {2:.3f}s)\\\".\\n              format(stop-start, calc-start, stop-calc)))\\n\\ndef __starting_point():\\n\\n    # Avoiding recursion limitaions\\n    sys.setrecursionlimit(100000)\\n\\n    if sys.argv[-1] == \\\"-ut\\\":\\n        unittest.main(argv=[\\\" \\\"])\\n\\n    # Print the result string\\n    sys.stdout.write(Beach().calculate())\\n\\n__starting_point()\", \"n, s, v = int(input()), 0, 0\\na = list(map(int, input().split()))\\nfor ai, bi in zip(a, sorted(a)):\\n    s += bi - ai\\n    v += not s\\nprint(v)\", \"def binsearch(a, x, k):\\n    l = 0\\n    r = k\\n    while l < r - 1:\\n        m = (l + r) // 2\\n        if a[m] <= x:\\n            l = m\\n        else:\\n            r = m\\n    return l\\nn = int(input())\\nk = -1\\na = [0] * n\\nfor i in input().split():\\n    x = int(i)\\n    if k == -1:\\n        k += 1\\n        a[k] = x\\n    else:\\n        if x >= a[k]:\\n            k += 1\\n            a[k] = x\\n        else:\\n            k1 = k\\n            k = binsearch(a, x, k + 1)\\n            if a[k] <= x:\\n                k += 1\\n            a[k] = a[k1]\\nprint(k + 1)\", \"__author__ = 'sandeepmellacheruvu'\\nn = int(input())\\narr = list(map(int, input().split()))\\nsum = 0\\nblocks = 0\\nfor ai, bi in zip(arr, sorted(arr)):\\n    sum += ai - bi\\n    if sum == 0:\\n        blocks += 1\\nprint(blocks)\", \"# import sys\\n# sys.stdin = open('cf599c.in')\\n\\nn = int(input())\\nhh = list(map(int, input().split()))\\nidx = sorted(range(n), key=lambda i: hh[i])\\n\\nnum_blocks = 0\\ncurr_max = idx[0]\\nfor j, i in enumerate(idx):\\n\\tcurr_max = max(i, curr_max)\\n\\tif curr_max <= j:\\n\\t\\tnum_blocks += 1\\n\\nprint(num_blocks)\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\nfrom collections import Counter\\n\\nn = int(input())\\nH = list(map(int,input().split()))\\n_H = sorted(H)\\n\\ndiff = Counter()\\ncount = 0\\n\\nfor i in range(n):\\n    diff[H[i]] += 1\\n    diff[_H[i]] -= 1\\n\\n    if _H[i] in diff and diff[_H[i]] == 0:\\n        diff.pop(_H[i])\\n    if H[i] in diff and diff[H[i]] == 0:\\n        diff.pop(H[i])\\n    if diff == Counter():\\n        count += 1\\n\\nprint(count)\\n\", \"n = int(input())\\nhs = tuple(int(x) for x in input().split())\\n\\ndef blocks(seq):\\n    res = 0\\n    i = 0 \\n    maxh = 0\\n    while True:\\n        if i == len(seq):\\n            return res\\n        maxh = max(maxh, seq[i])\\n        if maxh == i:\\n            res += 1\\n            i += 1 \\n        elif maxh > i:\\n            i += 1\\n            \\ndef solve(n, hs):\\n    hhs = sorted((hs[i], i) for i in range(n))\\n    hhhs = sorted((i, hhs[i][0], hhs[i][1]) for i in range(n))\\n    return blocks(list(h[2] for h in hhhs)) \\n    \\nprint(solve(n, hs))\\n\"]",
        "difficulty": "interview",
        "input": "20\n1 2 2 2 5 6 6 6 7 7 8 9 15 15 16 16 17 18 19 19\n",
        "output": "20\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/599/C"
    },
    {
        "id": 1793,
        "task_id": 1638,
        "test_case_id": 1,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 2 3 2 1\n",
        "output": "1 2 3 2 1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1794,
        "task_id": 1638,
        "test_case_id": 2,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "3\n10 6 8\n",
        "output": "10 6 6 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1795,
        "task_id": 1638,
        "test_case_id": 3,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "7\n1 2 1 2 1 2 1\n",
        "output": "1 2 1 1 1 1 1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1796,
        "task_id": 1638,
        "test_case_id": 4,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "7\n1 2 1 2 1 3 1\n",
        "output": "1 1 1 1 1 3 1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1797,
        "task_id": 1638,
        "test_case_id": 5,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "1\n1\n",
        "output": "1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1798,
        "task_id": 1638,
        "test_case_id": 6,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 1 4 2 2\n",
        "output": "1 1 4 2 2 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1799,
        "task_id": 1638,
        "test_case_id": 7,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "6\n1 3 4 3 5 4\n",
        "output": "1 3 3 3 5 4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1800,
        "task_id": 1638,
        "test_case_id": 8,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\n",
        "output": "3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 22 22 53 99 59 52 52 31 31 31 31 23 23 9 9 9 7 7 7 7 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1801,
        "task_id": 1638,
        "test_case_id": 9,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "7\n6 2 2 6 5 7 7\n",
        "output": "2 2 2 5 5 7 7 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1802,
        "task_id": 1638,
        "test_case_id": 10,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "7\n2 4 1 2 3 1 2\n",
        "output": "2 4 1 1 1 1 1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1803,
        "task_id": 1638,
        "test_case_id": 11,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "7\n2 1 2 1 2 2 1\n",
        "output": "1 1 1 1 2 2 1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1804,
        "task_id": 1638,
        "test_case_id": 12,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "7\n5 2 4 2 4 1 1\n",
        "output": "5 2 2 2 2 1 1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1805,
        "task_id": 1638,
        "test_case_id": 13,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "6\n3 2 1 7 3 7\n",
        "output": "1 1 1 7 3 3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1806,
        "task_id": 1638,
        "test_case_id": 14,
        "question": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought $n$ plots along the highway and is preparing to build $n$ skyscrapers, one skyscraper per plot.\n\nArchitects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.\n\nFormally, let's number the plots from $1$ to $n$. Then if the skyscraper on the $i$-th plot has $a_i$ floors, it must hold that $a_i$ is at most $m_i$ ($1 \\le a_i \\le m_i$). Also there mustn't be integers $j$ and $k$ such that $j < i < k$ and $a_j > a_i < a_k$. Plots $j$ and $k$ are not required to be adjacent to $i$.\n\nThe company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 1000$) — the number of plots.\n\nThe second line contains the integers $m_1, m_2, \\ldots, m_n$ ($1 \\leq m_i \\leq 10^9$) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.\n\n\n-----Output-----\n\nPrint $n$ integers $a_i$ — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.\n\nIf there are multiple answers possible, print any of them.\n\n\n-----Examples-----\nInput\n5\n1 2 3 2 1\n\nOutput\n1 2 3 2 1 \n\nInput\n3\n10 6 8\n\nOutput\n10 6 6 \n\n\n\n-----Note-----\n\nIn the first example, you can build all skyscrapers with the highest possible height.\n\nIn the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer $[10, 6, 6]$ is optimal. Note that the answer of $[6, 6, 8]$ also satisfies all restrictions, but is not optimal.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    S = -1\\n    for mid in range(N):\\n        ans = [0] * N\\n        ans[mid] = A[mid]\\n        prev = A[mid]\\n        for j in range(mid-1, -1, -1):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        prev = A[mid]\\n        for j in range(mid+1, N):\\n            ans[j] = min(prev, A[j])\\n            prev = ans[j]\\n        if sum(ans) > S:\\n            S = sum(ans)\\n            ans_best = ans\\n    print(*ans_best)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve():\\n    n = int(input())\\n    m = list(map(int, input().split()))\\n    answ = [0] * n\\n    answc = 0\\n    for i in range(n):\\n        cur = [0] * n\\n        cur[i] = m[i]\\n        for j in range(i+1, n):\\n            cur[j] = min(cur[j-1], m[j])\\n        for j in range(i-1, -1, -1):\\n            cur[j] = min(cur[j+1], m[j])\\n        s = sum(cur)\\n        if s > answc:\\n            answc = s\\n            answ = cur\\n    print(*answ)\\n\\n\\n\\nfor i in range(1):\\n    solve()\\n\", \"from heapq import heappush,heappop,heapify\\nfrom collections import deque,defaultdict,Counter\\nimport itertools\\nfrom functools import *\\nfrom itertools import permutations,combinations,groupby\\nimport sys\\nimport bisect\\nimport string\\nimport math\\nimport time\\nimport random\\ndef Golf():\\n    *a,=map(int,open(0))\\ndef S_():\\n    return input()\\ndef IS():\\n    return input().split()\\ndef LS():\\n    return [i for i in input().split()]\\ndef I():\\n    return int(input())\\ndef MI():\\n    return map(int,input().split())\\ndef LI():\\n    return [int(i) for i in input().split()]\\ndef LI_():\\n    return [int(i)-1 for i in input().split()]\\ndef NI(n):\\n    return [int(input()) for i in range(n)]\\ndef NI_(n):\\n    return [int(input())-1 for i in range(n)]\\ndef StoI():\\n    return [ord(i)-97 for i in input()]\\ndef ItoS(nn):\\n    return chr(nn+97)\\ndef LtoS(ls):\\n    return ''.join([chr(i+97) for i in ls])\\ndef GI(V,E,Directed=False,index=0):\\n    org_inp=[]\\n    g=[[] for i in range(n)]\\n    for i in range(E):\\n        inp=LI()\\n        org_inp.append(inp)\\n        if index==0:\\n            inp[0]-=1\\n            inp[1]-=1\\n        if len(inp)==2:\\n            a,b=inp\\n            g[a].append(b)\\n            if not Directed:\\n                g[b].append(a)\\n        elif len(inp)==3:\\n            a,b,c=inp\\n            aa=(inp[0],inp[2])\\n            bb=(inp[1],inp[2])\\n            g[a].append(bb)\\n            if not Directed:\\n                g[b].append(aa)\\n    return g,org_inp\\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):\\n#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage\\n    mp=[1]*(w+2)\\n    found={}\\n    for i in range(h):\\n        s=input()\\n        for char in search:\\n            if char in s:\\n                found[char]=((i+1)*(w+2)+s.index(char)+1)\\n                mp_def[char]=mp_def[replacement_of_found]\\n        mp+=[1]+[mp_def[j] for j in s]+[1]\\n    mp+=[1]*(w+2)\\n    return h+2,w+2,mp,found\\ndef bit_combination(k,n=2):\\n    rt=[]\\n    for tb in range(n**k):\\n        s=[tb//(n**bt)%n for bt in range(k)]\\n        rt+=[s]\\n    return rt\\ndef show(*inp,end='\\\\n'):\\n    if show_flg:\\n        print(*inp,end=end)\\nYN=['YES','NO']\\nYn=['Yes','No']\\n\\nmo=10**9+7\\ninf=float('inf')\\nl_alp=string.ascii_lowercase\\nu_alp=string.ascii_uppercase\\n#ts=time.time()\\n#sys.setrecursionlimit(10**7)\\ninput=lambda: sys.stdin.readline().rstrip()\\n \\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\ndef ran_input():\\n    import random\\n    n=random.randint(4,16)\\n    rmin,rmax=1,10\\n    a=[random.randint(rmin,rmax) for _ in range(n)]\\n    return n,a\\n\\nshow_flg=False\\nshow_flg=True\\n\\nans=0\\n\\nn=I()\\nm=LI()\\ntot=0\\nfor i in range(n):\\n    l,r=[],[]\\n    \\n    tmp=m[i]\\n    p=m[i]\\n    \\n    # right\\n    for j in range(i+1,n):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        r+=[p]\\n    \\n    p=m[i]\\n    # left\\n    for j in range(i-1,-1,-1):\\n        if m[j]<p:\\n            p=m[j]\\n        tmp+=p\\n        l+=[p]\\n    \\n    if tmp>tot:\\n        tot=tmp\\n        ans=l[::-1]+[m[i]]+r\\n        \\nprint(*ans)\\n\\n\\n\\n\\n\", \"from math import *\\nfrom collections import *\\nn = int(input())\\na = list(map(int,input().split()))\\nans = 0\\nfres = []\\nfor i in range(n):\\n\\ts = a[i]\\n\\tprev = a[i]\\n\\tres = []\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev)\\n\\tprev = a[i]\\n\\tres = res[::-1]\\n\\tres.append(a[i])\\n\\tfor j in range(i+1,n):\\n\\t\\tprev = min(a[j],prev)\\n\\t\\ts += prev\\n\\t\\tres.append(prev) \\n\\tif(s > ans):\\n\\t\\tans = s\\n\\t\\tfres = res[::]\\nfor i in fres:\\n\\tprint(i,end = \\\" \\\")\", \"import sys \\ninput = sys.stdin.readline\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\nans = 0\\nind = -1\\nfor i in range(n):\\n    tmp = a[i]\\n    l = i\\n    r = i\\n    \\n    max_height = a[i]\\n    for j in range(0, l)[::-1]:\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n        \\n    max_height = a[i]\\n    for j in range(r + 1, n):\\n        if a[j] >= max_height: \\n            tmp += max_height\\n        else:\\n            tmp += a[j]\\n            max_height = a[j]\\n    if ans < tmp:\\n        ans = tmp\\n        ind = i\\n\\ni = ind\\nans = [0] * n\\n\\ntmp = a[i]\\nl = i\\nr = i\\n\\nmax_height = a[i]\\nans[i] = a[i]\\nfor j in range(0, l)[::-1]:\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\n    \\nmax_height = a[i]\\nfor j in range(r + 1, n):\\n    if a[j] >= max_height: \\n        tmp += max_height\\n    else:\\n        tmp += a[j]\\n        max_height = a[j]\\n    ans[j] = max_height\\nprint(*ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nfans = 0\\nheight = [0] * n\\nma = []\\nfor m in range(n):\\n    minh = 0\\n    thisans = 0\\n    # increasing\\n    np = False\\n    height[m] = a[m]\\n    for i in range(m-1, -1, -1):\\n        height[i] = height[i + 1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n\\n    for i in range(m+1, n):\\n        height[i] = height[i-1]\\n        if height[i] > a[i]:\\n            height[i] = a[i]\\n    thisans = sum(height)\\n    # fans = max(fans, thisans)\\n    if thisans > fans:\\n        ma = height.copy()\\n        fans = thisans\\nprint(*list(ma))\", \"n=int(input())\\nL=list(map(int,input().split()))\\nans=[0]*n\\nsA=0\\nfor top in range(n):\\n    r=[]\\n\\n    if top!=0:\\n        left=[]\\n        now=L[top]\\n        for i in range(top)[::-1]:\\n            now=min(now,L[i])\\n            left.append(now)\\n        r+=left[::-1]\\n    r.append(L[top])\\n    if top!=n-1:\\n        right=[]\\n        now=L[top]\\n        for i in range(top+1,n):\\n            now=min(now,L[i])\\n            right.append(now)\\n        r+=right\\n    sr=sum(r)\\n    if sA<sr:\\n        sA=sr\\n        ans=r\\nfor i in range(n):\\n    print(ans[i],end=' ')\", \"def f():\\n    n = int(input())\\n    M = [int(s) for s in input().split()]\\n    def goLeftFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s-1,-1,-1):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    def goRightFrom(s):\\n        sum = 0\\n        cur = M[s]\\n        for i in range(s+1,n):\\n            cur = min(cur,M[i])\\n            sum += cur\\n        return sum\\n    ans = 0\\n    choose = -1\\n    for i in range(n):\\n        l = goLeftFrom(i)\\n        r = goRightFrom(i)\\n        if l+r+M[i] > ans:\\n            choose = i\\n            ans = l+r+M[i]\\n    rt = [0]*n\\n    s = choose\\n    rt[s] = M[s]\\n    cur = M[s]\\n    for i in range(s - 1, -1, -1):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    cur = M[s]\\n    for i in range(s + 1, n):\\n        cur = min(cur, M[i])\\n        rt[i] = cur\\n    print(' '.join(str(num) for num in rt))\\n\\n\\n\\n\\nf()\", \"n = int(input())\\nsp = list(map(int, input().split()))\\nforw = [0 for i in range(n)]\\nbackw = [0 for i in range(n)]\\nstack = [(0, -1, 0)]\\nfor i in range(n):\\n\\twhile (sp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((sp[i], i, (i - stack[-1][1]) * sp[i] + stack[-1][2]))\\n\\tforw[i] = stack[-1][2]\\nrevsp = sp[::-1]\\nstack = [(0, -1, 0)]\\n\\nfor i in range(n):\\n\\twhile (revsp[i] <= stack[-1][0]):\\n\\t\\tstack.pop()\\n\\tstack.append((revsp[i], i, (i - stack[-1][1]) * revsp[i] + stack[-1][2]))\\n\\tbackw[i] = stack[-1][2]\\n\\nbackw = backw[::-1]\\n#print(forw)\\n#print(backw)\\n\\ncenter = 0\\nans_center = 0\\nfor i in range(n):\\n\\tif ans_center < backw[i] + forw[i] - sp[i]:\\n\\t\\tcenter = i\\n\\t\\tans_center = backw[i] + forw[i] - sp[i]\\n#print(center)\\nans = [0 for i in range(n)]\\nans[center] = sp[center]\\ncur = sp[center]\\nfor i in range(center - 1, -1, -1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\ncur = sp[center]\\nfor i in range(center + 1, n, 1):\\n\\tcur = min(cur, sp[i])\\n\\tans[i] = cur\\n\\nprint(*ans)\\n\", \"N = int(input())\\n\\nm = list(map(int, input().split()))\\nans = 0\\n\\ndef sol(k):\\n    ret = l = r = m[k]\\n    for i in range(k+1, N):\\n        if m[i] < r: r = m[i]\\n        ret += r\\n    for i in range(k-1, -1, -1):\\n        if m[i] < l: l = m[i]\\n        ret += l\\n    return ret\\nans_idx = -1\\nfor i in range(N):\\n    X = sol(i)\\n    if ans < X:\\n        ans = X\\n        ans_idx = i\\n\\nl = r = m[ans_idx]\\nfor i in range(ans_idx+1, N):\\n    if m[i] < r:\\n        r = m[i]\\n    else:\\n        m[i] = r\\nfor i in range(ans_idx-1, -1, -1):\\n        if m[i] < l:\\n            l = m[i]\\n        else:\\n            m[i] = l\\nprint(*m)\", \"import sys\\n\\nn=int(sys.stdin.readline())\\n\\nm=[int(x) for x in sys.stdin.readline().split()]\\n\\nans=0\\n\\narr=[0]*n\\n\\nfor i in range(n):\\n\\t\\n\\tfloors=m[i]\\n\\t\\t\\n\\ttmp=[0]*n\\n\\ttmp[i]=m[i]\\n\\n\\tprev=m[i]\\n\\tfor j in range(i-1,-1,-1):\\n\\t\\tnum=min(prev,m[j])\\n\\t\\tfloors+=num\\n\\t\\ttmp[j]=num\\n\\t\\tprev=num\\n\\n\\tp2=m[i]\\n\\tfor k in range(i+1,n):\\n\\t\\tn2=min(p2,m[k])\\n\\t\\tfloors+=n2\\n\\t\\ttmp[k]=n2\\n\\t\\tp2=n2\\n\\n\\tif(floors>ans):\\n\\t\\tans=floors\\n\\t\\tfor g in range(n):\\n\\t\\t\\tarr[g]=tmp[g]\\n\\nfor p in range(n):\\n\\tprint(arr[p],end=\\\" \\\")\\nprint()\\n\", \"from sys import stdin,stdout\\ninput=stdin.readline\\nn=int(input())\\na=list(map(int,input().split()))\\ndict=[]\\nval=-1\\ni=0\\nwhile i<n:\\n    v=a[i]\\n    j=i-1\\n    arr=[]\\n    pmin=v\\n    while j>=0:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j-=1\\n        \\n    arr=arr[::-1]\\n    arr.append(a[i])\\n    j=i+1\\n    pmin=v\\n    while j<n:\\n        v+=min(a[j],pmin)\\n        arr.append(min(a[j],pmin))\\n        pmin=min(pmin,min(a[j],pmin))\\n        j+=1\\n    if v>val:\\n\\n        val=max(val,v)\\n        dict=arr\\n    i+=1\\nprint(*dict)\\n#print(dict.values())\\n    \\n\\n\\n\\n\", \"n = int(input())\\nm = list(map(int,input().split()))\\nans = []\\ntotalmax = 0\\nfor top in range(n):\\n    lst = [0]*n\\n    lst[top] = m[top]\\n    for i in range(top-1,-1,-1):\\n        lst[i] = min(lst[i+1],m[i])\\n    for i in range(top+1,n):\\n        lst[i] = min(lst[i-1],m[i])\\n    total = sum(lst)\\n    if totalmax < total:\\n        ans = lst\\n        totalmax = total\\n\\nprint(*ans,sep=\\\" \\\")\", \"n = int(input())\\narr = list(map(int, input().split()))\\nans = 0\\nres = None\\nfor i in range(n):\\n\\ttemp = list(arr)\\n\\tmini = arr[i]\\n\\tfor j in range(i-1, -1, -1):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\tmini = arr[i]\\n\\tfor j in range(i+1, n):\\n\\t\\ttemp[j] = min(temp[j], mini)\\n\\t\\tmini = min(mini, temp[j])\\n\\ts = sum(temp)\\n\\tif s > ans:\\n\\t\\tans = s\\n\\t\\tres = list(temp)\\nprint(*res)\", \"from copy import copy\\nfrom math import *\\n\\ndef arr_float_inp():\\n    return [float(s) for s in input().split()]\\n\\n\\ndef arr_int_inp():\\n    return [int(s) for s in input().split()]\\n\\n\\ndef int_inp():\\n    return int(input())\\n\\n\\ndef float_inp():\\n    return float(input())\\n\\n\\ndef comp(a):\\n    return a[0]\\n\\n\\ndef gcd(a, b):\\n    if b != 0:\\n        return gcd(b, a % b)\\n    else:\\n        return a\\n\\n\\ndef __starting_point():\\n    n = int_inp()\\n    arr = arr_int_inp()\\n    outs = []\\n    for j in range(len(arr)):\\n        max_el = (j, arr[j])\\n\\n        new_arr = [0 for _ in range(len(arr))]\\n        new_arr[max_el[0]] = max_el[1]\\n        right = max_el[1]\\n        for i in range(max_el[0], -1, -1):\\n            new_arr[i] = min(arr[i], right)\\n            right = new_arr[i]\\n\\n        left = max_el[1]\\n        for i in range(max_el[0], len(arr)):\\n            new_arr[i] = min(arr[i], left)\\n            left = new_arr[i]\\n\\n        outs.append(new_arr)\\n\\n    max_out = (sum(outs[0]), outs[0])\\n    for out in outs:\\n        new_sum = sum(out)\\n        if new_sum > max_out[0]:\\n            max_out = (new_sum, out)\\n\\n    for el in max_out[1]:\\n        print(el, end=' ')\\n\\n__starting_point()\", \"n = int(input())\\nm = list(map(int, input().split()))\\nans, idx = 0, -1\\nfor i in range(n):\\n    a = [0] * n\\n    a[i] = m[i]\\n    for j in range(i - 1, -1, -1):\\n        a[j] = min(m[j], a[j + 1])\\n    for j in range(i + 1, n):\\n        a[j] = min(m[j], a[j - 1])\\n    tot = sum(a)\\n    if tot > ans:\\n        ans = tot\\n        idx = i\\na = [0] * n\\na[idx] = m[idx]\\nfor j in range(idx - 1, -1, -1):\\n    a[j] = min(m[j], a[j + 1])\\nfor j in range(idx + 1, n):\\n    a[j] = min(m[j], a[j - 1])\\nprint(*a)\\n\"]",
        "difficulty": "interview",
        "input": "6\n4 1 2 3 2 1\n",
        "output": "1 1 2 3 2 1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1313/C1"
    },
    {
        "id": 1807,
        "task_id": 1656,
        "test_case_id": 8,
        "question": "Recall that string $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly zero or all) characters. For example, for the string $a$=\"wowwo\", the following strings are subsequences: \"wowwo\", \"wowo\", \"oo\", \"wow\", \"\", and others, but the following are not subsequences: \"owoo\", \"owwwo\", \"ooo\".\n\nThe wow factor of a string is the number of its subsequences equal to the word \"wow\". Bob wants to write a string that has a large wow factor. However, the \"w\" key on his keyboard is broken, so he types two \"v\"s instead. \n\nLittle did he realise that he may have introduced more \"w\"s than he thought. Consider for instance the string \"ww\". Bob would type it as \"vvvv\", but this string actually contains three occurrences of \"w\":   \"vvvv\"  \"vvvv\"  \"vvvv\" \n\nFor example, the wow factor of the word \"vvvovvv\" equals to four because there are four wows:  \"vvvovvv\"  \"vvvovvv\"  \"vvvovvv\"  \"vvvovvv\" \n\nNote that the subsequence \"vvvovvv\" does not count towards the wow factor, as the \"v\"s have to be consecutive.\n\nFor a given string $s$, compute and output its wow factor. Note that it is not guaranteed that it is possible to get $s$ from another string replacing \"w\" with \"vv\". For example, $s$ can be equal to \"vov\".\n\n\n-----Input-----\n\nThe input contains a single non-empty string $s$, consisting only of characters \"v\" and \"o\". The length of $s$ is at most $10^6$.\n\n\n-----Output-----\n\nOutput a single integer, the wow factor of $s$.\n\n\n-----Examples-----\nInput\nvvvovvv\n\nOutput\n4\n\nInput\nvvovooovovvovoovoovvvvovovvvov\n\nOutput\n100\n\n\n\n-----Note-----\n\nThe first example is explained in the legend.",
        "solutions": "[\"s = input()\\nn = len(s)\\np = [0] * (n+1)\\nfor x in range(1, n):\\n\\ty = 0\\n\\tif s[x] == 'v' and s[x-1] == 'v':\\n\\t\\ty = 1\\n\\tp[x+1] = p[x] + y\\nq = 0\\nsol = 0\\nfor x in range(n-3, -1, -1):\\n\\tif s[x+1] == 'v' and s[x+2] == 'v':\\n\\t\\tq += 1\\n\\tif s[x] == 'o':\\n\\t\\tsol += q*p[x]\\nprint(sol)\\n\", \"s = input()\\nn = len(s)\\n\\nout = 0\\nwCount = 0\\noPlace = []\\nfor i in range(n-1):\\n    if s[i] == 'o':\\n        oPlace.append(wCount)\\n    elif s[i] == 'v' and s[i+1] == 'v':\\n        wCount += 1\\n\\nprint(sum([x*(wCount-x) for x in oPlace]))\\n\", \"s=[max(0,len(x)-1) for x in input().split('o')]\\nR=sum(s)\\nL=0\\nans=0\\nfor x in s:\\n    L+=x\\n    R-=x\\n    ans+=L*R\\n    \\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\ns=input().strip()\\nANS=0\\nBEFORE=0\\nOCOUNT=0\\n\\nLEN=len(s)\\n\\nfor i in range(1,LEN):\\n    if s[i]==\\\"v\\\" and s[i-1]==\\\"v\\\":\\n        BEFORE+=1\\n\\n        ANS+=OCOUNT\\n\\n    if s[i]==\\\"o\\\":\\n        OCOUNT+=BEFORE\\n\\nprint(ANS)\\n\\n    \\n\", \"from itertools import accumulate\\n\\nv = ord('v')\\no = ord('o')\\nS = [o]+[ord(s) for s in input().strip()]\\n\\nstack = []\\npre = None\\ncnt = 0\\nfor s in S:\\n    if s == pre:\\n        cnt += 1\\n    else:\\n        pre = s\\n        stack.append(cnt)\\n        cnt = 1\\nstack.append(cnt)\\nstack = stack[1:]\\n\\nLS = len(stack)\\nw = 0\\nsp = [stack[i]-1 if i % 2 else 0 for i in range(LS)]\\nsr = list(accumulate(sp))\\nsl = list(accumulate(sp[::-1]))[::-1]\\nans = 0\\nfor i in range(0, LS, 2):\\n    ans += sr[i]*sl[i]*stack[i]\\nprint(ans)\\n\", \"import sys\\n\\ns = sys.stdin.readline().strip()\\nn = len(s)\\n\\nw = 0\\nwo = 0\\nwow = 0\\n\\nfor i in range (1, n):\\n    if s[i] == \\\"v\\\" and s[i-1] == \\\"v\\\":\\n        w = w + 1\\n        wow = wow + wo\\n    if s[i] == \\\"o\\\":\\n        wo = wo + w\\n\\nprint(wow)\", \"s = input()\\nl, n = [], len(s)\\ni = 0\\nwhile i < n:\\n    j = i\\n    while j < n and s[j] == 'v':\\n        j += 1\\n    l.append(max(j - i - 1, 0))\\n    i = j\\n    while j < n and s[j] == 'o':\\n        j += 1\\n    l.append(j - i)\\n    i = j\\ndp = [0, 0, 0]\\nfor i in range(len(l)):\\n    if i & 1:\\n        dp[1] += dp[0] * l[i]\\n    else:\\n        dp[2] += dp[1] * l[i]\\n        dp[0] += l[i]\\n# print(*l)\\nprint(dp[-1])\", \"s = input()\\nN = len(s)\\nd1 = [0] * N\\nd2 = [0] * N\\nfor i in range(N - 1):\\n    if s[i: i + 2] == 'vv':\\n        d1[i] += 1\\n\\nfor i in range(1, N):\\n    d1[i] += d1[i - 1]\\n\\nfor i in range(N - 1, 0, -1):\\n    if s[i] == 'v' and s[i - 1] == 'v':\\n        d2[i] = 1\\n\\nfor i in range(N - 2, -1, -1):\\n    d2[i] += d2[i + 1]\\n\\nans = 0\\nfor i in range(N):\\n    if s[i] == 'o':\\n        ans += d1[i] * d2[i]\\n\\nprint(ans)\", \"s = input()\\nw, wo, wow = 0, 0, 0\\nlast = None\\nfor c in s:\\n    if c == 'v' and last == 'v':\\n        w += 1\\n        wow += wo\\n    elif c == 'o':\\n        wo += w\\n    last = c\\n\\nprint( wow )\\n\", \"s = input()\\n\\nn = len(s)\\n\\nldp = [0 for i in range(n)]\\nrdp = [0 for i in range(n)]\\n\\nconsec = 0\\nfor i in range(n):\\n    if(s[i] == 'v'):\\n        consec += 1\\n    else:\\n        consec = 0\\n    if(consec > 1):\\n        ldp[i] = ldp[i - 1] + 1\\n    else:\\n        ldp[i] = ldp[i - 1]\\nconsec = (s[-1] == 'v')\\nfor i in range(n-2, -1, -1):\\n    if(s[i] == 'v'):\\n        consec += 1\\n    else:\\n        consec = 0\\n    if(consec > 1):\\n        rdp[i] = rdp[i + 1] + 1\\n    else:\\n        rdp[i] = rdp[i + 1]\\nans = 0\\n#print(ldp)\\n#print(rdp)\\nfor i in range(n):\\n    if(s[i] == 'o'):\\n        ans += ldp[i] * rdp[i]\\n\\nprint(ans)\\n\\n\", \"s = input()\\nprev = \\\"\\\"\\ncnt = 0\\nfor elem in s:\\n    if elem == \\\"v\\\" and prev == \\\"v\\\":\\n        cnt += 1\\n    prev = elem\\nn = 0\\nprev = \\\"\\\"\\nans = 0\\nfor elem in s:\\n    if elem == \\\"v\\\" and prev == \\\"v\\\":\\n        n += 1\\n    if elem == \\\"o\\\":\\n        ans += n*(cnt-n)\\n    prev = elem\\nprint(ans)\", \"3\\n\\nimport math\\nimport sys\\n\\n\\nDEBUG = False\\n\\n\\ndef inp():\\n    return sys.stdin.readline().rstrip()\\n\\n\\ndef dprint(*value, sep=' ', end='\\\\n'):\\n    if DEBUG:\\n        print(*value, sep=sep, end=end)\\n\\n\\ndef solve(S):\\n    vv = 0\\n    o = 0\\n    cnt = 0\\n\\n    N = len(S)\\n    for i in range(N):\\n        if S[i:i + 2] == 'vv':\\n            cnt += o\\n            vv += 1\\n        elif S[i] == 'o':\\n            o += vv\\n\\n    return cnt\\n\\n\\ndef main():\\n    S = inp()\\n    print(solve(S))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"s = input()\\nwcount = 0\\nfor i in range(len(s)-1):\\n    if s[i+1] == \\\"v\\\" and s[i] == \\\"v\\\":\\n        wcount += 1\\n\\nans = 0\\nwcountl = 0\\nfor i in range(len(s)-1):\\n    if s[i+1] == \\\"v\\\" and s[i] == \\\"v\\\":\\n        wcountl += 1\\n        wcount -= 1\\n    elif s[i+1] == \\\"o\\\":\\n        ans += wcountl*wcount\\n\\nprint(ans)\\n\", \"import io, sys, atexit, os\\nimport math as ma\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\nfrom itertools import combinations\\n\\n\\ndef li ():\\n\\treturn list (map (int, input ().split ()))\\n\\n\\ndef num ():\\n\\treturn map (int, input ().split ())\\n\\n\\ndef nu ():\\n\\treturn int (input ())\\n\\n\\ndef find_gcd ( x, y ):\\n\\twhile (y):\\n\\t\\tx, y = y, x % y\\n\\treturn x\\n\\n\\ndef lcm ( x, y ):\\n\\tgg = find_gcd (x, y)\\n\\treturn (x * y // gg)\\n\\n\\nmm = 1000000007\\nyp = 0\\ndef solve ():\\n\\tt = 1\\n\\tfor tt in range (t):\\n\\t\\ts=input()\\n\\t\\tn=len(s)\\n\\t\\tl=[0]*n\\n\\t\\tfor i in range(n-1):\\n\\t\\t\\tif(s[i]==s[i+1] and s[i]==\\\"v\\\"):\\n\\t\\t\\t\\tl[i]=1\\n\\t\\tpre=[0]*n\\n\\t\\tsuf=[0]*n\\n\\t\\tpre[0]=l[0]\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tpre[i]=pre[i-1]+l[i]\\n\\t\\tsuf[n-1]=l[n-1]\\n\\t\\tfor i in range(n-2,-1,-1):\\n\\t\\t\\tsuf[i]=suf[i+1]+l[i]\\n\\t\\tans=0\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif(s[i]==\\\"o\\\"):\\n\\t\\t\\t\\tif(i-1>=0 and i+1<n):\\n\\t\\t\\t\\t\\tans+=pre[i-1]*suf[i+1]\\n\\t\\tprint(ans)\\n\\ndef __starting_point():\\n\\tsolve ()\\n__starting_point()\", \"s=str(input())\\narr1=[]\\narr2=[]\\ncountx=0\\ni=0\\nwhile(i<len(s)):\\n\\tif(s[i]=='o'):\\n\\t\\tarr1.append(countx)\\n\\t\\ti+=1\\n\\telse:\\n\\t\\tj=i\\n\\t\\twhile(j<len(s) and s[j]=='v'):\\n\\t\\t\\tj+=1\\n\\t\\tdiff=j-i\\n\\t\\tcountx+=(diff-1)\\n\\t\\ti=j\\nans=0\\n#print(*arr1)\\nfor i in range(len(arr1)):\\n\\tans+=(arr1[i]*(countx-(arr1[i])))\\n\\nprint(ans)\", \"# @author \\n\\nimport sys\\n\\nclass BWOWFactor:\\n    def solve(self):\\n        s = input()\\n        n = len(s)\\n        vv_pre = [0] * (n + 1)\\n        vv_suf = [0] * (n + 1)\\n\\n        for i in range(n - 1):\\n            vv_pre[i + 1] = vv_pre[i]\\n            if s[i] == s[i + 1] == 'v':\\n                vv_pre[i + 1] += 1\\n\\n        for i in range(n - 1, 0, -1):\\n            vv_suf[i - 1] = vv_suf[i]\\n            if s[i] == s[i - 1] == 'v':\\n                vv_suf[i - 1] += 1\\n\\n\\n        ans = 0\\n        for i in range(2, n - 2):\\n            if s[i] == 'o':\\n                ans += vv_pre[i - 1] * vv_suf[i + 1]\\n\\n        \\n        print(ans)\\n\\nsolver = BWOWFactor()\\ninput = sys.stdin.readline\\n\\nsolver.solve()\\n\", \"s = input()\\nwtot = 0\\nfor i in range(1, len(s)):\\n    if s[i] == 'v' and s[i-1] == 'v':\\n        wtot += 1\\nwleft = 0\\nans = 0\\nfor i in range(len(s)):\\n    if i > 0 and s[i] == 'v' and s[i-1] == 'v':\\n        wleft += 1\\n    elif s[i] == 'o':\\n        ans += wleft*(wtot-wleft)\\nprint(ans)\", \"ll= lambda : list(map(int,input().split()))\\ntestcases=1\\n# testcases=int(input())\\nfor testcase in range(testcases):\\n\\ts=input()\\n\\tn=len(s)\\n\\tdp=[0]\\n\\t# print(dp)\\n\\tfor i in range(n-1):\\n\\t\\tif s[i]=='v' and s[i+1]=='v':\\n\\t\\t\\tdp.append(dp[-1]+1)\\n\\t\\telse:\\n\\t\\t\\tdp.append(dp[-1])\\n\\t# print(dp)\\n\\tans=0\\n\\tfor i in range(0,n):\\n\\t\\tif s[i]=='o':\\n\\t\\t\\tans+=(dp[i]*(dp[-1]-dp[i]))\\n\\tprint(ans)\\n\\n\", \"s = input()\\ns = s.strip('o')\\nv = []\\no = []\\n\\ncnt_v = 0\\ncnt_o = 0\\nfor i in range(len(s)):\\n    if s[i] == 'v':\\n        if cnt_o:\\n            o.append(cnt_o)\\n            cnt_o = 0\\n        cnt_v += 1\\n    else:\\n        if cnt_v:\\n            v.append(cnt_v)\\n            cnt_v = 0\\n        cnt_o += 1\\n\\nv.append(cnt_v)\\n\\nleft = v[0]\\nleft_cnt = 1\\nans = 0\\nall_v = sum(v)\\nlen_v = len(v)\\n\\nfor i in range(len(o)):\\n    ans += (left - left_cnt) * o[i] * (all_v - left - len_v + left_cnt)\\n    left += v[i + 1]\\n    left_cnt += 1\\n\\nprint(ans)\\n\", \"s = input()\\nans = 0\\narr = s.split('o')\\nwsall = 0\\nfor i in arr:\\n    if len(i)>1:\\n        wsall+=len(i)-1\\nws=0\\nfor i in range(len(arr)-1):\\n    if len(arr[i])>1:\\n        ws+=len(arr[i])-1\\n        wsall-=(len(arr[i])-1)\\n    ans += ws * wsall\\nprint(ans)\\n\\n\\n\\n\", \"s = input().split()[0]\\nwos = []\\n\\nsum_w = 0\\nsum_o = 0\\nfor i in range(len(s)):\\n    if s[i] == 'o':\\n        wos.append(sum_w + (0 if len(wos) == 0 else wos[-1]))\\n        sum_o += 1\\n    elif s[i] == 'v':\\n        wos.append(0 if len(wos) == 0 else wos[-1])\\n        if i == 0 or s[i - 1] != 'v':\\n            pass\\n        else:\\n            sum_w += 1\\n\\nanswer = 0\\nfor i in range(len(s)):\\n    if s[i] == 'o':\\n        pass\\n    elif s[i] == 'v':\\n        if i == 0 or s[i - 1] != 'v':\\n            pass\\n        else:\\n            answer += wos[i]\\n\\nprint(answer)\", \"from sys import stdin\\n\\ns=stdin.readline().strip()\\nn=len(s)\\nl=[0 for i in range(n)]\\nr=[0 for i in range(n)]\\ndef cal(x):\\n    return (x*(x-1))//2\\nfor i in range(n):\\n    if i==0:\\n        continue\\n    if s[i]==\\\"v\\\" and s[i-1]==\\\"v\\\":\\n        l[i]+=1\\n    l[i]+=l[i-1]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        continue\\n    if s[i]==\\\"v\\\" and s[i+1]==\\\"v\\\":\\n        r[i]+=1\\n    r[i]+=r[i+1]\\nans=0\\nfor i in range(n):\\n    if s[i]==\\\"o\\\":\\n        ans+=l[i]*r[i]\\nprint(ans)\\n    \\n\", \"s = input()\\nn = len(s)\\ncount_o = []\\ncount_w = 0\\ncount = 0\\nfor i in range(1, n):\\n    if s[i] == 'v' and s[i-1] == 'v':\\n        count_w += 1\\n    elif s[i] == 'o':\\n        count_o.append(count_w)\\nfor c in count_o:\\n    count += c * (count_w-c)\\nprint(count)\\n\", \"s = input()\\nn = len(s)\\n\\nfirst = [0]*n\\nlast = [0]*n\\n\\np = 0\\nc = 0\\nfor i in range(n):\\n    if s[i] == 'v':\\n        p += 1\\n    else:\\n        if p:\\n            c += p-1\\n        p = 0\\n    if s[i] == 'o':\\n        first[i] = c\\n\\np = 0\\nc = 0\\nfor i in range(n-1, -1, -1):\\n    if s[i] == 'v':\\n        p += 1\\n    else:\\n        if p:\\n            c += p-1\\n        p = 0\\n    if s[i] == 'o':\\n        last[i] = c\\n\\nresult = 0\\nfor i in range(n):\\n    if s[i] =='o':\\n        result += first[i]*last[i]\\n\\nprint(result)\", \"s=input()\\npre=[0]\\ncurr=-1\\nn=len(s)\\nfor i in range(1,n):\\n\\tif s[i]=='v' and s[i-1]=='v':\\n\\t\\tpre.append(pre[-1]+1)\\n\\telse:\\n\\t\\tpre.append(pre[-1])\\ncurr=0\\nans=0\\nfor i in range(n-2,-1,-1):\\n\\tif s[i]=='v' and s[i+1]=='v':\\n\\t\\tcurr+=1\\n\\telif s[i]=='o':\\n\\t\\tans+=(curr)*(pre[i])\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "ovvo\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1178/B"
    },
    {
        "id": 1808,
        "task_id": 1656,
        "test_case_id": 10,
        "question": "Recall that string $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly zero or all) characters. For example, for the string $a$=\"wowwo\", the following strings are subsequences: \"wowwo\", \"wowo\", \"oo\", \"wow\", \"\", and others, but the following are not subsequences: \"owoo\", \"owwwo\", \"ooo\".\n\nThe wow factor of a string is the number of its subsequences equal to the word \"wow\". Bob wants to write a string that has a large wow factor. However, the \"w\" key on his keyboard is broken, so he types two \"v\"s instead. \n\nLittle did he realise that he may have introduced more \"w\"s than he thought. Consider for instance the string \"ww\". Bob would type it as \"vvvv\", but this string actually contains three occurrences of \"w\":   \"vvvv\"  \"vvvv\"  \"vvvv\" \n\nFor example, the wow factor of the word \"vvvovvv\" equals to four because there are four wows:  \"vvvovvv\"  \"vvvovvv\"  \"vvvovvv\"  \"vvvovvv\" \n\nNote that the subsequence \"vvvovvv\" does not count towards the wow factor, as the \"v\"s have to be consecutive.\n\nFor a given string $s$, compute and output its wow factor. Note that it is not guaranteed that it is possible to get $s$ from another string replacing \"w\" with \"vv\". For example, $s$ can be equal to \"vov\".\n\n\n-----Input-----\n\nThe input contains a single non-empty string $s$, consisting only of characters \"v\" and \"o\". The length of $s$ is at most $10^6$.\n\n\n-----Output-----\n\nOutput a single integer, the wow factor of $s$.\n\n\n-----Examples-----\nInput\nvvvovvv\n\nOutput\n4\n\nInput\nvvovooovovvovoovoovvvvovovvvov\n\nOutput\n100\n\n\n\n-----Note-----\n\nThe first example is explained in the legend.",
        "solutions": "[\"s = input()\\nn = len(s)\\np = [0] * (n+1)\\nfor x in range(1, n):\\n\\ty = 0\\n\\tif s[x] == 'v' and s[x-1] == 'v':\\n\\t\\ty = 1\\n\\tp[x+1] = p[x] + y\\nq = 0\\nsol = 0\\nfor x in range(n-3, -1, -1):\\n\\tif s[x+1] == 'v' and s[x+2] == 'v':\\n\\t\\tq += 1\\n\\tif s[x] == 'o':\\n\\t\\tsol += q*p[x]\\nprint(sol)\\n\", \"s = input()\\nn = len(s)\\n\\nout = 0\\nwCount = 0\\noPlace = []\\nfor i in range(n-1):\\n    if s[i] == 'o':\\n        oPlace.append(wCount)\\n    elif s[i] == 'v' and s[i+1] == 'v':\\n        wCount += 1\\n\\nprint(sum([x*(wCount-x) for x in oPlace]))\\n\", \"s=[max(0,len(x)-1) for x in input().split('o')]\\nR=sum(s)\\nL=0\\nans=0\\nfor x in s:\\n    L+=x\\n    R-=x\\n    ans+=L*R\\n    \\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\ns=input().strip()\\nANS=0\\nBEFORE=0\\nOCOUNT=0\\n\\nLEN=len(s)\\n\\nfor i in range(1,LEN):\\n    if s[i]==\\\"v\\\" and s[i-1]==\\\"v\\\":\\n        BEFORE+=1\\n\\n        ANS+=OCOUNT\\n\\n    if s[i]==\\\"o\\\":\\n        OCOUNT+=BEFORE\\n\\nprint(ANS)\\n\\n    \\n\", \"from itertools import accumulate\\n\\nv = ord('v')\\no = ord('o')\\nS = [o]+[ord(s) for s in input().strip()]\\n\\nstack = []\\npre = None\\ncnt = 0\\nfor s in S:\\n    if s == pre:\\n        cnt += 1\\n    else:\\n        pre = s\\n        stack.append(cnt)\\n        cnt = 1\\nstack.append(cnt)\\nstack = stack[1:]\\n\\nLS = len(stack)\\nw = 0\\nsp = [stack[i]-1 if i % 2 else 0 for i in range(LS)]\\nsr = list(accumulate(sp))\\nsl = list(accumulate(sp[::-1]))[::-1]\\nans = 0\\nfor i in range(0, LS, 2):\\n    ans += sr[i]*sl[i]*stack[i]\\nprint(ans)\\n\", \"import sys\\n\\ns = sys.stdin.readline().strip()\\nn = len(s)\\n\\nw = 0\\nwo = 0\\nwow = 0\\n\\nfor i in range (1, n):\\n    if s[i] == \\\"v\\\" and s[i-1] == \\\"v\\\":\\n        w = w + 1\\n        wow = wow + wo\\n    if s[i] == \\\"o\\\":\\n        wo = wo + w\\n\\nprint(wow)\", \"s = input()\\nl, n = [], len(s)\\ni = 0\\nwhile i < n:\\n    j = i\\n    while j < n and s[j] == 'v':\\n        j += 1\\n    l.append(max(j - i - 1, 0))\\n    i = j\\n    while j < n and s[j] == 'o':\\n        j += 1\\n    l.append(j - i)\\n    i = j\\ndp = [0, 0, 0]\\nfor i in range(len(l)):\\n    if i & 1:\\n        dp[1] += dp[0] * l[i]\\n    else:\\n        dp[2] += dp[1] * l[i]\\n        dp[0] += l[i]\\n# print(*l)\\nprint(dp[-1])\", \"s = input()\\nN = len(s)\\nd1 = [0] * N\\nd2 = [0] * N\\nfor i in range(N - 1):\\n    if s[i: i + 2] == 'vv':\\n        d1[i] += 1\\n\\nfor i in range(1, N):\\n    d1[i] += d1[i - 1]\\n\\nfor i in range(N - 1, 0, -1):\\n    if s[i] == 'v' and s[i - 1] == 'v':\\n        d2[i] = 1\\n\\nfor i in range(N - 2, -1, -1):\\n    d2[i] += d2[i + 1]\\n\\nans = 0\\nfor i in range(N):\\n    if s[i] == 'o':\\n        ans += d1[i] * d2[i]\\n\\nprint(ans)\", \"s = input()\\nw, wo, wow = 0, 0, 0\\nlast = None\\nfor c in s:\\n    if c == 'v' and last == 'v':\\n        w += 1\\n        wow += wo\\n    elif c == 'o':\\n        wo += w\\n    last = c\\n\\nprint( wow )\\n\", \"s = input()\\n\\nn = len(s)\\n\\nldp = [0 for i in range(n)]\\nrdp = [0 for i in range(n)]\\n\\nconsec = 0\\nfor i in range(n):\\n    if(s[i] == 'v'):\\n        consec += 1\\n    else:\\n        consec = 0\\n    if(consec > 1):\\n        ldp[i] = ldp[i - 1] + 1\\n    else:\\n        ldp[i] = ldp[i - 1]\\nconsec = (s[-1] == 'v')\\nfor i in range(n-2, -1, -1):\\n    if(s[i] == 'v'):\\n        consec += 1\\n    else:\\n        consec = 0\\n    if(consec > 1):\\n        rdp[i] = rdp[i + 1] + 1\\n    else:\\n        rdp[i] = rdp[i + 1]\\nans = 0\\n#print(ldp)\\n#print(rdp)\\nfor i in range(n):\\n    if(s[i] == 'o'):\\n        ans += ldp[i] * rdp[i]\\n\\nprint(ans)\\n\\n\", \"s = input()\\nprev = \\\"\\\"\\ncnt = 0\\nfor elem in s:\\n    if elem == \\\"v\\\" and prev == \\\"v\\\":\\n        cnt += 1\\n    prev = elem\\nn = 0\\nprev = \\\"\\\"\\nans = 0\\nfor elem in s:\\n    if elem == \\\"v\\\" and prev == \\\"v\\\":\\n        n += 1\\n    if elem == \\\"o\\\":\\n        ans += n*(cnt-n)\\n    prev = elem\\nprint(ans)\", \"3\\n\\nimport math\\nimport sys\\n\\n\\nDEBUG = False\\n\\n\\ndef inp():\\n    return sys.stdin.readline().rstrip()\\n\\n\\ndef dprint(*value, sep=' ', end='\\\\n'):\\n    if DEBUG:\\n        print(*value, sep=sep, end=end)\\n\\n\\ndef solve(S):\\n    vv = 0\\n    o = 0\\n    cnt = 0\\n\\n    N = len(S)\\n    for i in range(N):\\n        if S[i:i + 2] == 'vv':\\n            cnt += o\\n            vv += 1\\n        elif S[i] == 'o':\\n            o += vv\\n\\n    return cnt\\n\\n\\ndef main():\\n    S = inp()\\n    print(solve(S))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"s = input()\\nwcount = 0\\nfor i in range(len(s)-1):\\n    if s[i+1] == \\\"v\\\" and s[i] == \\\"v\\\":\\n        wcount += 1\\n\\nans = 0\\nwcountl = 0\\nfor i in range(len(s)-1):\\n    if s[i+1] == \\\"v\\\" and s[i] == \\\"v\\\":\\n        wcountl += 1\\n        wcount -= 1\\n    elif s[i+1] == \\\"o\\\":\\n        ans += wcountl*wcount\\n\\nprint(ans)\\n\", \"import io, sys, atexit, os\\nimport math as ma\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\nfrom itertools import combinations\\n\\n\\ndef li ():\\n\\treturn list (map (int, input ().split ()))\\n\\n\\ndef num ():\\n\\treturn map (int, input ().split ())\\n\\n\\ndef nu ():\\n\\treturn int (input ())\\n\\n\\ndef find_gcd ( x, y ):\\n\\twhile (y):\\n\\t\\tx, y = y, x % y\\n\\treturn x\\n\\n\\ndef lcm ( x, y ):\\n\\tgg = find_gcd (x, y)\\n\\treturn (x * y // gg)\\n\\n\\nmm = 1000000007\\nyp = 0\\ndef solve ():\\n\\tt = 1\\n\\tfor tt in range (t):\\n\\t\\ts=input()\\n\\t\\tn=len(s)\\n\\t\\tl=[0]*n\\n\\t\\tfor i in range(n-1):\\n\\t\\t\\tif(s[i]==s[i+1] and s[i]==\\\"v\\\"):\\n\\t\\t\\t\\tl[i]=1\\n\\t\\tpre=[0]*n\\n\\t\\tsuf=[0]*n\\n\\t\\tpre[0]=l[0]\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tpre[i]=pre[i-1]+l[i]\\n\\t\\tsuf[n-1]=l[n-1]\\n\\t\\tfor i in range(n-2,-1,-1):\\n\\t\\t\\tsuf[i]=suf[i+1]+l[i]\\n\\t\\tans=0\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif(s[i]==\\\"o\\\"):\\n\\t\\t\\t\\tif(i-1>=0 and i+1<n):\\n\\t\\t\\t\\t\\tans+=pre[i-1]*suf[i+1]\\n\\t\\tprint(ans)\\n\\ndef __starting_point():\\n\\tsolve ()\\n__starting_point()\", \"s=str(input())\\narr1=[]\\narr2=[]\\ncountx=0\\ni=0\\nwhile(i<len(s)):\\n\\tif(s[i]=='o'):\\n\\t\\tarr1.append(countx)\\n\\t\\ti+=1\\n\\telse:\\n\\t\\tj=i\\n\\t\\twhile(j<len(s) and s[j]=='v'):\\n\\t\\t\\tj+=1\\n\\t\\tdiff=j-i\\n\\t\\tcountx+=(diff-1)\\n\\t\\ti=j\\nans=0\\n#print(*arr1)\\nfor i in range(len(arr1)):\\n\\tans+=(arr1[i]*(countx-(arr1[i])))\\n\\nprint(ans)\", \"# @author \\n\\nimport sys\\n\\nclass BWOWFactor:\\n    def solve(self):\\n        s = input()\\n        n = len(s)\\n        vv_pre = [0] * (n + 1)\\n        vv_suf = [0] * (n + 1)\\n\\n        for i in range(n - 1):\\n            vv_pre[i + 1] = vv_pre[i]\\n            if s[i] == s[i + 1] == 'v':\\n                vv_pre[i + 1] += 1\\n\\n        for i in range(n - 1, 0, -1):\\n            vv_suf[i - 1] = vv_suf[i]\\n            if s[i] == s[i - 1] == 'v':\\n                vv_suf[i - 1] += 1\\n\\n\\n        ans = 0\\n        for i in range(2, n - 2):\\n            if s[i] == 'o':\\n                ans += vv_pre[i - 1] * vv_suf[i + 1]\\n\\n        \\n        print(ans)\\n\\nsolver = BWOWFactor()\\ninput = sys.stdin.readline\\n\\nsolver.solve()\\n\", \"s = input()\\nwtot = 0\\nfor i in range(1, len(s)):\\n    if s[i] == 'v' and s[i-1] == 'v':\\n        wtot += 1\\nwleft = 0\\nans = 0\\nfor i in range(len(s)):\\n    if i > 0 and s[i] == 'v' and s[i-1] == 'v':\\n        wleft += 1\\n    elif s[i] == 'o':\\n        ans += wleft*(wtot-wleft)\\nprint(ans)\", \"ll= lambda : list(map(int,input().split()))\\ntestcases=1\\n# testcases=int(input())\\nfor testcase in range(testcases):\\n\\ts=input()\\n\\tn=len(s)\\n\\tdp=[0]\\n\\t# print(dp)\\n\\tfor i in range(n-1):\\n\\t\\tif s[i]=='v' and s[i+1]=='v':\\n\\t\\t\\tdp.append(dp[-1]+1)\\n\\t\\telse:\\n\\t\\t\\tdp.append(dp[-1])\\n\\t# print(dp)\\n\\tans=0\\n\\tfor i in range(0,n):\\n\\t\\tif s[i]=='o':\\n\\t\\t\\tans+=(dp[i]*(dp[-1]-dp[i]))\\n\\tprint(ans)\\n\\n\", \"s = input()\\ns = s.strip('o')\\nv = []\\no = []\\n\\ncnt_v = 0\\ncnt_o = 0\\nfor i in range(len(s)):\\n    if s[i] == 'v':\\n        if cnt_o:\\n            o.append(cnt_o)\\n            cnt_o = 0\\n        cnt_v += 1\\n    else:\\n        if cnt_v:\\n            v.append(cnt_v)\\n            cnt_v = 0\\n        cnt_o += 1\\n\\nv.append(cnt_v)\\n\\nleft = v[0]\\nleft_cnt = 1\\nans = 0\\nall_v = sum(v)\\nlen_v = len(v)\\n\\nfor i in range(len(o)):\\n    ans += (left - left_cnt) * o[i] * (all_v - left - len_v + left_cnt)\\n    left += v[i + 1]\\n    left_cnt += 1\\n\\nprint(ans)\\n\", \"s = input()\\nans = 0\\narr = s.split('o')\\nwsall = 0\\nfor i in arr:\\n    if len(i)>1:\\n        wsall+=len(i)-1\\nws=0\\nfor i in range(len(arr)-1):\\n    if len(arr[i])>1:\\n        ws+=len(arr[i])-1\\n        wsall-=(len(arr[i])-1)\\n    ans += ws * wsall\\nprint(ans)\\n\\n\\n\\n\", \"s = input().split()[0]\\nwos = []\\n\\nsum_w = 0\\nsum_o = 0\\nfor i in range(len(s)):\\n    if s[i] == 'o':\\n        wos.append(sum_w + (0 if len(wos) == 0 else wos[-1]))\\n        sum_o += 1\\n    elif s[i] == 'v':\\n        wos.append(0 if len(wos) == 0 else wos[-1])\\n        if i == 0 or s[i - 1] != 'v':\\n            pass\\n        else:\\n            sum_w += 1\\n\\nanswer = 0\\nfor i in range(len(s)):\\n    if s[i] == 'o':\\n        pass\\n    elif s[i] == 'v':\\n        if i == 0 or s[i - 1] != 'v':\\n            pass\\n        else:\\n            answer += wos[i]\\n\\nprint(answer)\", \"from sys import stdin\\n\\ns=stdin.readline().strip()\\nn=len(s)\\nl=[0 for i in range(n)]\\nr=[0 for i in range(n)]\\ndef cal(x):\\n    return (x*(x-1))//2\\nfor i in range(n):\\n    if i==0:\\n        continue\\n    if s[i]==\\\"v\\\" and s[i-1]==\\\"v\\\":\\n        l[i]+=1\\n    l[i]+=l[i-1]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        continue\\n    if s[i]==\\\"v\\\" and s[i+1]==\\\"v\\\":\\n        r[i]+=1\\n    r[i]+=r[i+1]\\nans=0\\nfor i in range(n):\\n    if s[i]==\\\"o\\\":\\n        ans+=l[i]*r[i]\\nprint(ans)\\n    \\n\", \"s = input()\\nn = len(s)\\ncount_o = []\\ncount_w = 0\\ncount = 0\\nfor i in range(1, n):\\n    if s[i] == 'v' and s[i-1] == 'v':\\n        count_w += 1\\n    elif s[i] == 'o':\\n        count_o.append(count_w)\\nfor c in count_o:\\n    count += c * (count_w-c)\\nprint(count)\\n\", \"s = input()\\nn = len(s)\\n\\nfirst = [0]*n\\nlast = [0]*n\\n\\np = 0\\nc = 0\\nfor i in range(n):\\n    if s[i] == 'v':\\n        p += 1\\n    else:\\n        if p:\\n            c += p-1\\n        p = 0\\n    if s[i] == 'o':\\n        first[i] = c\\n\\np = 0\\nc = 0\\nfor i in range(n-1, -1, -1):\\n    if s[i] == 'v':\\n        p += 1\\n    else:\\n        if p:\\n            c += p-1\\n        p = 0\\n    if s[i] == 'o':\\n        last[i] = c\\n\\nresult = 0\\nfor i in range(n):\\n    if s[i] =='o':\\n        result += first[i]*last[i]\\n\\nprint(result)\", \"s=input()\\npre=[0]\\ncurr=-1\\nn=len(s)\\nfor i in range(1,n):\\n\\tif s[i]=='v' and s[i-1]=='v':\\n\\t\\tpre.append(pre[-1]+1)\\n\\telse:\\n\\t\\tpre.append(pre[-1])\\ncurr=0\\nans=0\\nfor i in range(n-2,-1,-1):\\n\\tif s[i]=='v' and s[i+1]=='v':\\n\\t\\tcurr+=1\\n\\telif s[i]=='o':\\n\\t\\tans+=(curr)*(pre[i])\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "voovovvvoo\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1178/B"
    },
    {
        "id": 1809,
        "task_id": 1656,
        "test_case_id": 11,
        "question": "Recall that string $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly zero or all) characters. For example, for the string $a$=\"wowwo\", the following strings are subsequences: \"wowwo\", \"wowo\", \"oo\", \"wow\", \"\", and others, but the following are not subsequences: \"owoo\", \"owwwo\", \"ooo\".\n\nThe wow factor of a string is the number of its subsequences equal to the word \"wow\". Bob wants to write a string that has a large wow factor. However, the \"w\" key on his keyboard is broken, so he types two \"v\"s instead. \n\nLittle did he realise that he may have introduced more \"w\"s than he thought. Consider for instance the string \"ww\". Bob would type it as \"vvvv\", but this string actually contains three occurrences of \"w\":   \"vvvv\"  \"vvvv\"  \"vvvv\" \n\nFor example, the wow factor of the word \"vvvovvv\" equals to four because there are four wows:  \"vvvovvv\"  \"vvvovvv\"  \"vvvovvv\"  \"vvvovvv\" \n\nNote that the subsequence \"vvvovvv\" does not count towards the wow factor, as the \"v\"s have to be consecutive.\n\nFor a given string $s$, compute and output its wow factor. Note that it is not guaranteed that it is possible to get $s$ from another string replacing \"w\" with \"vv\". For example, $s$ can be equal to \"vov\".\n\n\n-----Input-----\n\nThe input contains a single non-empty string $s$, consisting only of characters \"v\" and \"o\". The length of $s$ is at most $10^6$.\n\n\n-----Output-----\n\nOutput a single integer, the wow factor of $s$.\n\n\n-----Examples-----\nInput\nvvvovvv\n\nOutput\n4\n\nInput\nvvovooovovvovoovoovvvvovovvvov\n\nOutput\n100\n\n\n\n-----Note-----\n\nThe first example is explained in the legend.",
        "solutions": "[\"s = input()\\nn = len(s)\\np = [0] * (n+1)\\nfor x in range(1, n):\\n\\ty = 0\\n\\tif s[x] == 'v' and s[x-1] == 'v':\\n\\t\\ty = 1\\n\\tp[x+1] = p[x] + y\\nq = 0\\nsol = 0\\nfor x in range(n-3, -1, -1):\\n\\tif s[x+1] == 'v' and s[x+2] == 'v':\\n\\t\\tq += 1\\n\\tif s[x] == 'o':\\n\\t\\tsol += q*p[x]\\nprint(sol)\\n\", \"s = input()\\nn = len(s)\\n\\nout = 0\\nwCount = 0\\noPlace = []\\nfor i in range(n-1):\\n    if s[i] == 'o':\\n        oPlace.append(wCount)\\n    elif s[i] == 'v' and s[i+1] == 'v':\\n        wCount += 1\\n\\nprint(sum([x*(wCount-x) for x in oPlace]))\\n\", \"s=[max(0,len(x)-1) for x in input().split('o')]\\nR=sum(s)\\nL=0\\nans=0\\nfor x in s:\\n    L+=x\\n    R-=x\\n    ans+=L*R\\n    \\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\ns=input().strip()\\nANS=0\\nBEFORE=0\\nOCOUNT=0\\n\\nLEN=len(s)\\n\\nfor i in range(1,LEN):\\n    if s[i]==\\\"v\\\" and s[i-1]==\\\"v\\\":\\n        BEFORE+=1\\n\\n        ANS+=OCOUNT\\n\\n    if s[i]==\\\"o\\\":\\n        OCOUNT+=BEFORE\\n\\nprint(ANS)\\n\\n    \\n\", \"from itertools import accumulate\\n\\nv = ord('v')\\no = ord('o')\\nS = [o]+[ord(s) for s in input().strip()]\\n\\nstack = []\\npre = None\\ncnt = 0\\nfor s in S:\\n    if s == pre:\\n        cnt += 1\\n    else:\\n        pre = s\\n        stack.append(cnt)\\n        cnt = 1\\nstack.append(cnt)\\nstack = stack[1:]\\n\\nLS = len(stack)\\nw = 0\\nsp = [stack[i]-1 if i % 2 else 0 for i in range(LS)]\\nsr = list(accumulate(sp))\\nsl = list(accumulate(sp[::-1]))[::-1]\\nans = 0\\nfor i in range(0, LS, 2):\\n    ans += sr[i]*sl[i]*stack[i]\\nprint(ans)\\n\", \"import sys\\n\\ns = sys.stdin.readline().strip()\\nn = len(s)\\n\\nw = 0\\nwo = 0\\nwow = 0\\n\\nfor i in range (1, n):\\n    if s[i] == \\\"v\\\" and s[i-1] == \\\"v\\\":\\n        w = w + 1\\n        wow = wow + wo\\n    if s[i] == \\\"o\\\":\\n        wo = wo + w\\n\\nprint(wow)\", \"s = input()\\nl, n = [], len(s)\\ni = 0\\nwhile i < n:\\n    j = i\\n    while j < n and s[j] == 'v':\\n        j += 1\\n    l.append(max(j - i - 1, 0))\\n    i = j\\n    while j < n and s[j] == 'o':\\n        j += 1\\n    l.append(j - i)\\n    i = j\\ndp = [0, 0, 0]\\nfor i in range(len(l)):\\n    if i & 1:\\n        dp[1] += dp[0] * l[i]\\n    else:\\n        dp[2] += dp[1] * l[i]\\n        dp[0] += l[i]\\n# print(*l)\\nprint(dp[-1])\", \"s = input()\\nN = len(s)\\nd1 = [0] * N\\nd2 = [0] * N\\nfor i in range(N - 1):\\n    if s[i: i + 2] == 'vv':\\n        d1[i] += 1\\n\\nfor i in range(1, N):\\n    d1[i] += d1[i - 1]\\n\\nfor i in range(N - 1, 0, -1):\\n    if s[i] == 'v' and s[i - 1] == 'v':\\n        d2[i] = 1\\n\\nfor i in range(N - 2, -1, -1):\\n    d2[i] += d2[i + 1]\\n\\nans = 0\\nfor i in range(N):\\n    if s[i] == 'o':\\n        ans += d1[i] * d2[i]\\n\\nprint(ans)\", \"s = input()\\nw, wo, wow = 0, 0, 0\\nlast = None\\nfor c in s:\\n    if c == 'v' and last == 'v':\\n        w += 1\\n        wow += wo\\n    elif c == 'o':\\n        wo += w\\n    last = c\\n\\nprint( wow )\\n\", \"s = input()\\n\\nn = len(s)\\n\\nldp = [0 for i in range(n)]\\nrdp = [0 for i in range(n)]\\n\\nconsec = 0\\nfor i in range(n):\\n    if(s[i] == 'v'):\\n        consec += 1\\n    else:\\n        consec = 0\\n    if(consec > 1):\\n        ldp[i] = ldp[i - 1] + 1\\n    else:\\n        ldp[i] = ldp[i - 1]\\nconsec = (s[-1] == 'v')\\nfor i in range(n-2, -1, -1):\\n    if(s[i] == 'v'):\\n        consec += 1\\n    else:\\n        consec = 0\\n    if(consec > 1):\\n        rdp[i] = rdp[i + 1] + 1\\n    else:\\n        rdp[i] = rdp[i + 1]\\nans = 0\\n#print(ldp)\\n#print(rdp)\\nfor i in range(n):\\n    if(s[i] == 'o'):\\n        ans += ldp[i] * rdp[i]\\n\\nprint(ans)\\n\\n\", \"s = input()\\nprev = \\\"\\\"\\ncnt = 0\\nfor elem in s:\\n    if elem == \\\"v\\\" and prev == \\\"v\\\":\\n        cnt += 1\\n    prev = elem\\nn = 0\\nprev = \\\"\\\"\\nans = 0\\nfor elem in s:\\n    if elem == \\\"v\\\" and prev == \\\"v\\\":\\n        n += 1\\n    if elem == \\\"o\\\":\\n        ans += n*(cnt-n)\\n    prev = elem\\nprint(ans)\", \"3\\n\\nimport math\\nimport sys\\n\\n\\nDEBUG = False\\n\\n\\ndef inp():\\n    return sys.stdin.readline().rstrip()\\n\\n\\ndef dprint(*value, sep=' ', end='\\\\n'):\\n    if DEBUG:\\n        print(*value, sep=sep, end=end)\\n\\n\\ndef solve(S):\\n    vv = 0\\n    o = 0\\n    cnt = 0\\n\\n    N = len(S)\\n    for i in range(N):\\n        if S[i:i + 2] == 'vv':\\n            cnt += o\\n            vv += 1\\n        elif S[i] == 'o':\\n            o += vv\\n\\n    return cnt\\n\\n\\ndef main():\\n    S = inp()\\n    print(solve(S))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"s = input()\\nwcount = 0\\nfor i in range(len(s)-1):\\n    if s[i+1] == \\\"v\\\" and s[i] == \\\"v\\\":\\n        wcount += 1\\n\\nans = 0\\nwcountl = 0\\nfor i in range(len(s)-1):\\n    if s[i+1] == \\\"v\\\" and s[i] == \\\"v\\\":\\n        wcountl += 1\\n        wcount -= 1\\n    elif s[i+1] == \\\"o\\\":\\n        ans += wcountl*wcount\\n\\nprint(ans)\\n\", \"import io, sys, atexit, os\\nimport math as ma\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\nfrom itertools import combinations\\n\\n\\ndef li ():\\n\\treturn list (map (int, input ().split ()))\\n\\n\\ndef num ():\\n\\treturn map (int, input ().split ())\\n\\n\\ndef nu ():\\n\\treturn int (input ())\\n\\n\\ndef find_gcd ( x, y ):\\n\\twhile (y):\\n\\t\\tx, y = y, x % y\\n\\treturn x\\n\\n\\ndef lcm ( x, y ):\\n\\tgg = find_gcd (x, y)\\n\\treturn (x * y // gg)\\n\\n\\nmm = 1000000007\\nyp = 0\\ndef solve ():\\n\\tt = 1\\n\\tfor tt in range (t):\\n\\t\\ts=input()\\n\\t\\tn=len(s)\\n\\t\\tl=[0]*n\\n\\t\\tfor i in range(n-1):\\n\\t\\t\\tif(s[i]==s[i+1] and s[i]==\\\"v\\\"):\\n\\t\\t\\t\\tl[i]=1\\n\\t\\tpre=[0]*n\\n\\t\\tsuf=[0]*n\\n\\t\\tpre[0]=l[0]\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tpre[i]=pre[i-1]+l[i]\\n\\t\\tsuf[n-1]=l[n-1]\\n\\t\\tfor i in range(n-2,-1,-1):\\n\\t\\t\\tsuf[i]=suf[i+1]+l[i]\\n\\t\\tans=0\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif(s[i]==\\\"o\\\"):\\n\\t\\t\\t\\tif(i-1>=0 and i+1<n):\\n\\t\\t\\t\\t\\tans+=pre[i-1]*suf[i+1]\\n\\t\\tprint(ans)\\n\\ndef __starting_point():\\n\\tsolve ()\\n__starting_point()\", \"s=str(input())\\narr1=[]\\narr2=[]\\ncountx=0\\ni=0\\nwhile(i<len(s)):\\n\\tif(s[i]=='o'):\\n\\t\\tarr1.append(countx)\\n\\t\\ti+=1\\n\\telse:\\n\\t\\tj=i\\n\\t\\twhile(j<len(s) and s[j]=='v'):\\n\\t\\t\\tj+=1\\n\\t\\tdiff=j-i\\n\\t\\tcountx+=(diff-1)\\n\\t\\ti=j\\nans=0\\n#print(*arr1)\\nfor i in range(len(arr1)):\\n\\tans+=(arr1[i]*(countx-(arr1[i])))\\n\\nprint(ans)\", \"# @author \\n\\nimport sys\\n\\nclass BWOWFactor:\\n    def solve(self):\\n        s = input()\\n        n = len(s)\\n        vv_pre = [0] * (n + 1)\\n        vv_suf = [0] * (n + 1)\\n\\n        for i in range(n - 1):\\n            vv_pre[i + 1] = vv_pre[i]\\n            if s[i] == s[i + 1] == 'v':\\n                vv_pre[i + 1] += 1\\n\\n        for i in range(n - 1, 0, -1):\\n            vv_suf[i - 1] = vv_suf[i]\\n            if s[i] == s[i - 1] == 'v':\\n                vv_suf[i - 1] += 1\\n\\n\\n        ans = 0\\n        for i in range(2, n - 2):\\n            if s[i] == 'o':\\n                ans += vv_pre[i - 1] * vv_suf[i + 1]\\n\\n        \\n        print(ans)\\n\\nsolver = BWOWFactor()\\ninput = sys.stdin.readline\\n\\nsolver.solve()\\n\", \"s = input()\\nwtot = 0\\nfor i in range(1, len(s)):\\n    if s[i] == 'v' and s[i-1] == 'v':\\n        wtot += 1\\nwleft = 0\\nans = 0\\nfor i in range(len(s)):\\n    if i > 0 and s[i] == 'v' and s[i-1] == 'v':\\n        wleft += 1\\n    elif s[i] == 'o':\\n        ans += wleft*(wtot-wleft)\\nprint(ans)\", \"ll= lambda : list(map(int,input().split()))\\ntestcases=1\\n# testcases=int(input())\\nfor testcase in range(testcases):\\n\\ts=input()\\n\\tn=len(s)\\n\\tdp=[0]\\n\\t# print(dp)\\n\\tfor i in range(n-1):\\n\\t\\tif s[i]=='v' and s[i+1]=='v':\\n\\t\\t\\tdp.append(dp[-1]+1)\\n\\t\\telse:\\n\\t\\t\\tdp.append(dp[-1])\\n\\t# print(dp)\\n\\tans=0\\n\\tfor i in range(0,n):\\n\\t\\tif s[i]=='o':\\n\\t\\t\\tans+=(dp[i]*(dp[-1]-dp[i]))\\n\\tprint(ans)\\n\\n\", \"s = input()\\ns = s.strip('o')\\nv = []\\no = []\\n\\ncnt_v = 0\\ncnt_o = 0\\nfor i in range(len(s)):\\n    if s[i] == 'v':\\n        if cnt_o:\\n            o.append(cnt_o)\\n            cnt_o = 0\\n        cnt_v += 1\\n    else:\\n        if cnt_v:\\n            v.append(cnt_v)\\n            cnt_v = 0\\n        cnt_o += 1\\n\\nv.append(cnt_v)\\n\\nleft = v[0]\\nleft_cnt = 1\\nans = 0\\nall_v = sum(v)\\nlen_v = len(v)\\n\\nfor i in range(len(o)):\\n    ans += (left - left_cnt) * o[i] * (all_v - left - len_v + left_cnt)\\n    left += v[i + 1]\\n    left_cnt += 1\\n\\nprint(ans)\\n\", \"s = input()\\nans = 0\\narr = s.split('o')\\nwsall = 0\\nfor i in arr:\\n    if len(i)>1:\\n        wsall+=len(i)-1\\nws=0\\nfor i in range(len(arr)-1):\\n    if len(arr[i])>1:\\n        ws+=len(arr[i])-1\\n        wsall-=(len(arr[i])-1)\\n    ans += ws * wsall\\nprint(ans)\\n\\n\\n\\n\", \"s = input().split()[0]\\nwos = []\\n\\nsum_w = 0\\nsum_o = 0\\nfor i in range(len(s)):\\n    if s[i] == 'o':\\n        wos.append(sum_w + (0 if len(wos) == 0 else wos[-1]))\\n        sum_o += 1\\n    elif s[i] == 'v':\\n        wos.append(0 if len(wos) == 0 else wos[-1])\\n        if i == 0 or s[i - 1] != 'v':\\n            pass\\n        else:\\n            sum_w += 1\\n\\nanswer = 0\\nfor i in range(len(s)):\\n    if s[i] == 'o':\\n        pass\\n    elif s[i] == 'v':\\n        if i == 0 or s[i - 1] != 'v':\\n            pass\\n        else:\\n            answer += wos[i]\\n\\nprint(answer)\", \"from sys import stdin\\n\\ns=stdin.readline().strip()\\nn=len(s)\\nl=[0 for i in range(n)]\\nr=[0 for i in range(n)]\\ndef cal(x):\\n    return (x*(x-1))//2\\nfor i in range(n):\\n    if i==0:\\n        continue\\n    if s[i]==\\\"v\\\" and s[i-1]==\\\"v\\\":\\n        l[i]+=1\\n    l[i]+=l[i-1]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        continue\\n    if s[i]==\\\"v\\\" and s[i+1]==\\\"v\\\":\\n        r[i]+=1\\n    r[i]+=r[i+1]\\nans=0\\nfor i in range(n):\\n    if s[i]==\\\"o\\\":\\n        ans+=l[i]*r[i]\\nprint(ans)\\n    \\n\", \"s = input()\\nn = len(s)\\ncount_o = []\\ncount_w = 0\\ncount = 0\\nfor i in range(1, n):\\n    if s[i] == 'v' and s[i-1] == 'v':\\n        count_w += 1\\n    elif s[i] == 'o':\\n        count_o.append(count_w)\\nfor c in count_o:\\n    count += c * (count_w-c)\\nprint(count)\\n\", \"s = input()\\nn = len(s)\\n\\nfirst = [0]*n\\nlast = [0]*n\\n\\np = 0\\nc = 0\\nfor i in range(n):\\n    if s[i] == 'v':\\n        p += 1\\n    else:\\n        if p:\\n            c += p-1\\n        p = 0\\n    if s[i] == 'o':\\n        first[i] = c\\n\\np = 0\\nc = 0\\nfor i in range(n-1, -1, -1):\\n    if s[i] == 'v':\\n        p += 1\\n    else:\\n        if p:\\n            c += p-1\\n        p = 0\\n    if s[i] == 'o':\\n        last[i] = c\\n\\nresult = 0\\nfor i in range(n):\\n    if s[i] =='o':\\n        result += first[i]*last[i]\\n\\nprint(result)\", \"s=input()\\npre=[0]\\ncurr=-1\\nn=len(s)\\nfor i in range(1,n):\\n\\tif s[i]=='v' and s[i-1]=='v':\\n\\t\\tpre.append(pre[-1]+1)\\n\\telse:\\n\\t\\tpre.append(pre[-1])\\ncurr=0\\nans=0\\nfor i in range(n-2,-1,-1):\\n\\tif s[i]=='v' and s[i+1]=='v':\\n\\t\\tcurr+=1\\n\\telif s[i]=='o':\\n\\t\\tans+=(curr)*(pre[i])\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "vovoovovvoovvvvvvovo\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1178/B"
    },
    {
        "id": 1810,
        "task_id": 1656,
        "test_case_id": 12,
        "question": "Recall that string $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly zero or all) characters. For example, for the string $a$=\"wowwo\", the following strings are subsequences: \"wowwo\", \"wowo\", \"oo\", \"wow\", \"\", and others, but the following are not subsequences: \"owoo\", \"owwwo\", \"ooo\".\n\nThe wow factor of a string is the number of its subsequences equal to the word \"wow\". Bob wants to write a string that has a large wow factor. However, the \"w\" key on his keyboard is broken, so he types two \"v\"s instead. \n\nLittle did he realise that he may have introduced more \"w\"s than he thought. Consider for instance the string \"ww\". Bob would type it as \"vvvv\", but this string actually contains three occurrences of \"w\":   \"vvvv\"  \"vvvv\"  \"vvvv\" \n\nFor example, the wow factor of the word \"vvvovvv\" equals to four because there are four wows:  \"vvvovvv\"  \"vvvovvv\"  \"vvvovvv\"  \"vvvovvv\" \n\nNote that the subsequence \"vvvovvv\" does not count towards the wow factor, as the \"v\"s have to be consecutive.\n\nFor a given string $s$, compute and output its wow factor. Note that it is not guaranteed that it is possible to get $s$ from another string replacing \"w\" with \"vv\". For example, $s$ can be equal to \"vov\".\n\n\n-----Input-----\n\nThe input contains a single non-empty string $s$, consisting only of characters \"v\" and \"o\". The length of $s$ is at most $10^6$.\n\n\n-----Output-----\n\nOutput a single integer, the wow factor of $s$.\n\n\n-----Examples-----\nInput\nvvvovvv\n\nOutput\n4\n\nInput\nvvovooovovvovoovoovvvvovovvvov\n\nOutput\n100\n\n\n\n-----Note-----\n\nThe first example is explained in the legend.",
        "solutions": "[\"s = input()\\nn = len(s)\\np = [0] * (n+1)\\nfor x in range(1, n):\\n\\ty = 0\\n\\tif s[x] == 'v' and s[x-1] == 'v':\\n\\t\\ty = 1\\n\\tp[x+1] = p[x] + y\\nq = 0\\nsol = 0\\nfor x in range(n-3, -1, -1):\\n\\tif s[x+1] == 'v' and s[x+2] == 'v':\\n\\t\\tq += 1\\n\\tif s[x] == 'o':\\n\\t\\tsol += q*p[x]\\nprint(sol)\\n\", \"s = input()\\nn = len(s)\\n\\nout = 0\\nwCount = 0\\noPlace = []\\nfor i in range(n-1):\\n    if s[i] == 'o':\\n        oPlace.append(wCount)\\n    elif s[i] == 'v' and s[i+1] == 'v':\\n        wCount += 1\\n\\nprint(sum([x*(wCount-x) for x in oPlace]))\\n\", \"s=[max(0,len(x)-1) for x in input().split('o')]\\nR=sum(s)\\nL=0\\nans=0\\nfor x in s:\\n    L+=x\\n    R-=x\\n    ans+=L*R\\n    \\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\ns=input().strip()\\nANS=0\\nBEFORE=0\\nOCOUNT=0\\n\\nLEN=len(s)\\n\\nfor i in range(1,LEN):\\n    if s[i]==\\\"v\\\" and s[i-1]==\\\"v\\\":\\n        BEFORE+=1\\n\\n        ANS+=OCOUNT\\n\\n    if s[i]==\\\"o\\\":\\n        OCOUNT+=BEFORE\\n\\nprint(ANS)\\n\\n    \\n\", \"from itertools import accumulate\\n\\nv = ord('v')\\no = ord('o')\\nS = [o]+[ord(s) for s in input().strip()]\\n\\nstack = []\\npre = None\\ncnt = 0\\nfor s in S:\\n    if s == pre:\\n        cnt += 1\\n    else:\\n        pre = s\\n        stack.append(cnt)\\n        cnt = 1\\nstack.append(cnt)\\nstack = stack[1:]\\n\\nLS = len(stack)\\nw = 0\\nsp = [stack[i]-1 if i % 2 else 0 for i in range(LS)]\\nsr = list(accumulate(sp))\\nsl = list(accumulate(sp[::-1]))[::-1]\\nans = 0\\nfor i in range(0, LS, 2):\\n    ans += sr[i]*sl[i]*stack[i]\\nprint(ans)\\n\", \"import sys\\n\\ns = sys.stdin.readline().strip()\\nn = len(s)\\n\\nw = 0\\nwo = 0\\nwow = 0\\n\\nfor i in range (1, n):\\n    if s[i] == \\\"v\\\" and s[i-1] == \\\"v\\\":\\n        w = w + 1\\n        wow = wow + wo\\n    if s[i] == \\\"o\\\":\\n        wo = wo + w\\n\\nprint(wow)\", \"s = input()\\nl, n = [], len(s)\\ni = 0\\nwhile i < n:\\n    j = i\\n    while j < n and s[j] == 'v':\\n        j += 1\\n    l.append(max(j - i - 1, 0))\\n    i = j\\n    while j < n and s[j] == 'o':\\n        j += 1\\n    l.append(j - i)\\n    i = j\\ndp = [0, 0, 0]\\nfor i in range(len(l)):\\n    if i & 1:\\n        dp[1] += dp[0] * l[i]\\n    else:\\n        dp[2] += dp[1] * l[i]\\n        dp[0] += l[i]\\n# print(*l)\\nprint(dp[-1])\", \"s = input()\\nN = len(s)\\nd1 = [0] * N\\nd2 = [0] * N\\nfor i in range(N - 1):\\n    if s[i: i + 2] == 'vv':\\n        d1[i] += 1\\n\\nfor i in range(1, N):\\n    d1[i] += d1[i - 1]\\n\\nfor i in range(N - 1, 0, -1):\\n    if s[i] == 'v' and s[i - 1] == 'v':\\n        d2[i] = 1\\n\\nfor i in range(N - 2, -1, -1):\\n    d2[i] += d2[i + 1]\\n\\nans = 0\\nfor i in range(N):\\n    if s[i] == 'o':\\n        ans += d1[i] * d2[i]\\n\\nprint(ans)\", \"s = input()\\nw, wo, wow = 0, 0, 0\\nlast = None\\nfor c in s:\\n    if c == 'v' and last == 'v':\\n        w += 1\\n        wow += wo\\n    elif c == 'o':\\n        wo += w\\n    last = c\\n\\nprint( wow )\\n\", \"s = input()\\n\\nn = len(s)\\n\\nldp = [0 for i in range(n)]\\nrdp = [0 for i in range(n)]\\n\\nconsec = 0\\nfor i in range(n):\\n    if(s[i] == 'v'):\\n        consec += 1\\n    else:\\n        consec = 0\\n    if(consec > 1):\\n        ldp[i] = ldp[i - 1] + 1\\n    else:\\n        ldp[i] = ldp[i - 1]\\nconsec = (s[-1] == 'v')\\nfor i in range(n-2, -1, -1):\\n    if(s[i] == 'v'):\\n        consec += 1\\n    else:\\n        consec = 0\\n    if(consec > 1):\\n        rdp[i] = rdp[i + 1] + 1\\n    else:\\n        rdp[i] = rdp[i + 1]\\nans = 0\\n#print(ldp)\\n#print(rdp)\\nfor i in range(n):\\n    if(s[i] == 'o'):\\n        ans += ldp[i] * rdp[i]\\n\\nprint(ans)\\n\\n\", \"s = input()\\nprev = \\\"\\\"\\ncnt = 0\\nfor elem in s:\\n    if elem == \\\"v\\\" and prev == \\\"v\\\":\\n        cnt += 1\\n    prev = elem\\nn = 0\\nprev = \\\"\\\"\\nans = 0\\nfor elem in s:\\n    if elem == \\\"v\\\" and prev == \\\"v\\\":\\n        n += 1\\n    if elem == \\\"o\\\":\\n        ans += n*(cnt-n)\\n    prev = elem\\nprint(ans)\", \"3\\n\\nimport math\\nimport sys\\n\\n\\nDEBUG = False\\n\\n\\ndef inp():\\n    return sys.stdin.readline().rstrip()\\n\\n\\ndef dprint(*value, sep=' ', end='\\\\n'):\\n    if DEBUG:\\n        print(*value, sep=sep, end=end)\\n\\n\\ndef solve(S):\\n    vv = 0\\n    o = 0\\n    cnt = 0\\n\\n    N = len(S)\\n    for i in range(N):\\n        if S[i:i + 2] == 'vv':\\n            cnt += o\\n            vv += 1\\n        elif S[i] == 'o':\\n            o += vv\\n\\n    return cnt\\n\\n\\ndef main():\\n    S = inp()\\n    print(solve(S))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"s = input()\\nwcount = 0\\nfor i in range(len(s)-1):\\n    if s[i+1] == \\\"v\\\" and s[i] == \\\"v\\\":\\n        wcount += 1\\n\\nans = 0\\nwcountl = 0\\nfor i in range(len(s)-1):\\n    if s[i+1] == \\\"v\\\" and s[i] == \\\"v\\\":\\n        wcountl += 1\\n        wcount -= 1\\n    elif s[i+1] == \\\"o\\\":\\n        ans += wcountl*wcount\\n\\nprint(ans)\\n\", \"import io, sys, atexit, os\\nimport math as ma\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\nfrom itertools import combinations\\n\\n\\ndef li ():\\n\\treturn list (map (int, input ().split ()))\\n\\n\\ndef num ():\\n\\treturn map (int, input ().split ())\\n\\n\\ndef nu ():\\n\\treturn int (input ())\\n\\n\\ndef find_gcd ( x, y ):\\n\\twhile (y):\\n\\t\\tx, y = y, x % y\\n\\treturn x\\n\\n\\ndef lcm ( x, y ):\\n\\tgg = find_gcd (x, y)\\n\\treturn (x * y // gg)\\n\\n\\nmm = 1000000007\\nyp = 0\\ndef solve ():\\n\\tt = 1\\n\\tfor tt in range (t):\\n\\t\\ts=input()\\n\\t\\tn=len(s)\\n\\t\\tl=[0]*n\\n\\t\\tfor i in range(n-1):\\n\\t\\t\\tif(s[i]==s[i+1] and s[i]==\\\"v\\\"):\\n\\t\\t\\t\\tl[i]=1\\n\\t\\tpre=[0]*n\\n\\t\\tsuf=[0]*n\\n\\t\\tpre[0]=l[0]\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tpre[i]=pre[i-1]+l[i]\\n\\t\\tsuf[n-1]=l[n-1]\\n\\t\\tfor i in range(n-2,-1,-1):\\n\\t\\t\\tsuf[i]=suf[i+1]+l[i]\\n\\t\\tans=0\\n\\t\\tfor i in range(n):\\n\\t\\t\\tif(s[i]==\\\"o\\\"):\\n\\t\\t\\t\\tif(i-1>=0 and i+1<n):\\n\\t\\t\\t\\t\\tans+=pre[i-1]*suf[i+1]\\n\\t\\tprint(ans)\\n\\ndef __starting_point():\\n\\tsolve ()\\n__starting_point()\", \"s=str(input())\\narr1=[]\\narr2=[]\\ncountx=0\\ni=0\\nwhile(i<len(s)):\\n\\tif(s[i]=='o'):\\n\\t\\tarr1.append(countx)\\n\\t\\ti+=1\\n\\telse:\\n\\t\\tj=i\\n\\t\\twhile(j<len(s) and s[j]=='v'):\\n\\t\\t\\tj+=1\\n\\t\\tdiff=j-i\\n\\t\\tcountx+=(diff-1)\\n\\t\\ti=j\\nans=0\\n#print(*arr1)\\nfor i in range(len(arr1)):\\n\\tans+=(arr1[i]*(countx-(arr1[i])))\\n\\nprint(ans)\", \"# @author \\n\\nimport sys\\n\\nclass BWOWFactor:\\n    def solve(self):\\n        s = input()\\n        n = len(s)\\n        vv_pre = [0] * (n + 1)\\n        vv_suf = [0] * (n + 1)\\n\\n        for i in range(n - 1):\\n            vv_pre[i + 1] = vv_pre[i]\\n            if s[i] == s[i + 1] == 'v':\\n                vv_pre[i + 1] += 1\\n\\n        for i in range(n - 1, 0, -1):\\n            vv_suf[i - 1] = vv_suf[i]\\n            if s[i] == s[i - 1] == 'v':\\n                vv_suf[i - 1] += 1\\n\\n\\n        ans = 0\\n        for i in range(2, n - 2):\\n            if s[i] == 'o':\\n                ans += vv_pre[i - 1] * vv_suf[i + 1]\\n\\n        \\n        print(ans)\\n\\nsolver = BWOWFactor()\\ninput = sys.stdin.readline\\n\\nsolver.solve()\\n\", \"s = input()\\nwtot = 0\\nfor i in range(1, len(s)):\\n    if s[i] == 'v' and s[i-1] == 'v':\\n        wtot += 1\\nwleft = 0\\nans = 0\\nfor i in range(len(s)):\\n    if i > 0 and s[i] == 'v' and s[i-1] == 'v':\\n        wleft += 1\\n    elif s[i] == 'o':\\n        ans += wleft*(wtot-wleft)\\nprint(ans)\", \"ll= lambda : list(map(int,input().split()))\\ntestcases=1\\n# testcases=int(input())\\nfor testcase in range(testcases):\\n\\ts=input()\\n\\tn=len(s)\\n\\tdp=[0]\\n\\t# print(dp)\\n\\tfor i in range(n-1):\\n\\t\\tif s[i]=='v' and s[i+1]=='v':\\n\\t\\t\\tdp.append(dp[-1]+1)\\n\\t\\telse:\\n\\t\\t\\tdp.append(dp[-1])\\n\\t# print(dp)\\n\\tans=0\\n\\tfor i in range(0,n):\\n\\t\\tif s[i]=='o':\\n\\t\\t\\tans+=(dp[i]*(dp[-1]-dp[i]))\\n\\tprint(ans)\\n\\n\", \"s = input()\\ns = s.strip('o')\\nv = []\\no = []\\n\\ncnt_v = 0\\ncnt_o = 0\\nfor i in range(len(s)):\\n    if s[i] == 'v':\\n        if cnt_o:\\n            o.append(cnt_o)\\n            cnt_o = 0\\n        cnt_v += 1\\n    else:\\n        if cnt_v:\\n            v.append(cnt_v)\\n            cnt_v = 0\\n        cnt_o += 1\\n\\nv.append(cnt_v)\\n\\nleft = v[0]\\nleft_cnt = 1\\nans = 0\\nall_v = sum(v)\\nlen_v = len(v)\\n\\nfor i in range(len(o)):\\n    ans += (left - left_cnt) * o[i] * (all_v - left - len_v + left_cnt)\\n    left += v[i + 1]\\n    left_cnt += 1\\n\\nprint(ans)\\n\", \"s = input()\\nans = 0\\narr = s.split('o')\\nwsall = 0\\nfor i in arr:\\n    if len(i)>1:\\n        wsall+=len(i)-1\\nws=0\\nfor i in range(len(arr)-1):\\n    if len(arr[i])>1:\\n        ws+=len(arr[i])-1\\n        wsall-=(len(arr[i])-1)\\n    ans += ws * wsall\\nprint(ans)\\n\\n\\n\\n\", \"s = input().split()[0]\\nwos = []\\n\\nsum_w = 0\\nsum_o = 0\\nfor i in range(len(s)):\\n    if s[i] == 'o':\\n        wos.append(sum_w + (0 if len(wos) == 0 else wos[-1]))\\n        sum_o += 1\\n    elif s[i] == 'v':\\n        wos.append(0 if len(wos) == 0 else wos[-1])\\n        if i == 0 or s[i - 1] != 'v':\\n            pass\\n        else:\\n            sum_w += 1\\n\\nanswer = 0\\nfor i in range(len(s)):\\n    if s[i] == 'o':\\n        pass\\n    elif s[i] == 'v':\\n        if i == 0 or s[i - 1] != 'v':\\n            pass\\n        else:\\n            answer += wos[i]\\n\\nprint(answer)\", \"from sys import stdin\\n\\ns=stdin.readline().strip()\\nn=len(s)\\nl=[0 for i in range(n)]\\nr=[0 for i in range(n)]\\ndef cal(x):\\n    return (x*(x-1))//2\\nfor i in range(n):\\n    if i==0:\\n        continue\\n    if s[i]==\\\"v\\\" and s[i-1]==\\\"v\\\":\\n        l[i]+=1\\n    l[i]+=l[i-1]\\nfor i in range(n-1,-1,-1):\\n    if i==n-1:\\n        continue\\n    if s[i]==\\\"v\\\" and s[i+1]==\\\"v\\\":\\n        r[i]+=1\\n    r[i]+=r[i+1]\\nans=0\\nfor i in range(n):\\n    if s[i]==\\\"o\\\":\\n        ans+=l[i]*r[i]\\nprint(ans)\\n    \\n\", \"s = input()\\nn = len(s)\\ncount_o = []\\ncount_w = 0\\ncount = 0\\nfor i in range(1, n):\\n    if s[i] == 'v' and s[i-1] == 'v':\\n        count_w += 1\\n    elif s[i] == 'o':\\n        count_o.append(count_w)\\nfor c in count_o:\\n    count += c * (count_w-c)\\nprint(count)\\n\", \"s = input()\\nn = len(s)\\n\\nfirst = [0]*n\\nlast = [0]*n\\n\\np = 0\\nc = 0\\nfor i in range(n):\\n    if s[i] == 'v':\\n        p += 1\\n    else:\\n        if p:\\n            c += p-1\\n        p = 0\\n    if s[i] == 'o':\\n        first[i] = c\\n\\np = 0\\nc = 0\\nfor i in range(n-1, -1, -1):\\n    if s[i] == 'v':\\n        p += 1\\n    else:\\n        if p:\\n            c += p-1\\n        p = 0\\n    if s[i] == 'o':\\n        last[i] = c\\n\\nresult = 0\\nfor i in range(n):\\n    if s[i] =='o':\\n        result += first[i]*last[i]\\n\\nprint(result)\", \"s=input()\\npre=[0]\\ncurr=-1\\nn=len(s)\\nfor i in range(1,n):\\n\\tif s[i]=='v' and s[i-1]=='v':\\n\\t\\tpre.append(pre[-1]+1)\\n\\telse:\\n\\t\\tpre.append(pre[-1])\\ncurr=0\\nans=0\\nfor i in range(n-2,-1,-1):\\n\\tif s[i]=='v' and s[i+1]=='v':\\n\\t\\tcurr+=1\\n\\telif s[i]=='o':\\n\\t\\tans+=(curr)*(pre[i])\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "ovvvvovovvvvovoovovovovvvvvvvoovoovvovvoooooovo\n",
        "output": "463\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1178/B"
    },
    {
        "id": 1811,
        "task_id": 1662,
        "test_case_id": 1,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5\n1 2 3 4 5\n",
        "output": "5\n5 4 3 2 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1812,
        "task_id": 1662,
        "test_case_id": 2,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "6\n1 1 2 2 3 3\n",
        "output": "5\n1 2 3 2 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1813,
        "task_id": 1662,
        "test_case_id": 3,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "47\n3 4 5 3 1 4 4 3 4 6 1 5 1 3 5 3 6 5 1 4 3 2 6 5 3 1 4 6 4 6 2 1 1 1 4 3 6 1 6 6 3 5 1 4 6 4 4\n",
        "output": "11\n1 2 3 4 5 6 5 4 3 2 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1814,
        "task_id": 1662,
        "test_case_id": 4,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "13\n8 23 26 8 15 13 35 36 28 8 4 33 6\n",
        "output": "12\n8 36 35 33 28 26 23 15 13 8 6 4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1815,
        "task_id": 1662,
        "test_case_id": 5,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "17\n15 29 28 23 20 12 9 30 4 13 1 25 11 20 6 23 10\n",
        "output": "17\n20 23 30 29 28 25 23 20 15 13 12 11 10 9 6 4 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1816,
        "task_id": 1662,
        "test_case_id": 6,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "31\n189 73 300 133 414 23 150 301 252 21 274 272 316 291 339 356 201 267 257 43 10 25 16 211 59 2 181 54 344 337 201\n",
        "output": "31\n201 414 356 344 339 337 316 301 300 291 274 272 267 257 252 211 201 189 181 150 133 73 59 54 43 25 23 21 16 10 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1817,
        "task_id": 1662,
        "test_case_id": 7,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "85\n319 554 696 281 275 544 356 313 296 308 848 668 135 705 231 735 882 622 796 435 621 523 709 247 169 152 395 758 447 595 550 819 188 664 589 907 3 619 771 810 669 471 425 870 737 329 83 549 425 138 870 775 451 818 735 169 162 419 903 803 852 75 297 687 310 714 419 652 164 667 245 906 133 643 881 322 681 704 479 278 114 324 42 475 396\n",
        "output": "85\n169 419 425 735 870 907 906 903 882 881 870 852 848 819 818 810 803 796 775 771 758 737 735 714 709 705 704 696 687 681 669 668 667 664 652 643 622 621 619 595 589 554 550 549 544 523 479 475 471 451 447 435 425 419 396 395 356 329 324 322 319 313 310 308 297 296 281 278 275 247 245 231 188 169 164 162 152 138 135 133 114 83 75 42 3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1818,
        "task_id": 1662,
        "test_case_id": 8,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "102\n1830 2653 1293 4285 4679 3563 3668 4499 3507 2666 3507 1120 466 290 4280 60 4135 1120 289 1752 2101 2699 653 2811 3885 4018 4097 3142 2932 561 193 3662 3017 3487 3158 2876 3396 2806 3440 4503 1728 362 2194 2743 2946 596 1892 4785 3661 2971 3487 17 3616 2710 1189 613 915 3891 2654 554 3506 1938 2783 2537 4791 1098 930 1000 1007 942 3871 2547 1798 4610 1613 774 1347 1460 2752 3158 4540 4720 2639 887 1999 2046 1199 1889 426 1888 4317 649 1660 336 4728 2422 2771 3536 1683 3786 2711 308\n",
        "output": "102\n1120 3158 3487 3507 4791 4785 4728 4720 4679 4610 4540 4503 4499 4317 4285 4280 4135 4097 4018 3891 3885 3871 3786 3668 3662 3661 3616 3563 3536 3507 3506 3487 3440 3396 3158 3142 3017 2971 2946 2932 2876 2811 2806 2783 2771 2752 2743 2711 2710 2699 2666 2654 2653 2639 2547 2537 2422 2194 2101 2046 1999 1938 1892 1889 1888 1830 1798 1752 1728 1683 1660 1613 1460 1347 1293 1199 1189 1120 1098 1007 1000 942 930 915 887 774 653 649 613 596 561 554 466 426 362 336 308 290 289 193 60 17\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1819,
        "task_id": 1662,
        "test_case_id": 10,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2\n1 1\n",
        "output": "1\n1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1820,
        "task_id": 1662,
        "test_case_id": 11,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3\n1 2 3\n",
        "output": "3\n3 2 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1821,
        "task_id": 1662,
        "test_case_id": 12,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "3\n2 1 2\n",
        "output": "2\n2 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1822,
        "task_id": 1662,
        "test_case_id": 13,
        "question": "Sereja loves integer sequences very much. He especially likes stairs.\n\nSequence a_1, a_2, ..., a_{|}a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met: a_1 < a_2 < ... < a_{i} - 1 < a_{i} > a_{i} + 1 > ... > a_{|}a| - 1 > a_{|}a|.\n\nFor example, sequences [1, 2, 3, 2] and [4, 2] are stairs and sequence [3, 1, 2] isn't.\n\nSereja has m cards with numbers. He wants to put some cards on the table in a row to get a stair sequence. What maximum number of cards can he put on the table?\n\n\n-----Input-----\n\nThe first line contains integer m (1 ≤ m ≤ 10^5) — the number of Sereja's cards. The second line contains m integers b_{i} (1 ≤ b_{i} ≤ 5000) — the numbers on the Sereja's cards.\n\n\n-----Output-----\n\nIn the first line print the number of cards you can put on the table. In the second line print the resulting stairs.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n5 4 3 2 1\n\nInput\n6\n1 1 2 2 3 3\n\nOutput\n5\n1 2 3 2 1",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\ncount=[0]*(10**5+1)\\nfor i in a:\\n    count[i]+=1\\nans=[]\\nfor i in range(10**5+1):\\n    if count[i]:\\n        ans.append(i)\\n        count[i]-=1\\nif len(ans)!=n:\\n    for i in reversed(range(10**5+1)):\\n        if count[i] and ans[-1]!=i:\\n            ans.append(i)\\nprint(len(ans))\\nprint(*ans)\", \"n = int(input())\\nquant = [0] * 5001\\nnumbers = list(map(int, input().split()))\\nres = []\\nm = max(numbers)\\n\\nfor i in range(n):\\n    quant[numbers[i]] += 1\\n\\ni = 1\\n\\nwhile i < m:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i += 1\\nres.append(m)\\ni = m - 1\\nwhile i > 0:\\n    if quant[i] > 0:\\n        res.append(i)\\n        quant[i] -= 1\\n    i -= 1\\n    \\nprint(len(res))\\nprint(*res)\", \"n = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nb=[]\\nfor i in range(n-2):\\n    if not (a[i] == a[i+1] and a[i] == a[i+2]):\\n        b.append(a[i])\\nb.append(a[n-2])\\nb.append(a[n-1])\\nif b[-1] == b[-2]:\\n    b = b[:len(b)-1]\\nprint(len(b))\\nb1=[]\\nb2=[]\\nfor i in range(len(b)):\\n    if i % 2 == 0:\\n        b2.append(b[i])\\n    else:\\n        b1.append(b[i])\\nfor i in b1:\\n    print(i, end=' ')\\nb2.reverse()\\nfor i in b2:\\n    print(i, end=' ')\\n\", \"n = input()\\ncards = input().split(\\\" \\\")\\ncards = [int(cards[i]) for i in range(len(cards))]\\n\\nif len(cards) == len(list(set(cards))):\\n    print(n)\\n    cards.sort()\\n    for i in range(len(cards) - 1, 0, -1):\\n        print(cards[i], end=\\\" \\\")\\n    print(cards[0], end=\\\"\\\\n\\\")\\nelse:\\n    cards.sort()\\n    mycards = [cards[0]]\\n\\n    cards[0] = None\\n    for i in range(1, len(cards)):\\n        if cards[i] > mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    for i in range(len(cards) - 1, -1, -1):\\n        if cards[i] == None: continue\\n        \\n        if cards[i] < mycards[-1]:\\n            mycards.append(cards[i])\\n            cards[i] = None\\n\\n    print(len(mycards))\\n    for i in range(len(mycards) - 1):\\n        print(mycards[i], end=\\\" \\\")\\n    print(mycards[-1], end=\\\"\\\\n\\\")\\n\", \"import sys\\ndef main():\\n    l=sys.stdin.readline()\\n    l=sys.stdin.readline()\\n    numbers={}\\n    for el in l.split():\\n        el=int(el)\\n        try:\\n            numbers[el]=numbers[el]+1\\n        except KeyError:\\n            numbers[el]=1\\n        \\n    nr=numbers.keys()\\n    nr=sorted(list(set(nr)))\\n    \\n    count=0\\n    final=[]\\n    for n in nr:\\n        if numbers[n] > 0:\\n            final.append(n)\\n            numbers[n]-=1\\n            count+=1\\n    nr=sorted(nr,reverse=True)\\n    for n in nr:\\n        if n != final[-1]:\\n            if numbers[n] > 0:\\n                final.append(n)\\n                numbers[n]-=1\\n                count+=1\\n    print (count)\\n    for el in final[:-1]:\\n        print (el,end = \\\" \\\")\\n    print (final[-1])\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"__author__ = 'Adela'\\n\\n\\ndef main():\\n\\n    m = int(input())\\n    b = [0 for i in range(0, 5001)]\\n    res = []\\n    maxi = 0\\n\\n    for k in input().split():\\n        nr = int(k)\\n        b[nr] += 1\\n        if nr > maxi:\\n            maxi = nr\\n\\n    for i in range(0, maxi + 1):\\n        if b[i] != 0:\\n            res.append(i)\\n            b[i] -= 1\\n\\n    for j in range(maxi - 1, 0, -1):\\n        if b[j] != 0:\\n            res.append(j)\\n\\n    print(len(res))\\n    for k in res:\\n        print(k, end=' ')\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\ncards = list(map(int, input().split()))\\ncards.sort()\\nstair = []\\nstair_rev = []\\nstair.append(cards[0])\\ncards.pop(0)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] > stair[-1]:\\n        stair.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\ntmpmax = stair[-1]\\ncards.sort(reverse = True)\\na = 0\\nwhile a < len(cards):\\n    if cards[a] < tmpmax:\\n        tmpmax = cards[a]\\n        stair_rev.append(cards[a])\\n        cards.pop(a)\\n    else:\\n        a+= 1\\n            \\nstair += stair_rev\\nprint(len(stair))\\ns = ''\\nfor d in stair[0:-1]:\\n    s += str(d)+' '\\ns += str(stair[-1])\\nprint(s)\\n\", \"from collections import Counter\\n__author__ = 'asmn'\\n\\nn=int(input())\\na=Counter(list(map(int,input().split())))\\nkeys=sorted(a.keys())\\n\\nfor i in range(len(keys)-2,-1,-1):\\n    if a[keys[i]] > 1:\\n        keys.append(keys[i])\\n\\nprint(len(keys))\\nprint(' '.join(map(str,keys)))\\n\\n\", \"n = int(input())\\ntest = list(map(int, input().split()))\\ntest1 = []\\nresult = []\\ntest.sort(reverse=True)\\n\\nnum = test.count(test[0])\\n\\ntest1.append(test[0])\\nmark = 0\\n\\nfor i in range(num, len(test)):\\n    if test[i] != test1[len(test1)-1]:\\n        test1.append(test[i])\\n        mark = 0\\n    else:\\n        if mark > 0:\\n            continue\\n        else:\\n            test1.append(test[i])\\n            mark += 1\\n\\nresult.append(test1[0])\\nfor j in range(1, len(test1)):\\n    if test1[j] != result[len(result)-1]:\\n        result.append(test1[j])\\n    else:\\n        result.insert(0, test1[j])\\nprint(len(result))\\nprint(' '.join(map(str, result)))\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n\\tif a[i]>last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nfor i in range(n-1,-1,-1):\\n\\tif not v[i] and a[i]<last:\\n\\t\\tlast=a[i]\\n\\t\\tb.append(a[i])\\n\\t\\tv[i]=1\\nprint(len(b))\\nfor i in range(len(b)):\\n\\tprint(b[i],end=' ')\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nlast=0\\nv=[0]*n\\nb=[]\\nfor i in range(n):\\n    if a[i]>last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\nfor i in range(n-1,-1,-1):\\n    if not v[i] and a[i]<last:\\n        last=a[i]\\n        b.append(a[i])\\n        v[i]=1\\ntmp=len(b)\\nprint(tmp)\\nfor i in range(tmp):\\n    print(b[i],end=' ')\\n\", \"input()\\na=list(map(int,input().split()))\\nb=[0]*5000\\nfor x in a:\\n    b[x-1]+=1\\nr=''\\ncount=0\\nmax=0\\nfor i in range(5000):\\n    if b[i]>0:\\n        count+=1\\n        max=i\\n        r+=str(i+1)+' ';\\n        b[i]-=1\\nfor i in range(max-1,-1,-1):\\n    if b[i]>0:\\n        count+=1\\n        r+=str(i+1)+' ';\\nprint(count)\\nprint(r)\", \"n, t = int(input()), sorted(map(int, input().split()))\\na, b, k = [t[0]], [], False\\nfor i in range(1, n):\\n    if t[i] == t[i - 1]: k = True\\n    else:\\n        if k:\\n            k = False\\n            b.append(t[i - 1])\\n        a.append(t[i])\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"n, p = input(), [0] * 5001\\nfor i in map(int, input().split()): p[i] += 1\\na = [i for i in range(1, 5001) if p[i]]\\nb = [i for i in a[: -1] if p[i] > 1]\\nprint(len(a) + len(b))\\nprint(' '.join(map(str, a)) + ' ' + ' '.join(map(str, reversed(b))))\", \"from sys import stdin, stdout\\n\\ndef solve(c, n):\\n\\tc = list(sorted(c))\\n\\troot = Root()\\n\\troot.value = c.pop()\\n\\tleft_bound = root\\n\\tright_bound = root\\n\\twhile len(c) > 0:\\n\\t\\tval = c.pop()\\n\\t\\t# print('Current: ' + str(val))\\n\\t\\tnode = Node()\\n\\t\\tnode.value = val\\n\\t\\tif left_bound.value > val:\\n\\t\\t\\tnode.prev = left_bound\\n\\t\\t\\tif left_bound == root:\\n\\t\\t\\t\\troot.left = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tleft_bound.next = node\\n\\t\\t\\tleft_bound = node\\n\\t\\t\\t# print('appended to left')\\n\\t\\telif right_bound.value > val:\\n\\t\\t\\tnode.prev = right_bound\\n\\t\\t\\tif right_bound == root:\\n\\t\\t\\t\\troot.right = node\\n\\t\\t\\telse:\\n\\t\\t\\t\\tright_bound.next = node\\n\\t\\t\\tright_bound = node\\n\\t\\t# \\tprint('appended to right')\\n\\t\\t# else:\\n\\t\\t# \\tprint('skipped')\\n\\tres_len = 0\\n\\tres_str = ''\\n\\n\\tp = left_bound\\n\\twhile p is not root:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.prev\\n\\tres_str += str(p.value) + ' '\\n\\tres_len += 1\\n\\tp = root.right\\n\\twhile p is not None:\\n\\t\\tres_str += str(p.value) + ' '\\n\\t\\tres_len += 1\\n\\t\\tp = p.next\\n\\treturn (res_len, res_str)\\n\\nclass Node:\\n\\tvalue = None\\n\\tnext = None\\n\\tprev = None\\n\\nclass Root:\\n\\tvalue = None\\n\\tright = None\\n\\tleft = None\\n\\n\\ndef __starting_point():\\n\\tn_s = stdin.readline()\\n\\tcards_s = stdin.readline().split(' ')\\n\\tn = int(n_s)\\n\\tcards = [int(c) for c in cards_s]\\n\\troot = solve(cards, n)\\n\\tprint('{}\\\\n{}'.format(root[0], root[1]))\\n__starting_point()\", \"__author__ = 'maaanu'\\n\\ndef start():\\n    m = int(input())\\n    cards = [int(x) for x in input().split(\\\" \\\")]\\n    cards.sort()\\n    max_cards = len(cards)\\n    last_card = cards.pop()\\n    table = [last_card]\\n\\n    for val in reversed(cards):\\n        if val < last_card:\\n            last_card = val\\n            table.append(last_card)\\n        elif val < table[0]:\\n            table.insert(0, val)\\n        else:\\n            max_cards -= 1\\n    print(max_cards)\\n    print(\\\"\\\".join([str(number)+\\\" \\\" for number in table]))\\n\\n\\nstart()\", \"# -*- coding: utf-8 -*-\\nimport sys\\n\\nm = int(sys.stdin.readline())\\nb = [int(x) for x in sys.stdin.readline().split(' ')]\\n\\nb.sort()\\n\\nl1 = []\\nl2 = []\\n\\nlast = b[0]\\nrep = 1\\nl1.append(last)\\nfor i in range(1, len(b)):\\n    if b[i] == last:\\n        rep += 1\\n    else:\\n        last = b[i]\\n        rep = 1\\n    if rep == 1:\\n        l1.append(last)\\n    elif rep == 2:\\n        l2.append(last)\\n    #\\u5426\\u5219\\u4e22\\u5f03\\n\\nif l2 and l2[-1] == l1[-1]:\\n    l2.pop()\\nl2.reverse()\\n\\nprint(len(l1)+len(l2))\\nprint(' '.join([str(x) for x in l1]), end='')\\nif l2:\\n    print(' ', end='')\\n    print(' '.join([str(x) for x in l2]))\\nelse:\\n    print()\\n\", \"import sys\\nf = sys.stdin\\nf.readline()\\na = sorted([int(x) for x in f.readline().split()])\\nb = [a[0],]\\nc = [True]\\nfor i in range(1, len(a)):\\n    if a[i] != a[i - 1]: b.append(a[i])\\n    c.append(a[i] != a[i - 1])\\nfor i in range(len(a) - 1, -1, -1):\\n    if (a[i] < b[-1]) and (not c[i]): b.append(a[i])\\nprint(len(b))\\nfor i in b: print(i, end=' ')\\n\\n\", \"#!/usr/bin/env python3.3\\n# -*- coding: utf-8 -*-\\n\\ndef sereja_and_stairs ():\\n\\n    m = input()\\n    b = input()\\n\\n    nr_allcards = int(m)\\n    cards = list(map(int, b.split(' ')))\\n\\n    nr_cards = [0] * 5001\\n    max_card = 0\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    up_stairs = []\\n    down_stairs = []\\n    for card in range(1, max_card+1):\\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print(('{nr:d}\\\\n{stairs:s}'\\n          .format(nr=nr_stairs, stairs=stairs)\\n          ))\\n\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"#!/usr/bin/env python\\n# -*- coding: utf-8 -*-\\n\\n\\n## Python 3 \\ndef sereja_and_stairs ():\\n\\n    ## \\n    # raw_input() \\u2192 input()\\n    m = input()\\n    b = input()\\n\\n    ## \\n    # nr_allcards = int(m)          #\\n    cards = list(map(int, b.split(' ')))  #\\n\\n    ##\\n    nr_cards = [0] * 5001           #\\n    max_card = 0                    #\\n    for card in cards:\\n        nr_cards[card] += 1\\n        max_card = max(max_card, card)\\n\\n    ##\\n    #\\n    #\\n    up_stairs = []                  # \\n    down_stairs = []                # \\n    for card in range(1, max_card+1):\\n        # \\n        if nr_cards[card] > 0:\\n            nr_cards[card] -= 1\\n            down_stairs.append(card)\\n        # \\n        if nr_cards[card - 1] > 0:\\n            up_stairs.append(card - 1)\\n\\n    ## \\n    down_stairs.reverse()\\n    stairs = up_stairs + down_stairs\\n\\n    ## \\n    # \\n    # \\n    # [Python2] : print '%d\\\\n%s' % (nr_stairs, stairs)\\n    # [Python3] : print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    nr_stairs = len(stairs)\\n    stairs = ' '.join(map(str,stairs))\\n    print('{number:d}\\\\n{stairs:s}'.format(number=nr_stairs, stairs=stairs))\\n    return\\n\\ndef __starting_point():\\n    sereja_and_stairs()\\n\\n__starting_point()\", \"n = int(input())\\ns = sorted(map(int, input().split()))\\nm = 5001\\nc = [0] * m\\nfor i in range(n):\\n  c[s[i]] += 1\\nc[s[-1]] = 1\\na = [i for i in range(m) if c[i] > 0] + [i for i in range(m) if c[i] > 1][::-1]\\nprint(len(a))\\nprint(' '.join(map(str, a)))\", \"import sys\\nimport math\\n\\nn = int(sys.stdin.readline())\\nan = [int(x) for x in (sys.stdin.readline()).split()]\\n\\nd = dict()\\nfor i in an:\\n    if i in d:\\n        d[i] += 1\\n    else:\\n        d[i] = 1\\n        \\nt = list(d.keys())\\nt.sort(reverse = True)\\n\\nresr = []\\nresl = []\\nc = 1\\nresr.append(str(t[0]))\\nfor i in t[1:]:\\n    if(d[i] > 1):\\n        c += 2\\n        resr.append(str(i))\\n        resl.append(str(i))\\n    else:\\n        c += 1\\n        resr.append(str(i))\\n        \\nk = list(resl[::-1])\\nk.extend(resr)     \\nprint(c)  \\nprint(\\\" \\\".join(k))\", \"from collections import Counter\\nn = int(input())\\nl = Counter(int(x) for x in input().split())\\na = []\\nb = []\\nfor x, y in list(l.items()):\\n\\ta.append(x)\\n\\tif y > 1:\\n\\t\\tb.append(x)\\na.sort()\\nb.sort()\\nif len(b) and a[-1] == b[-1]:\\n\\tb = b[:-1]\\nans = a + b[::-1]\\nprint(len(ans))\\nprint(' '.join(str(x) for x in ans))\\n\", \"from itertools import chain\\n\\n\\ndef main():\\n    input()\\n    lb, la = [], []\\n    a = b = -1\\n    it = iter(sorted(map(int, input().split())))\\n    try:\\n        while True:\\n            c = next(it)\\n            if a != c:\\n                a = c\\n                la.append(a)\\n            c = next(it)\\n            if b != c:\\n                b = c\\n                lb.append(b)\\n            pass\\n    except StopIteration:\\n        if a == b:\\n            del lb[-1]\\n    print(len(la) + len(lb))\\n    print(' '.join(map(str, chain(la, lb[::-1]))))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2\n1 2\n",
        "output": "2\n2 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/381/B"
    },
    {
        "id": 1823,
        "task_id": 1690,
        "test_case_id": 1,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "5\n1 2 1 3 6\n",
        "output": "10",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1824,
        "task_id": 1690,
        "test_case_id": 2,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "5\n3 2 5 4 10\n",
        "output": "20",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1825,
        "task_id": 1690,
        "test_case_id": 3,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "4\n1 1 1 1\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1826,
        "task_id": 1690,
        "test_case_id": 5,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "2\n921 921\n",
        "output": "1841",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1827,
        "task_id": 1690,
        "test_case_id": 7,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "11\n3 10 20 13 18 12 6 5 19 10 8\n",
        "output": "36",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1828,
        "task_id": 1690,
        "test_case_id": 8,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "19\n3 1 16 11 12 10 3 13 12 9 1 9 8 4 19 16 19 3 3\n",
        "output": "6",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1829,
        "task_id": 1690,
        "test_case_id": 9,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "4\n11 6 1 16\n",
        "output": "17",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1830,
        "task_id": 1690,
        "test_case_id": 10,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "19\n10 10 8 11 6 1 6 13 8 20 8 14 9 18 18 7 5 20 6\n",
        "output": "21",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1831,
        "task_id": 1690,
        "test_case_id": 11,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "12\n6 20 12 12 1 8 15 19 5 19 5 16\n",
        "output": "31",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1832,
        "task_id": 1690,
        "test_case_id": 12,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "2\n6 16\n",
        "output": "22",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1833,
        "task_id": 1690,
        "test_case_id": 13,
        "question": "You went to the store, selling $n$ types of chocolates. There are $a_i$ chocolates of type $i$ in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy $x_i$ chocolates of type $i$ (clearly, $0 \\le x_i \\le a_i$), then for all $1 \\le j < i$ at least one of the following must hold:  $x_j = 0$ (you bought zero chocolates of type $j$) $x_j < x_i$ (you bought less chocolates of type $j$ than of type $i$) \n\nFor example, the array $x = [0, 0, 1, 2, 10]$ satisfies the requirement above (assuming that all $a_i \\ge x_i$), while arrays $x = [0, 1, 0]$, $x = [5, 5]$ and $x = [3, 2]$ don't.\n\nCalculate the maximum number of chocolates you can buy.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), denoting the number of types of chocolate.\n\nThe next line contains $n$ integers $a_i$ ($1 \\le a_i \\le 10^9$), denoting the number of chocolates of each type.\n\n\n-----Output-----\n\nPrint the maximum number of chocolates you can buy.\n\n\n-----Examples-----\nInput\n5\n1 2 1 3 6\n\nOutput\n10\nInput\n5\n3 2 5 4 10\n\nOutput\n20\nInput\n4\n1 1 1 1\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first example, it is optimal to buy: $0 + 0 + 1 + 3 + 6$ chocolates.\n\nIn the second example, it is optimal to buy: $1 + 2 + 3 + 4 + 10$ chocolates.\n\nIn the third example, it is optimal to buy: $0 + 0 + 0 + 1$ chocolates.",
        "solutions": "[\"rr = lambda: input().strip()\\nrri = lambda: int(rr())\\nrrm = lambda: list(map(int, rr().split()))\\n\\ndef solve(N, A):\\n    ans = 0\\n    prev = float('inf')\\n    for x in reversed(A):\\n        x = min(x, prev - 1)\\n        ans += max(x, 0)\\n        prev = x\\n    return ans\\n\\nfor tc in range(1):#rri()):\\n    N = rri()\\n    A = rrm()\\n    print(solve(N, A))\\n\", \"import getpass\\nimport sys\\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\\nimport math\\nimport string\\nimport re\\nimport math\\nimport random\\nfrom decimal import Decimal, getcontext\\n\\n\\ndef ria():\\n    return [int(i) for i in input().split()]\\n\\n\\nn = ria()[0]\\nar = [i for i in reversed(ria())]\\np = ar[0]\\nsm = ar[0]\\nfor i in range(1,n):\\n    cr=min(max(0,p-1),ar[i])\\n    # print(cr)\\n    p=cr\\n    sm+=cr\\nprint(sm)\", \"n = int(input())\\n\\nt = list(map(int, input().split()))\\n\\nv = [0] * n\\nv[-1] = t[-1]\\nfor i in range(n - 1 - 1, 0 - 1, -1):\\n    v[i] = max(min(v[i + 1] - 1, t[i]), 0)\\n\\nprint(sum(v))\", \"n = int(input())\\na = list(map(int, input().split()))\\nans = 0\\nmx = a[-1] + 1\\nfor i in range(n-1,-1,-1):\\n    ans += max(0, min(mx-1, a[i]))\\n    mx = min(mx-1, a[i])\\nprint(ans)\", \"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\n#T_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    za =  getIntList()\\n    r = 0\\n    now = 10**10\\n    for i in range(N-1, -1, -1):\\n        x = min(now-1, za[i])\\n        if x<=0: break\\n        now = x\\n        r+=x\\n    print(r)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nans=0\\ncurr=1000000001\\nfor i in range(n-1,-1,-1):\\n         if(l[i]<curr):\\n                  curr=l[i]\\n         elif(curr>0):\\n                  curr-=1\\n         ans+=curr\\nprint(ans)\", \"import math\\nn = int(input())\\na = list(map(int, input().split()))\\na = list(reversed(a))\\ns = 0\\nm = math.inf\\nfor i in range(len(a)):\\n    m = min(max(m-1, 0), a[i])\\n    s +=m\\nprint(s)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = a[-1]\\nres = c\\nfor i in a[::-1][1:]:\\n    if i < c:\\n        res += i\\n        c = i\\n    else:\\n        if c == 0:\\n            break\\n        res += c - 1\\n        c -= 1\\nprint(res)\", \"n = int(input())\\nA = [int(i) for i in input().split()]\\nans = 0\\ncurmax = 10**10\\nfor i in range(n-1, -1, -1):\\n    if curmax==0:\\n        continue\\n    if A[i] < curmax:\\n        ans += A[i]\\n        curmax = A[i]\\n    else:\\n        ans += curmax-1\\n        curmax-=1\\nprint(ans)\\n    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nmaxi = 10**11\\nans = 0\\nfor i in range(n - 1, -1, -1):\\n    maxi = max(min(a[i], maxi - 1), 0)\\n    ans += maxi\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\ncnt = 0\\nz = float('inf')\\nfor i in range(n - 1, -1, -1):\\n    if z > A[i]:\\n        z = min(z, A[i])\\n        cnt += z\\n    else:\\n        z -= 1\\n        z = max(0, z)\\n        cnt += z\\nprint(cnt)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nr = 10**10\\nans = 0\\nfor i in range(n):\\n    r = max(min(r - 1, a[n - i - 1]), 0)\\n    ans += r\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\nans=arr[-1]\\nval=max(arr[-1]-1,0)\\nfor i in range(n-2,-1,-1):\\n\\tif(arr[i]>val):\\n\\t\\tans+=val\\n\\t\\tval=max(val-1,0)\\n\\telse:\\n\\t\\tans+=arr[i]\\n\\t\\tval=max(arr[i]-1,0)\\nprint(ans)\\n\", \"n = int(input())\\nl = [*map(int, input().split())]\\nm = [e for e in l]\\nfor i in range(n - 2, -1, -1):\\n    m[i] = max(0, min(m[i], m[i + 1] - 1))\\nprint(sum(m))\", \"n = int(input())\\nu = list(map(int, input().split()))\\nfor i in range(n - 2, -1, -1):\\n    if u[i] >= u[i + 1] and u[i] != 0:\\n        u[i] = u[i + 1] - 1\\n        if u[i + 1] == 0:\\n            u[i] = 0\\n    \\nprint(sum(u))\\n\", \"''' CODED WITH LOVE BY SATYAM KUMAR '''\\n\\nfrom sys import stdin, stdout\\nimport cProfile, math\\nfrom collections import Counter,defaultdict\\nfrom bisect import bisect_left,bisect,bisect_right\\nimport itertools\\nfrom copy import deepcopy\\nfrom fractions import Fraction\\nimport sys, threading\\nimport operator as op\\nfrom functools import reduce\\nsys.setrecursionlimit(10**6) # max depth of recursion\\nthreading.stack_size(2**27)  # new thread will get stack of such size\\nfac_warmup = False\\nprintHeap = str()\\nmemory_constrained = False\\nP = 10**9+7\\nimport sys\\n\\nclass merge_find:\\n    def __init__(self,n):\\n        self.parent = list(range(n))\\n        self.size = [1]*n\\n        self.num_sets = n\\n        self.lista = [[_] for _ in range(n)]\\n    def find(self,a):\\n        to_update = []\\n        while a != self.parent[a]:\\n            to_update.append(a)\\n            a = self.parent[a]\\n        for b in to_update:\\n            self.parent[b] = a\\n        return self.parent[a]\\n    def merge(self,a,b):\\n        a = self.find(a)\\n        b = self.find(b)\\n        if a==b:\\n            return\\n        if self.size[a]<self.size[b]:\\n            a,b = b,a\\n        self.num_sets -= 1\\n        self.parent[b] = a\\n        self.size[a] += self.size[b]\\n        self.lista[a] += self.lista[b]\\n    def set_size(self, a):\\n        return self.size[self.find(a)]\\n    def __len__(self):\\n        return self.num_sets\\n\\ndef display(string_to_print):\\n    stdout.write(str(string_to_print) + \\\"\\\\n\\\")\\n\\ndef primeFactors(n): #n**0.5 complex \\n    factors = dict()\\n    for i in range(2,math.ceil(math.sqrt(n))+1):  \\n        while n % i== 0: \\n            if i in factors:\\n                factors[i]+=1\\n            else: factors[i]=1\\n            n = n // i \\n    if n>2:\\n        factors[n]=1\\n    return (factors)\\n\\ndef fibonacci_modP(n,MOD):\\n    if n<2: return 1\\n    #print (n,MOD)\\n    return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\\n\\ndef factorial_modP_Wilson(n , p): \\n    if (p <= n): \\n        return 0\\n    res = (p - 1) \\n    for i in range (n + 1, p): \\n        res = (res * cached_fn(InverseEuler,i, p)) % p \\n    return res \\n\\ndef binary(n,digits = 20):\\n    b = bin(n)[2:]\\n    b = '0'*(20-len(b))+b\\n    return b\\n\\ndef isprime(n):\\n    \\\"\\\"\\\"Returns True if n is prime.\\\"\\\"\\\"\\n    if n < 4:\\n        return True\\n    if n % 2 == 0:\\n        return False\\n    if n % 3 == 0:\\n        return False\\n    i = 5\\n    w = 2\\n    while i * i <= n:\\n        if n % i == 0:\\n            return False\\n        i += w\\n        w = 6 - w\\n    return True\\nfactorial_modP = []\\ndef warm_up_fac(MOD):\\n    nonlocal factorial_modP,fac_warmup\\n    if fac_warmup: return\\n    factorial_modP= [1 for _ in range(fac_warmup_size+1)]\\n    for i in range(2,fac_warmup_size):\\n        factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\\n    fac_warmup = True\\n\\ndef InverseEuler(n,MOD):\\n    return pow(n,MOD-2,MOD)\\n\\ndef nCr(n, r, MOD):\\n    nonlocal fac_warmup,factorial_modP\\n    if not fac_warmup:\\n        warm_up_fac(MOD)\\n        fac_warmup = True\\n    return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\\n\\ndef test_print(*args):\\n    if testingMode:\\n        print(args)\\n\\ndef display_list(list1, sep=\\\" \\\"):\\n    stdout.write(sep.join(map(str, list1)) + \\\"\\\\n\\\")\\n\\ndef display_2D_list(li):\\n    for i in li:\\n        print(i)\\ndef prefix_sum(li):\\n    sm = 0\\n    res = []\\n    for i in li:\\n        sm+=i\\n        res.append(sm)\\n    return res\\n\\ndef get_int():\\n    return int(stdin.readline().strip())\\n\\ndef get_tuple():\\n    return map(int, stdin.readline().split())\\n\\ndef get_list():\\n    return list(map(int, stdin.readline().split()))\\nimport heapq,itertools\\npq = []                         # list of entries arranged in a heap\\nentry_finder = {}               # mapping of tasks to entries\\nREMOVED = '<removed-task>' \\ndef add_task(task, priority=0):\\n    'Add a new task or update the priority of an existing task'\\n    if task in entry_finder:\\n        remove_task(task)\\n    count = next(counter)\\n    entry = [priority, count, task]\\n    entry_finder[task] = entry\\n    heapq.heappush(pq, entry)\\n\\ndef remove_task(task):\\n    'Mark an existing task as REMOVED.  Raise KeyError if not found.'\\n    entry = entry_finder.pop(task)\\n    entry[-1] = REMOVED\\n\\ndef pop_task():\\n    'Remove and return the lowest priority task. Raise KeyError if empty.'\\n    while pq:\\n        priority, count, task = heapq.heappop(pq)\\n        if task is not REMOVED:\\n            del entry_finder[task]\\n            return task\\n    raise KeyError('pop from an empty priority queue')\\nmemory = dict()\\ndef clear_cache():\\n    nonlocal memory\\n    memory = dict()\\ndef cached_fn(fn, *args):\\n    nonlocal memory\\n    if args in memory:\\n        return memory[args]\\n    else:\\n        result = fn(*args)\\n        memory[args] = result\\n        return result\\n\\ndef ncr (n,r):\\n    return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\\ndef binary_serach(i,li):\\n    #print(\\\"Search for \\\",i)\\n    fn = lambda x: li[x]-x//i\\n    x = -1\\n    b = len(li)\\n    while b>=1:\\n        #print(b,x)\\n        while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\\n            x+=b\\n        b=b//2\\n    return x\\n\\n# -------------------------------------------------------------- MAIN PROGRAM\\nTestCases = False\\ntestingMode = False\\nfac_warmup_size = 10**5+100\\noptimiseForReccursion = True #Can not be used clubbed with TestCases\\nfrom math import factorial\\n\\ndef main():\\n    n = get_int()\\n    li = get_list()\\n    li.reverse()\\n    k = 1000000000000000\\n    res = 0\\n    for i in li:\\n        k = max(min(i,k-1),0)\\n        res+=k\\n    print(res)\\n\\n    \\n# --------------------------------------------------------------------- END=\\n\\n\\nif TestCases: \\n    for _ in range(get_int()): \\n        cProfile.run('main()') if testingMode else main() \\nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()\", \"'''input\\n4\\n1 1 1 1\\n'''\\nimport sys\\nfrom collections import defaultdict as dd\\nfrom itertools import  permutations as pp\\nfrom itertools import combinations as cc\\nfrom collections import Counter as ccd\\nfrom random import randint as rd\\nfrom bisect import bisect_left as bl\\nimport heapq\\nmod=10**9+7\\n\\ndef ri(flag=0):\\n\\tif flag==0:\\n\\t\\treturn [int(i) for i in sys.stdin.readline().split()]\\n\\telse:\\n\\t\\treturn int(sys.stdin.readline())\\n\\nn=ri(1)\\na=ri()\\nc=0\\nlast=0\\nans=0\\nans=[a[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tans.append(min(ans[-1]-1,a[i]))\\nfor i in ans:\\n\\tif i>0:\\n\\t\\tc+=i\\nprint(c)\", \"input()\\nS=list(map(int,input().split()))\\nan=S[-1]\\nla = S[-1]\\n\\nfor i in range(len(S) - 2, -1,-1):\\n    ne = max(min(la-1,S[i]), 0)\\n    an += ne\\n    la = ne\\nprint(an)    \", \"import sys\\nsys.setrecursionlimit(2000)\\nfrom collections import Counter\\nfrom functools import reduce\\n# sys.stdin.readline()\\n\\ndef __starting_point():\\n\\n    # single variables\\n    n = [int(val) for val in sys.stdin.readline().split()][0]\\n    a = [int(val) for val in sys.stdin.readline().split()]\\n\\n\\n    prev = a[-1]\\n    count = prev\\n    for i in range(n-2, -1, -1):\\n        prev = min(a[i], prev-1)\\n        prev = max(prev, 0)\\n        count += prev\\n\\n    print(count)       \\n \\n\\n\\n__starting_point()\", \"n = int(input())\\na = [int(t) for t in input().split(' ')]\\n\\nINF = 10**10\\n\\ni = n-1\\ntotal = 0\\nmn = INF\\nwhile i >= 0:\\n    mn = max(0, min(mn - 1, a[i]))\\n    total += mn\\n    i -= 1\\n\\nprint(total)\\n\", \"'''stdin=open('input.txt')\\n\\ndef input():\\n\\treturn stdin.readline()[:-1]'''\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nans = a[0]\\nfor i in range(1, n):\\n\\tif a[i] >= a[i - 1]:\\n\\t\\tans += max(a[i - 1] - 1, 0)\\n\\t\\ta[i] = max(a[i - 1] - 1, 0)\\n\\telse:\\n\\t\\tans += a[i]\\n\\nprint(ans)\\n#CODE ENDS HERE....................\\n\\n\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nsumm=0\\ni=n-1\\nminn=a[i]\\nwhile i>=0:\\n    if minn>=a[i]:\\n        summ+=a[i]\\n        minn=a[i]-1\\n    else:\\n        summ+=minn\\n        minn=max(0,minn-1)\\n    i-=1\\nprint(summ)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = a[::-1]\\n\\nk = 0\\nmx = a[0] + 2\\n\\nfor c in a:\\n\\tmx = max(0, mx - 1)\\n\\t#print(k, c, mx)\\n\\tif c < mx:\\n\\t\\tk += c\\n\\t\\tmx = c\\n\\t\\n\\telif mx == c:\\n\\t\\tk += max(c, 0)\\n\\t\\tmx = max(c, 0)\\n\\t\\n\\telse:\\n\\t\\tk += mx\\n\\nprint(k)\\n\", \"n = int(input())\\ns = [int(i) for i  in input().split()]\\ns = s[::-1]\\nc = 100000000000\\nans = 0\\nfor i in s:\\n    if i < c:\\n        c = i\\n    else:\\n        c = max(c-1, 0)\\n    ans+=c\\nprint(ans)\"]",
        "difficulty": "interview",
        "input": "8\n10 4 7 6 14 4 2 2\n",
        "output": "3",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1139/B"
    },
    {
        "id": 1834,
        "task_id": 1707,
        "test_case_id": 1,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "3\n2 5 -3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1835,
        "task_id": 1707,
        "test_case_id": 2,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "2\n3 6\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1836,
        "task_id": 1707,
        "test_case_id": 3,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "2\n0 1\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1837,
        "task_id": 1707,
        "test_case_id": 4,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "3\n0 1000000000 -1000000000\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1838,
        "task_id": 1707,
        "test_case_id": 5,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "10\n-35 77 72 -62 76 90 58 97 -74 94\n",
        "output": "38\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1839,
        "task_id": 1707,
        "test_case_id": 6,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "20\n14 8 6 -16 5 -9 0 11 -7 10 20 -6 -17 -13 -11 7 -2 9 -19 19\n",
        "output": "110\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1840,
        "task_id": 1707,
        "test_case_id": 7,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "20\n55 -14 -28 13 -67 -23 58 2 -87 92 -80 62 -44 86 18 97 -47 63 32 94\n",
        "output": "96\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1841,
        "task_id": 1707,
        "test_case_id": 8,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "50\n29 80 0 91 93 36 83 44 79 60 53 89 18 64 37 13 15 54 98 90 68 88 86 38 63 92 16 70 58 45 46 96 62 21 31 14 30 42 7 9 69 97 50 85 84 57 10 59 33 23\n",
        "output": "650\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1842,
        "task_id": 1707,
        "test_case_id": 9,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "50\n-482 -431 -457 -473 -428 -427 -406 -422 -426 -472 -407 -441 -408 -475 -463 -443 -447 -450 -412 -436 -481 -454 -465 -403 -411 -460 -453 -466 -468 -459 -486 -413 -420 -421 -424 -470 -492 -409 -400 -425 -493 -438 -418 -456 -499 -410 -415 -487 -430 -476\n",
        "output": "1225\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1843,
        "task_id": 1707,
        "test_case_id": 10,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "100\n404 523 -303 876 982 -275 498 287 255 491 -723 289 203 -796 -469 -299 -435 -869 58 577 55 600 153 -948 -11 726 129 797 -323 99 -934 -419 101 -307 -525 502 353 44 -905 371 -946 925 -538 614 -171 -867 -929 702 -429 720 94 -390 997 -803 451 379 57 -377 -545 -890 442 525 -975 -484 808 -498 -523 641 725 -425 621 -961 -530 -863 724 -501 -389 348 -263 -396 -225 -489 339 -619 -964 935 -950 210 -245 -326 -850 533 -261 -106 46 270 936 698 -392 -514\n",
        "output": "2751\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1844,
        "task_id": 1707,
        "test_case_id": 11,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "10\n9 1 2 3 5 7 4 10 6 8\n",
        "output": "25\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1845,
        "task_id": 1707,
        "test_case_id": 12,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "10\n-994167199 -21213955 -162630040 335515257 -234713251 -101691063 235271021 -401255443 591241065 803570234\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1846,
        "task_id": 1707,
        "test_case_id": 13,
        "question": "The legend of the foundation of Vectorland talks of two integers $x$ and $y$. Centuries ago, the array king placed two markers at points $|x|$ and $|y|$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $|x - y|$ and $|x + y|$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.\n\nHere $|z|$ denotes the absolute value of $z$.\n\nNow, Jose is stuck on a question of his history exam: \"What are the values of $x$ and $y$?\" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $n$ integers $a_1, a_2, \\dots, a_n$. Now, he wants to know the number of unordered pairs formed by two different elements from these $n$ integers such that the legend could be true if $x$ and $y$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$)  — the number of choices.\n\nThe second line contains $n$ pairwise distinct integers $a_1, a_2, \\dots, a_n$ ($-10^9 \\le a_i \\le 10^9$) — the choices Jose is considering.\n\n\n-----Output-----\n\nPrint a single integer number — the number of unordered pairs $\\{x, y\\}$ formed by different numbers from Jose's choices that could make the legend true.\n\n\n-----Examples-----\nInput\n3\n2 5 -3\n\nOutput\n2\n\nInput\n2\n3 6\n\nOutput\n1\n\n\n\n-----Note-----\n\nConsider the first sample. For the pair $\\{2, 5\\}$, the situation looks as follows, with the Arrayland markers at $|2| = 2$ and $|5| = 5$, while the Vectorland markers are located at $|2 - 5| = 3$ and $|2 + 5| = 7$:\n\n [Image] \n\nThe legend is not true in this case, because the interval $[2, 3]$ is not conquered by Vectorland. For the pair $\\{5, -3\\}$ the situation looks as follows, with Arrayland consisting of the interval $[3, 5]$ and Vectorland consisting of the interval $[2, 8]$:\n\n [Image] \n\nAs Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $\\{2, -3\\}$, for a total of two pairs.\n\nIn the second sample, the only pair is $\\{3, 6\\}$, and the situation looks as follows:\n\n [Image] \n\nNote that even though Arrayland and Vectorland share $3$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.",
        "solutions": "[\"n = int(input())\\nnums = (abs(int(x)) for x in input().split())\\nnums = list(sorted(nums))\\nleft = 0\\nright = 0\\nans = 0\\nwhile left < n:\\n    while right < n and nums[right] <= 2 * nums[left]:\\n        right += 1\\n    ans += right - left - 1\\n    left += 1\\nprint(ans)\", \"n=int(input())\\nA=list(map(int,input().split()))\\n\\nA=[abs(a) for a in A]\\nA.sort()\\n\\nj=0\\nANS=0\\n\\n\\nfor i in range(n-1):\\n    while j<n-1 and A[j+1]-A[i]<=A[i]:\\n        j+=1\\n\\n    ANS+=(j-i)\\n\\nprint(ANS)\\n\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\nn=nn()\\nvals=lm()\\n\\navals=[abs(v) for v in vals]\\n\\navals.sort()\\n\\n\\n\\ntotal=0\\n\\nstart=0\\n\\nend=1\\n\\n\\nwhile end<n:\\n\\n\\tif 2*avals[start]>=avals[end]:\\n\\t\\tend+=1\\n\\n\\n\\telse:\\n\\t\\t\\n\\n\\t\\ttotal=total+max(0,end-start-1)\\n\\t\\tstart+=1\\n\\n\\nnum=end-start\\n\\ntotal+=num*(num-1)//2\\n\\n\\nprint(total)\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\", \"n = int(input())\\nl = sorted([abs(int(i)) for i in input().split()])\\nans = 0\\ni, j = 0, 0\\n\\nwhile i < n:\\n\\twhile j < n and l[i] + l[i] >= l[j]:\\n\\t\\tj += 1\\n\\tans += j - i - 1\\n\\ti += 1\\n\\nprint(ans)\", \"n=int(input())\\nl1=list(map(int,input().split()))\\nl2=[]\\nfor i in range(0,n):\\n    if l1[i]!=0:\\n        l2.append(abs(l1[i]))\\nimport bisect\\nl2.sort()\\nans=0\\nfor i in range(0,len(l2)):\\n    x=bisect.bisect_right(l2,2*l2[i],0,len(l2))\\n    ans+=(x-i-1)\\nprint(ans)\", \"def getN():\\n    return int(input())\\ndef getList():\\n    return list(map(int, input().split()))\\n\\nfrom bisect import bisect_right\\n\\nn = getN()\\nnums = [abs(i) for i in getList()]\\nnums.sort(reverse=False)\\nans = 0\\n#print(nums)\\nfor i , num in enumerate(nums):\\n    ans += bisect_right(nums, num*2) - i - 1\\n\\nprint(ans )\\n\", \"import bisect\\nn = int(input())\\na = list(map(int, input().split()))\\na = [abs(i) for i in a]\\na.sort()\\nans = 0\\nfor i in range(len(a)):\\n    right = a[i]*2\\n    ans += bisect.bisect_right(a, right) - (i+1)\\n\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\na = [abs(l[i]) for i in range(n)]\\na.sort()\\nwyn = 0\\nwsk1 = 0\\nwsk2 = 1\\nlicz = 0\\nwhile True:\\n\\tif a[wsk1] * 2 < a[wsk2]:\\n\\t\\twyn += (wsk2-wsk1-1)\\n\\t\\twsk1 += 1\\n\\telse:\\n\\t\\twsk2 += 1\\n\\tif wsk2 == n:\\n\\t\\tbreak\\nwyn += (n-wsk1)*(n-wsk1-1)//2\\nprint(wyn)\", \"N = int(input())\\nA = sorted([abs(int(a)) for a in input().split()])\\n\\ni = 0\\nj = 1\\nans = 0\\nwhile j < N:\\n    while j < N-1 and A[j+1] <= A[i] * 2:\\n        j += 1\\n    if A[j] <= A[i] * 2:\\n        ans += j - i\\n    i += 1\\n    if j == i:\\n        j += 1\\n\\nprint(ans)\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\na = sorted([abs(x) for x in a])\\n\\n\\ntotal = 0\\ni = 0\\nfor j,h in enumerate(a[:-1]):\\n    h *= 2\\n    while i<(n-1) and a[i+1]<=h:\\n        i+=1\\n    total += i-j\\nprint (total)\\n\\n\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\na = sorted(map(abs, a))\\n\\n#print(a)\\nans = 0\\nj = 1\\nfor i in range(n):\\n    while j < n and a[j] - a[i] <= a[i]:\\n        j += 1\\n    #print(i, j)\\n    ans += j - i - 1\\nprint(ans)\\n\", \"from collections import deque\\n\\nn = int(input().strip())\\nnums = list(map(int, input().strip().split()))\\nnums = sorted([abs(num) for num in nums], reverse=True)\\n\\nres = 0\\nmax_index = 0\\ncurr_index = 1\\nfor curr_index in range(1, n):\\n    while nums[curr_index] * 2 < nums[max_index]:\\n        max_index += 1\\n    res += curr_index - max_index\\nprint(res)\", \"def main():\\n    n = int(input())\\n    a = sorted(map(abs, list(map(int, input().split()))))\\n    i = 0\\n    res = 0\\n    for j in range(n):\\n        while a[i] * 2 < a[j]:\\n            i += 1\\n        res += j - i\\n    print(res)\\n\\n\\nmain()\\n\", \"import bisect\\n\\ndef main():\\n    n = int(input())\\n    pts = list(map(int,input().split()))\\n    points = []\\n    for i in range(n):\\n        points.append(abs(pts[i]))\\n\\n    points.sort()\\n    #print(points)\\n    pairs = 0\\n\\n    for i in range(n):\\n        x = points[i]\\n        index = bisect.bisect(points,2*x)-1\\n        #print(x,index)\\n        if points[index] <= 2*x:\\n            if index >= i:\\n                pairs += index-i\\n\\n    print(pairs)\\n        \\n\\n\\nmain()\\n\", \"n=int(input())\\na=sorted([int(x) for x in input().split()])\\ncounter=0\\nanswer=0\\nend=1\\nfor i in range(n):\\n    if a[i]<0:\\n        a[i]=a[i]*(-1)\\na.sort()\\nfor i in range(n):\\n    end=max(end,i+1)\\n    for j in range(end,n):\\n        if a[i]*2<a[j]:\\n            end=j\\n            break\\n        else:\\n            counter+=1\\n    else:\\n        end=j+1\\n    answer+=counter\\n    counter=max(counter-1,0)\\n            \\nprint(answer)\\n                \\n\", \"'''input\\n2\\n3 6\\n'''\\nfrom sys import stdin, setrecursionlimit\\nfrom bisect import bisect_right\\nimport math\\nsetrecursionlimit(15000)\\n\\n\\n# main starts\\nn = int(stdin.readline().strip())\\narr = list(map(int, stdin.readline().split()))\\nfor i in range(n):\\n\\tarr[i] = abs(arr[i])\\narr.sort()\\ncount = 0\\nfor i in range(n):\\n\\tindex = bisect_right(arr, arr[i] * 2)\\n\\tcount += index - i - 1\\nprint(count) \\n\", \"from bisect import bisect_right\\nn = int(input())\\nA = list(map(int, input().split()))\\nfor i in range(len(A)):\\n    A[i] = abs(A[i])\\nA.sort()\\ncnt = 0\\nfor i in range(len(A)):\\n    q = 2 * A[i]\\n    j = bisect_right(A, q)\\n    cnt += max(0, j - i - 1)\\nprint(cnt)\", \"n = int(input())\\n\\nL = sorted([abs(int(x)) for x in input().split()])\\n\\nT = 0\\n\\nfor i in range(n-1):\\n    l,h = i,n-1\\n    while h != l:\\n        if L[(l+h+1)//2] <= 2*L[i]:\\n            l = (l+h+1)//2\\n        else:\\n            h = (l+h)//2\\n    T += l-i\\n\\nprint(T)\", \"n = int(input())\\nls = list(map(int, input().split()))\\nls = [abs(i) for i in ls]\\nls.sort()\\ni = 0\\nj = 1\\nres = []\\ntry:\\n    while True:\\n        while ls[j]<=2*ls[i]: j+=1\\n        res.append(j-i-1)\\n        i+=1\\nexcept:\\n    while i!=n:\\n        res.append(j-i-1)\\n        i+=1\\nprint(sum(res))\\n\", \"# stdin=open('input.txt')\\nfrom sys import stdin, stdout\\ndef input():\\n\\treturn stdin.readline()[:-1]\\n\\n\\n# stdout=open('output.txt',mode='w+')\\n\\n# def print(x, end='\\\\n'):\\n# \\tstdout.write(str(x) +end)\\n\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n# n = int(input())\\n\\n\\n\\n\\n\\n# CODE BEGINS HERE.................\\n\\n# import copy\\nimport math\\n# import sys\\n# sys.setrecursionlimit(10**7)\\ndef abs_int(a):\\n\\treturn abs(int(a))\\n\\nn = int(input())\\na = list(map(abs_int, input().split()))\\n\\na.sort()\\n# print(a)\\n\\nptr = 0\\nhalf = -1\\ngt_than_half = [0] * n\\nfor i in range(n):\\n\\thalf = math.ceil(a[i]/2)\\n\\twhile a[ptr] < half:\\n\\t\\tptr += 1\\n\\tgt_than_half[i] = i - ptr\\n# print(gt_than_half)\\n\\na.reverse()\\n# print(a)\\n\\nptr = 0\\ntwice = -1\\nlt_than_twice = [0] * n\\nfor i in range(n):\\n\\ttwice = 2 * a[i]\\n\\twhile a[ptr] > twice:\\n\\t\\tptr += 1\\n\\tlt_than_twice[i] = i - ptr\\n# print(lt_than_twice)\\n\\nprint((sum(gt_than_half) + sum(lt_than_twice))//2)\\n\\n\\n#CODE ENDS HERE....................\\n\\n\\n#stdout.close()\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\ndef count(X, Y):\\n    res = 0\\n    r = 0\\n    r2 = 0\\n    Y = [-10**10] + Y + [10**10]\\n    for l in range(len(X)):\\n        xl = X[l]\\n        for _ in range(len(Y)):\\n            if Y[r+1] <= 2*xl:\\n                r += 1\\n                continue\\n            break\\n        for _ in range(len(Y)):\\n            if Y[r2+1] < xl:\\n                r2 += 1\\n                continue\\n            break\\n        res += max(0, r - r2)\\n    return res\\n\\nAP = [a for a in A if a > 0]\\nAP.sort()\\nAN = [-a for a in A if a < 0]\\nAN.sort()\\nprint(count(AP, AP) + count(AP, AN) + count(AN, AP) + count(AN, AN) - len(AN) - len(AP) - len(set(AP) & set(AN)))\"]",
        "difficulty": "interview",
        "input": "8\n-9 -17 -18 -19 9 7 18 19\n",
        "output": "19\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/C"
    },
    {
        "id": 1847,
        "task_id": 1722,
        "test_case_id": 1,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "4\njorge\njose\noscar\njerry\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1848,
        "task_id": 1722,
        "test_case_id": 2,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1849,
        "task_id": 1722,
        "test_case_id": 3,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "5\nmike\nmike\nmike\nmike\nmike\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1850,
        "task_id": 1722,
        "test_case_id": 4,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "10\nnr\nbifiedubnohaektjox\nzxghhzkwfpbsmfsrvzry\njkv\nqppaqotfnqkogvsxyphj\ngjewi\ndzonunipvwclfwfngx\niwu\nzafueotqtrbntjy\nnvp\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1851,
        "task_id": 1722,
        "test_case_id": 5,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "1\nnrkbi\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1852,
        "task_id": 1722,
        "test_case_id": 6,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "5\nmrkbifiedu\nmohaektjox\ngxghhzkwfp\nmmfsrvzr\nmjkvyqppaq\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1853,
        "task_id": 1722,
        "test_case_id": 7,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "20\ngrkbifiedu\ngohaektjox\nyxghhzkwfp\ngmfsrvzr\njjkvyqppaq\nmfnqko\nysxyphjvgj\njixdzo\nynipv\nilfwfngxa\ngutza\ngeotqtrb\ngjytnvppb\nmyllmkvnot\njafckw\njfccigs\njwabzf\nmjzeoxrui\ngctsja\nyvxpeybbh\n",
        "output": "16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1854,
        "task_id": 1722,
        "test_case_id": 8,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "20\nmrkbifiedu\nmohaektjox\ngxghhzkwfp\nmmfsrvzr\nmjkvyqppaq\nmfnqko\nmsxyphjvgj\nmixdzo\nmnipv\nglfwfngxa\nmutza\nmeotqtrb\nmjytnvppb\ngyllmkvnot\ngafckw\nmfccigs\nmwabzf\nmjzeoxrui\ngctsja\nmvxpeybbh\n",
        "output": "53\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1855,
        "task_id": 1722,
        "test_case_id": 9,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "20\ngrkbifiedubnohaektjo\nizxghhzkwfpbsmfsrvzr\njjkvyqppaqotfnqkogvs\ngphjvgjewixdzonunipv\nilfwfngxaiwutzafueot\nirbntjytnvppbgyyllmk\njotpbafckwsufccigskt\njbzfmhjzeoxruiebctsj\nijvxpeybbhrezjuajkkp\njdqriujmuvcvphlcsxfm\nykwqjokeljlnyqpirlvp\nyhcczukakwarzzloccim\nmmygnzejmxmoksmsmnbq\ngzewloxwkwjrexgyiuwn\niacxcpwuwbvioohpndwm\nimkqihzucgjorhpukjjg\nmppnjejitmrbcckatznf\nmvqcunhdhjierflnmwld\njxoemcuqxabbzeqhlizr\nyscbwlaumgkbkpsxenpz\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1856,
        "task_id": 1722,
        "test_case_id": 10,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "20\nnrkbifiedubnohaekt\noxyzxghhzkwfpbsm\nsrvzrywjkvyqppaqot\nnqkogvsxyphjvgje\nixdzonunipvwcl\nwfngxaiwutzaf\neotqtrbntjytnvpp\ngyyllmkvnotpbafc\nwsufccigsktwabzfmh\nzeoxruiebctsjal\nvxpeybbhrezjuajkkp\nedqriujmuvc\nphlcsxfmrikw\njokeljlnyq\nirlvpahhcczukakwarzz\noccimzwmygnzejmxmo\nsmsmnbqmozewloxwk\njrexgyiuwntaacxc\nwuwbvioohpndwmnfmk\nihzucgjorhpukjj\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1857,
        "task_id": 1722,
        "test_case_id": 11,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "100\nm\ng\nm\nm\nm\ng\ng\nm\ng\nm\ng\ng\ng\nm\ng\ng\ng\nm\nm\nm\ng\nm\ng\ng\ng\nm\ng\ng\ng\ng\nm\ng\ng\nm\ng\ng\nm\nm\ng\nm\nm\nm\ng\ng\ng\ng\nm\nm\nm\nm\nm\ng\ng\ng\nm\nm\nm\nm\ng\ng\ng\nm\ng\nm\nm\ng\ng\ng\nm\ng\ng\ng\ng\nm\ng\ng\nm\ng\ng\ng\nm\ng\nm\nm\nm\nm\ng\ng\ng\ng\ng\nm\nm\ng\ng\nm\ng\nm\nm\nm\n",
        "output": "1213\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1858,
        "task_id": 1722,
        "test_case_id": 12,
        "question": "There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.\n\nFor example, if there are $6$ students: \"olivia\", \"jacob\", \"tanya\", \"jack\", \"oliver\" and \"jessica\", then:  splitting into two classrooms (\"jack\", \"jacob\", \"jessica\", \"tanya\") and (\"olivia\", \"oliver\") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),  splitting into two classrooms (\"jack\", \"tanya\", \"olivia\") and (\"jessica\", \"oliver\", \"jacob\") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom). \n\nYou are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?\n\nNote that it is valid to place all of the students in one of the classrooms, leaving the other one empty.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n \\leq 100$) — the number of students.\n\nAfter this $n$ lines follow.\n\nThe $i$-th line contains the name of the $i$-th student.\n\nIt is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.\n\n\n-----Output-----\n\nThe output must consist of a single integer $x$ — the minimum possible number of chatty pairs.\n\n\n-----Examples-----\nInput\n4\njorge\njose\noscar\njerry\n\nOutput\n1\n\nInput\n7\nkambei\ngorobei\nshichiroji\nkyuzo\nheihachi\nkatsushiro\nkikuchiyo\n\nOutput\n2\n\nInput\n5\nmike\nmike\nmike\nmike\nmike\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.\n\nIn the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.\n\nIn the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.",
        "solutions": "[\"n = int(input())\\na = [0] * 27\\nfor i in range(n):\\n\\ts = input()\\n\\ta[ord(s[0]) - ord('a')] += 1\\nans = 0\\nfor i in range(26):\\n\\tt = a[i] // 2\\n\\tk = a[i] - t\\n\\tans += t * (t - 1) // 2\\n\\tans += k * (k - 1) // 2\\nprint(ans)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nx = defaultdict(int)\\nfor i in range(n):\\n    s = input()\\n    x[s[0]] += 1\\n\\nsol = 0\\nfor i in x:\\n    a = x[i] // 2\\n    b = x[i] - a\\n    sol += a * (a-1) // 2\\n    sol += b * (b-1) // 2\\nprint(sol)\", \"def main():\\n    arr = [0] * 26\\n    for i in range(int(input())):\\n        s = input()\\n        s = ord(s[0]) - ord('a')\\n        arr[s] += 1\\n    ans = 0\\n    for i in range(26):\\n        a = arr[i] // 2\\n        b = arr[i] - a\\n        ans += a * (a - 1)\\n        ans += b * (b - 1)\\n    print(ans >> 1)\\n    return 0\\n\\nmain()\", \"from sys import *\\nfrom math import *\\nfrom collections import *\\n\\n\\nM = {}\\n\\nn = int(input())\\n\\nfor i in range(n):\\n    s = input()\\n    if s[0] not in M:\\n        M[s[0]] = 1\\n    else:\\n        M[s[0]] += 1\\n\\nans = 0\\n\\nfor m in M:\\n    if M[m] > 2:\\n        l = M[m] // 2\\n        r = M[m] - l\\n        if l >= 2:\\n            ans += l * (l - 1) // 2\\n        if r >= 2:\\n            ans += r * (r - 1) // 2\\nprint(ans)        \", \"import string\\n\\nnames = {c: 0 for c in string.ascii_lowercase}\\n\\nfor _ in range(int(input())):\\n\\tnames[input()[0]] += 1\\n\\nc = 0\\n\\nf = lambda n: n * (n - 1) // 2\\n\\nfor k in names:\\n\\tc += f(names[k] // 2) + f(-(-names[k] // 2))\\n\\nprint(c)\", \"n = int(input())\\nfrom collections import defaultdict\\nc = defaultdict(int)\\nfor _ in range(n):\\n    name = input()\\n    c[name[0]]+=1\\ntotal = 0\\nfor k,v in c.items():\\n    left = v//2\\n    right = (v+1)//2\\n    total += (left*(left-1))//2\\n    total +=(right*(right-1))//2\\nprint (total)\", \"n = int(input())\\na = [0 for _ in range(26)]\\n\\nfor _ in range(n):\\n\\tname = input()\\n\\ta[ord(name[0]) - ord('a')] += 1\\n\\nt = 0\\nfor m in a:\\n\\tl1 = m // 2\\n\\tl2 = m - l1\\n\\n\\tt += l1 * (l1 - 1) // 2\\n\\tt += l2 * (l2 - 1) // 2\\nprint(t)\", \"n = int(input())\\ns = [input() for i in range(n)]\\n\\nans = 0\\nfor c_i in range(26):\\n    c = chr(ord('a') + c_i)\\n    cnt = sum(1 for name in s if name.startswith(c))\\n    a = cnt // 2\\n    b = cnt - a\\n    ans += (a * (a - 1)) // 2\\n    ans += (b * (b - 1)) // 2\\nprint(ans)\\n\", \"n = int(input())\\na = []\\nfor _ in range(n):\\n    a.append(input()[0])\\nq = 0\\ndef f(x):\\n    return x * (x - 1) // 2\\n\\nfor i in set(a):\\n    r = a.count(i)\\n    if r % 2 == 0:\\n        q += 2 * f(r // 2)\\n    else:\\n        q += f(r // 2) + f(r // 2 + 1)\\nprint(q)\\n\", \"n = int(input())\\n\\nnames = dict()\\n\\nfor _ in range(n):\\n    name = input().strip()\\n    if name[0] not in names:\\n        names[name[0]] = 0\\n    names[name[0]] += 1\\n\\ncnt = 0\\nfor k,v in names.items():\\n    prvi = v//2\\n    drugi = v - prvi\\n    cnt += (prvi*(prvi - 1))//2\\n    cnt += (drugi*(drugi - 1))//2\\nprint(cnt)\", \"n = int(input())\\ns = {}\\nfor i in range(n):\\n    q = input()\\n    if q[0] in list(s.keys()):\\n        s[q[0]] += 1\\n    else:\\n        s[q[0]] = 1\\nu = []\\nans = 0\\nfor i in list(s.keys()):\\n    k = s[i]\\n    u.append(k)\\n    a = k // 2; b = k - a\\n    ans += (a - 1) * a // 2 + (b - 1) * b // 2\\nprint(ans)\\n\", \"n = int(input())\\nx = {}\\nfor i in range(n):\\n    l = input()\\n    try:\\n        x[l[0]].append(l)\\n    except:\\n        x[l[0]] = [l]\\n\\np = 0\\n\\nfor (k, v) in x.items():\\n    a = len(v) // 2\\n    b = len(v) - a\\n    p += (a-1) * a / 2\\n    p += (b-1) * b / 2\\n\\nprint(int(p))\", \"from collections import defaultdict\\n\\ndef pairs(n):\\n    return n * (n - 1) // 2\\n\\nn = int(input())\\nnames = [input() for _ in range(n)]\\nletters = defaultdict(int)\\nfor name in names:\\n    letters[name[0]] += 1\\n\\nans = 0\\nfor val in letters.values():\\n    ans += pairs(val // 2) + pairs(val - val // 2)\\nprint(ans)\", \"from collections import Counter\\n\\nn = int(input())\\ncounts = Counter()\\nfor _ in range(n):\\n    name = input()\\n    counts[name[0]] += 1\\n\\nans = 0\\nfor letter, count in counts.items():\\n    a = count // 2\\n    b = count - a\\n    ans += a * (a - 1) // 2\\n    ans += b * (b - 1) // 2\\n\\nprint(ans)\", \"n=int(input())\\nl1=[0]*26\\nfor i in range(n):\\n    s=input()\\n    l1[ord(s[0])-97]+=1\\nans=0\\nfor item in l1:\\n    x=item//2\\n    y=item-x\\n    ans+=x*(x-1)//2\\n    ans+=y*(y-1)//2\\nprint(ans)\", \"n = int(input())\\nd = {}\\nfor _ in range(n):\\n    c = input()[0]\\n    d[c] = d.get(c, 0) + 1\\nres = 0\\n# print(d)\\nfor v in d.values():\\n    x = (v + 1) // 2\\n    res += (x * (x - 1)) // 2\\n    y = v - x\\n    res += (y * (y - 1)) // 2\\nprint(res)\", \"n = int(input())\\nl = [0] * 26\\nfor _ in range(n):\\n\\ts = input()\\n\\tl[ord(s[0]) - 97] += 1\\nans = 0\\nfor i in range(26):\\n\\tx = l[i] // 2\\n\\ty = l[i] - x\\n\\tans += x * (x - 1) // 2\\n\\tans += y * (y - 1) // 2\\nprint(ans)\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nl=[0]*26\\nfor i in range(n):\\n\\ts=input()\\n\\tl[ord(s[0])-97]+=1\\n\\nans=0\\nfor i in range(26):\\n\\tcur=l[i]//2\\n\\tnex=l[i]-cur\\n\\tans+=cur*(cur-1)//2\\n\\tans+=nex*(nex-1)//2\\n\\nprint(ans)\\n\", \"n = int(input())\\nsp = [0] * 26\\nfor i in range(n):\\n\\tst = input()\\n\\tsp[ord(st[0]) - ord(\\\"a\\\")] += 1\\nsm = 0\\nfor x in sp:\\n\\tch = x // 2\\n\\tsm += ch * (ch - 1) // 2\\n\\tsm += (x - ch) * (x - ch - 1) // 2\\nprint(sm)\\n\", \"n=int(input())\\ndict1={}\\nfor i in range(n):\\n    s=str(input())\\n    try:\\n        dict1[s[0]]+=1\\n    except:\\n        KeyError\\n        dict1[s[0]]=1\\nans=0\\nfor i in list(dict1.keys()):\\n    if(dict1[i]>2):\\n        val1=dict1[i]//2\\n        val2=dict1[i]//2+dict1[i]%2\\n        if(val1>0):\\n            ans+=(val1*(val1-1))//2\\n        if(val2>0):\\n            ans+=(val2*(val2-1))//2\\nprint(ans)\\n\", \"n=int(input())\\ncounter=0\\ndic={}\\nfor i in range(n):\\n    a=list(input())\\n    if a[0] not in dic:\\n        dic[a[0]]=1\\n    else:\\n        dic[a[0]]+=1\\nfor item in dic:\\n    y=dic[item]\\n    x=dic[item]//2\\n    counter+=x*(x-1)//2+(y-x)*(y-x-1)//2\\nprint(counter)\\n\", \"#Bhargey Mehta (Sophomore)\\n#DA-IICT, Gandhinagar\\nimport sys, math, queue\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\")\\nMOD = 10**9+7\\n\\nn = int(input())\\nd = {}\\nfor i in range(n):\\n    s = input()\\n    if s[0] in d:\\n        d[s[0]] += 1\\n    else:\\n        d[s[0]] = 1\\n\\nans = 0\\nfor k in d:\\n    x1 = (d[k]+1)//2\\n    x2 = d[k]-x1\\n    ans += (x1*(x1-1))//2 + (x2*(x2-1))//2\\nprint(ans)\", \"n = int(input())\\n\\nD = {}\\n\\nfor _ in range(n):\\n    x = input()[:1]\\n    if x in D:\\n        D[x] += 1\\n    else:\\n        D[x] = 1\\n    \\nT = 0\\nfor i in D:\\n    m = 10000000\\n    for j in range(D[i]):\\n        m = min(m,(j*(j-1))//2+((D[i]-j)*(D[i]-j-1))//2)\\n    T += m\\n    \\nprint(T)\"]",
        "difficulty": "interview",
        "input": "6\nyou\nare\na\nvery\ncurious\nindividual\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1166/A"
    },
    {
        "id": 1859,
        "task_id": 1738,
        "test_case_id": 1,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "aaaaaaaaaa\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1860,
        "task_id": 1738,
        "test_case_id": 2,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "abcab\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1861,
        "task_id": 1738,
        "test_case_id": 3,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "cczabababab\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1862,
        "task_id": 1738,
        "test_case_id": 4,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "kbyjorwqjk\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1863,
        "task_id": 1738,
        "test_case_id": 5,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "baaabbbaba\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1864,
        "task_id": 1738,
        "test_case_id": 6,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "aaaaaaaaaa\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1865,
        "task_id": 1738,
        "test_case_id": 7,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "cbbbcccbbc\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1866,
        "task_id": 1738,
        "test_case_id": 8,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1867,
        "task_id": 1738,
        "test_case_id": 9,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "hltcdvuobkormkxkbmpfjniilublkrckmvvxemcyietgxcyjgrjwsdsgsfmoqnmbxozfavxopklhldhnsjpxhejxaxuctxeifglx\n",
        "output": "101\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1868,
        "task_id": 1738,
        "test_case_id": 10,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "agdmdjkbfnleldamiiedfheefgaimecnllgkjdkdcfejainklmhaklcjkgkimgfiiajiiihhdngjedgmefnjmbglghjjejfjkaha\n",
        "output": "101\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1869,
        "task_id": 1738,
        "test_case_id": 11,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "aaaaaaabaaaabbbbaaaaaaabbaaaaaaaaaabbabaaaaaabaaaaabaaaaaaaabaaaaaaaaaaaaaaaabaaaaaabaaaaaaaaabbaaabaaaaabbaaabaaaaabaaabaaaaaabaaaaaaaaaaabaabaaabaaaaabbbbaaaaaaaaaaaaaaabaaaaaaaaababaaabaaaaaaaaaabaaaaaaaabaaaabbbbaaaaaaabbaaaaaaaaaabbabaaaaaabaaaaabaaaaaaaabaaaaaaaaaaaaaaaabaaaaaabaaaaaaaaabbaaabaaaaabbaaabaaaaabaaabaaaaaabaaaaaaaaaaabaabaaabaaaaabbbbaaaaaaaaaaaaaaabaaaaaaaaababaaabaaaaaaaaaaba\n",
        "output": "191\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1870,
        "task_id": 1738,
        "test_case_id": 12,
        "question": "Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string s instead of the string itself.\n\nThe compressed version of string s is a sequence of strings c_1, s_1, c_2, s_2, ..., c_{k}, s_{k}, where c_{i} is the decimal representation of number a_{i} (without any leading zeroes) and s_{i} is some string consisting of lowercase Latin letters. If Ivan writes string s_1 exactly a_1 times, then string s_2 exactly a_2 times, and so on, the result will be string s.\n\nThe length of a compressed version is |c_1| + |s_1| + |c_2| + |s_2|... |c_{k}| + |s_{k}|. Among all compressed versions Ivan wants to choose a version such that its length is minimum possible. Help Ivan to determine minimum possible length.\n\n\n-----Input-----\n\nThe only line of input contains one string s consisting of lowercase Latin letters (1 ≤ |s| ≤ 8000).\n\n\n-----Output-----\n\nOutput one integer number — the minimum possible length of a compressed version of s.\n\n\n-----Examples-----\nInput\naaaaaaaaaa\n\nOutput\n3\n\nInput\nabcab\n\nOutput\n6\n\nInput\ncczabababab\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example Ivan will choose this compressed version: c_1 is 10, s_1 is a.\n\nIn the second example Ivan will choose this compressed version: c_1 is 1, s_1 is abcab.\n\nIn the third example Ivan will choose this compressed version: c_1 is 2, s_1 is c, c_2 is 1, s_2 is z, c_3 is 4, s_3 is ab.",
        "solutions": "[\"def prefix(s):\\n    p = [0]\\n    for i in range(1, len(s)):\\n        j = p[-1]\\n        while j > 0 and s[j] != s[i]:\\n            j = p[j - 1]\\n        if s[i] == s[j]:\\n            j += 1\\n        p.append(j)\\n    return p\\n\\n\\ns = input()\\nn = len(s)\\nans = [0] * (n + 1)\\ni = n - 1\\n\\nwhile i >= 0:\\n    p = prefix(s[i:])\\n    ans[i] = 2 + ans[i + 1]\\n    for j in range(len(p)):\\n        z = 1\\n        if (j + 1) % (j + 1 - p[j]) == 0:\\n            z = (j + 1) // (j + 1 - p[j])\\n        res = len(str(z)) + (j + 1) // z + ans[i + j + 1]\\n        ans[i] = min(ans[i], res)\\n    i -= 1\\n\\nprint(ans[0])\\n\"]",
        "difficulty": "interview",
        "input": "mulzibhhlxawrjqunzww\n",
        "output": "21\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/825/F"
    },
    {
        "id": 1871,
        "task_id": 1763,
        "test_case_id": 1,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "3 1 100 100\n1 3 8\n",
        "output": "12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1872,
        "task_id": 1763,
        "test_case_id": 2,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "3 100 1 100\n1 3 8\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1873,
        "task_id": 1763,
        "test_case_id": 3,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "3 100 100 1\n1 3 8\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1874,
        "task_id": 1763,
        "test_case_id": 4,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "5 1 2 4\n5 5 3 6 5\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1875,
        "task_id": 1763,
        "test_case_id": 5,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "5 1 2 2\n5 5 3 6 5\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1876,
        "task_id": 1763,
        "test_case_id": 6,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "10 7 8 3\n3 10 4 9 2 7 6 10 4 8\n",
        "output": "57\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1877,
        "task_id": 1763,
        "test_case_id": 7,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "10 7122 8827 3205\n452685204 144160553 743427456 403576146 888744473 313727757 22025193 886601085 576370788 787974081\n",
        "output": "4081476227653\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1878,
        "task_id": 1763,
        "test_case_id": 8,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "100 52 92 72\n67 100 56 15 0 92 26 74 44 61 6 44 45 19 22 19 9 85 67 78 24 61 81 99 62 84 5 71 11 65 5 97 9 72 11 81 81 64 65 91 52 21 20 53 68 91 4 75 84 88 72 27 48 23 9 65 14 6 54 55 6 1 89 78 40 45 98 45 27 51 94 72 67 81 20 19 38 64 14 40 57 21 82 99 37 92 21 22 30 14 65 93 60 8 63 60 27 30 32 11\n",
        "output": "95816\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1879,
        "task_id": 1763,
        "test_case_id": 9,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "10 4078 1859 607\n160396657 831922387 330524879 901162754 847008736 781626686 496115244 470330335 824475169 620982654\n",
        "output": "639731251326\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1880,
        "task_id": 1763,
        "test_case_id": 10,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "10 1299 4362 8516\n177913931 857265729 858027469 743427538 70328308 334897178 739985290 903278439 602456716 623851298\n",
        "output": "3721721948256\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1881,
        "task_id": 1763,
        "test_case_id": 11,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "10 8521 9022 6018\n195431204 251205289 385530059 954288541 703713298 183134963 983855337 409855471 11842043 921687235\n",
        "output": "9408102096630\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1882,
        "task_id": 1763,
        "test_case_id": 12,
        "question": "You have to restore the wall. The wall consists of $N$ pillars of bricks, the height of the $i$-th pillar is initially equal to $h_{i}$, the height is measured in number of bricks. After the restoration all the $N$ pillars should have equal heights.\n\nYou are allowed the following operations: put a brick on top of one pillar, the cost of this operation is $A$; remove a brick from the top of one non-empty pillar, the cost of this operation is $R$; move a brick from the top of one non-empty pillar to the top of another pillar, the cost of this operation is $M$.\n\nYou cannot create additional pillars or ignore some of pre-existing pillars even if their height becomes $0$.\n\nWhat is the minimal total cost of restoration, in other words, what is the minimal total cost to make all the pillars of equal height?\n\n\n-----Input-----\n\nThe first line of input contains four integers $N$, $A$, $R$, $M$ ($1 \\le N \\le 10^{5}$, $0 \\le A, R, M \\le 10^{4}$) — the number of pillars and the costs of operations.\n\nThe second line contains $N$ integers $h_{i}$ ($0 \\le h_{i} \\le 10^{9}$) — initial heights of pillars.\n\n\n-----Output-----\n\nPrint one integer — the minimal cost of restoration.\n\n\n-----Examples-----\nInput\n3 1 100 100\n1 3 8\n\nOutput\n12\n\nInput\n3 100 1 100\n1 3 8\n\nOutput\n9\n\nInput\n3 100 100 1\n1 3 8\n\nOutput\n4\n\nInput\n5 1 2 4\n5 5 3 6 5\n\nOutput\n4\n\nInput\n5 1 2 2\n5 5 3 6 5\n\nOutput\n3",
        "solutions": "[\"n, a, r, m = map(int, input().split())\\nh = list(map(int, input().split()))\\nm = min(m, a+r)\\n\\ndef get(M):\\n\\tup = 0\\n\\tdw = 0\\n\\tfor e in h:\\n\\t\\tif e > M:\\n\\t\\t\\tup += e - M\\n\\t\\telse:\\n\\t\\t\\tdw += M - e\\n\\tans = m * min(dw, up)\\n\\tif dw > up:\\n\\t\\tans += (dw - up) * a\\n\\telse:\\n\\t\\tans += (up - dw) * r\\n\\treturn ans\\n\\n\\nL = 0\\nR = int(1e9)\\nmn = int(1e18)\\n\\nwhile R - L > 10:\\n\\tM1 = L + (R - L) // 3\\n\\tM2 = R - (R - L) // 3\\n\\tV1 = get(M1)\\n\\tV2 = get(M2)\\n\\tmn = min(mn, V1)\\n\\tmn = min(mn, V2)\\n\\tif V1 < V2:\\n\\t\\tR = M2\\n\\telif V2 < V1:\\n\\t\\tL = M1\\n\\telse:\\n\\t\\tL = M1\\n\\t\\tR = M2\\n\\nfor it in range(L, R+1):\\n\\tmn = min(mn, get(it))\\n\\nprint(mn)\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nn, a, r, m = read_ints()\\nh = list(read_ints())\\nh.sort()\\nlo = h[0]\\nhi = h[-1]\\ns = [0]\\nfor i in h:\\n    s.append(s[-1] + i)\\nans = int(1e20)\\nfor i in range(n):\\n    target = h[i]\\n    inc = i * target - s[i]\\n    dec = s[n] - s[i + 1] - (n - i - 1) * target\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\navg = s[n] // n\\nfor target in range(max(0, avg - 1), avg + 2):\\n    inc = 0\\n    dec = 0\\n    for i in h:\\n        if i > target:\\n            dec += i - target\\n        else:\\n            inc += target - i\\n    plan_a = inc * a + dec * r\\n    plan_b = (inc - dec) * a + dec * \\\\\\n        m if inc >= dec else inc * m + (dec - inc) * r\\n    ans = min(ans, min(plan_a, plan_b))\\nprint(ans)\\n\", \"import sys\\nimport math\\nimport bisect\\n\\ndef query_value(A, a, r, m, target):\\n    n = len(A)\\n    more_val = 0\\n    less_val = 0\\n    for i in range(n):\\n        if A[i] > target:\\n            more_val += A[i] - target\\n        elif A[i] < target:\\n            less_val += target - A[i]\\n    move_val = min(more_val, less_val)\\n    val1 = more_val * r + less_val * a\\n    val2 = (more_val - move_val) * r + (less_val - move_val) * a + (move_val) * m\\n    '''\\n    print('n: %d, a, %d, r: %d, m: %d' % (n, a, r, m))\\n    print('more_val: %d, less_val: %d, move_val: %d' % (more_val, less_val, move_val))\\n    print('val1: %d' % (val1))\\n    print('val2: %d' % (val2))\\n    print('target: %d, val: %d' % (target, min(val1, val2)))\\n    '''\\n    return min(val1, val2)\\n\\ndef main():\\n    n, a, r, m = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n    left = min(A)\\n    right = max(A)\\n    while right - left > 2:\\n        #print('left: %d, right: %d' % (left, right))\\n        m1 = left + (right - left) // 3\\n        m2 = left + (right - left) // 3 * 2\\n        val1 = query_value(A, a, r, m, m1)\\n        val2 = query_value(A, a, r, m, m2)\\n        if val1 <= val2:\\n            right = m2\\n        else:\\n            left = m1\\n    B = []\\n    for i in range(left, right + 1):\\n        val = query_value(A, a, r, m, i)\\n        B.append(val)\\n    print(min(B))\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport bisect\\n\\nreadline = sys.stdin.readline\\nreadall = sys.stdin.read\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\n\\ndef solve():\\n    n, a, r, m = nm()\\n    hl = nl()\\n    shl = [0]*(n+1)\\n    hl.sort()\\n    for i in range(n):\\n        shl[i+1] = shl[i] + hl[i]\\n\\n    def cost(x):\\n        lidx = bisect.bisect_left(hl, x)\\n        ridx = bisect.bisect_right(hl, x)\\n        much = shl[-1] - shl[ridx] - x * (n - ridx)\\n        less = x * lidx - shl[lidx]\\n        # print(x, lidx, ridx, much, less)\\n        res = min(m, a+r) * min(much, less)\\n        if much > less:\\n            res += r * (much - less)\\n        else:\\n            res += a * (less - much)\\n        return res\\n\\n    # print([cost(i) for i in range(10)])\\n    lo, hi = min(hl) - 1, max(hl) + 1\\n    while hi - lo > 3:\\n        mlo = (hi + lo*2)//3\\n        mhi = (hi*2 + lo)//3\\n        # print(mlo, cost(mlo))\\n        if cost(mlo) < cost(mhi):\\n            hi = mhi\\n        else:\\n            lo = mlo\\n    print(min(cost(i) for i in range(lo, hi+1)))\\n    return\\n\\nsolve()\\n\\n# T = ni()\\n# for _ in range(T):\\n#     solve()\\n\", \"N, A, R, M = list(map(int, input().split()))\\nif M > A + R:\\n    M = A + R\\n    \\nh = list(map(int, input().split()))\\n\\ndef calc(final):\\n    adds = 0\\n    removes = 0\\n\\n    for v in h:\\n        if v > final:\\n            removes += (v - final)\\n        else:\\n            adds += (final - v)\\n\\n    moves = min(adds, removes)\\n    return M * moves + A * (adds - moves) + R * (removes - moves)\\n\\nlo = -1 #Higher than next\\nhi = 10 ** 9 + 1\\n\\nwhile hi - lo > 1:\\n    test = (lo + hi) // 2\\n\\n    if calc(test) > calc(test + 1):\\n        lo = test\\n    else:\\n        hi = test\\n\\nprint(calc(hi))\\n\", \"n, a, ra, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nif a + ra < m:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(50):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        f1 = p1 * a + q1 * ra\\n        f2 = p2 * a + q2 * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    f1 = p1 * a + q1 * ra\\n    print(f1)\\nelse:\\n    l, r = 0, 10 ** 9 + 1\\n    for _ in range(55):\\n        c1 = (l * 2 + r) // 3\\n        c2 = (l + r * 2) // 3\\n        p1 = 0\\n        p2 = 0\\n        q1 = 0\\n        q2 = 0\\n        for x in h:\\n            if c1 <= x:\\n                q1 += x - c1\\n            else:\\n                p1 += c1 - x\\n            if c2 <= x:\\n                q2 += x - c2\\n            else:\\n                p2 += c2 - x\\n        if p1 > q1:\\n            f1 = q1 * m + (p1 - q1) * a\\n        else:\\n            f1 = p1 * m + (q1 - p1) * ra\\n        if p2 > q2:\\n            f2 = q2 * m + (p2 - q2) * a\\n        else:\\n            f2 = p2 * m + (q2 - p2) * ra\\n        if f1 > f2:\\n            l = c1\\n        else:\\n            r = c2\\n    c1 = l + 1\\n    p1 = 0\\n    q1 = 0\\n    for x in h:\\n        if c1 <= x:\\n            q1 += x - c1\\n        else:\\n            p1 += c1 - x\\n    if p1 > q1:\\n        f1 = q1 * m + (p1 - q1) * a\\n    else:\\n        f1 = p1 * m + (q1 - p1) * ra\\n    print(f1)\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, A, R, M = map(int, input().split())\\n    H = [int(h) for h in input().split()]\\n    H.sort()\\n    tB = [0] * (N + 1)\\n    for i, h in enumerate(H): tB[i+1] = tB[i] + h\\n    minCost = 10 ** 20\\n    for i in range(N):\\n        toAdd = H[i] * i - tB[i]\\n        toSub = tB[N] - tB[i+1] - H[i] * (N - i - 1)\\n        if M >= A + R: minCost = min(minCost, A * toAdd + R * toSub)\\n        else:\\n            mN = min(toAdd, toSub)\\n            minCost = min(minCost, A * (toAdd - mN) + R * (toSub - mN) + M * mN)\\n    if M < A + R:\\n        sumH = sum(H)\\n        lcost = 0\\n        hcost = 0\\n        fH = sumH // N\\n        for i, h in enumerate(H):\\n            if h < fH: lcost += (fH - h) * M\\n            if h > fH + 1: hcost += (h - fH - 1) * M\\n        lcost += (sumH % N) * R\\n        hcost += (N - (sumH % N)) * A\\n        minCost = min(minCost, lcost)\\n        minCost = min(minCost, hcost)\\n    \\n    print(minCost)\\n\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\nfrom itertools import accumulate\\nimport bisect\\n\\nN,A,R,M=list(map(int,input().split()))\\nW=sorted(map(int,input().split()))\\nSUM=list(accumulate(W))\\nSW=SUM[-1]\\n\\nindmin=0\\nindmax=1\\nANS=1<<62\\n\\ndef calc(MINUS,PLUS,A,R,M):\\n\\n    RET1=MINUS*A+PLUS*R\\n    MIN=min(MINUS,PLUS)\\n    \\n    RET2=MIN*M+(MINUS-MIN)*A+(PLUS-MIN)*R\\n\\n    return min(RET1,RET2)\\n\\n\\nwhile indmin<N:\\n    while indmax<N and W[indmax]==W[indmin]:\\n        indmax+=1\\n\\n    ave=W[indmin]\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(MINUS,PLUS,calc(MINUS,PLUS,A,R,M))\\n    \\n    indmin=indmax\\n    indmax+=1\\n\\nAVE=SW//N\\n\\nfor ave in range(max(W[0],AVE-10**4),min(AVE+10**4,W[-1])):\\n    indmin=bisect.bisect_left(W,ave)\\n    if W[indmin]==ave:\\n        continue\\n    indmin,indmax=indmin-1,indmin\\n\\n    MINUS=ave*(indmin+1)-SUM[indmin]\\n    PLUS=SW-SUM[indmax-1]-ave*(N-indmax)\\n\\n    ANS=min(ANS,calc(MINUS,PLUS,A,R,M))\\n\\n    #print(ave,indmin,indmax,MINUS,PLUS,ANS)\\n    \\n\\nprint(ANS)\\n\\n\\n\\n\\n\", \"n,a,r,m = [int(x) for x in input().split()]\\n\\nheight =[int(x) for x in input().split()]\\nhmax = max(height)\\nheight.sort()\\n\\ndef tellCost(h):\\n    cost = 0\\n    add,remove = 0,0\\n    for i in range(n):\\n        if h > height[i]:\\n            add += abs(h-height[i])\\n        else:\\n            remove += abs(h-height[i])\\n    move = min(remove,add)\\n    if a+r >= m:\\n        cost += m*move\\n        if add > remove:\\n            cost += abs(add-remove)*a\\n        else:\\n            cost += abs(add-remove)*r\\n    else:\\n        cost += add*a\\n        cost += remove*r\\n    return cost\\n\\n\\ns,e = 0,hmax\\n\\nwhile s < e:\\n    mid = (s+e)//2\\n    cost1,cost2 = tellCost(mid),tellCost(mid+1)\\n    if cost2 > cost1:\\n        e = mid\\n    else:\\n        s = mid + 1\\nprint(tellCost(s))\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ndef bin(l, r, c):\\n\\tif l == r:\\n\\t\\treturn l\\n\\tm = (l + r + 1) // 2\\n\\tif h[m] <= c:\\n\\t\\treturn bin(m, r, c)\\n\\telse:\\n\\t\\treturn bin(l, m - 1, c)\\n\\ndef cost(c, move):\\n\\tres = 0\\n\\ti = 0\\n\\tif c >= h[-1]:\\n\\t\\ti = n - 1\\n\\telse:\\n\\t\\ti = bin(0, n - 1, c)\\n\\n\\tres += a * ((i + 1) * c - H[i + 1])\\n\\tres += r * (H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\tif move:\\n\\t\\tres -= (a + r - m) * min((i + 1) * c - H[i + 1], H[-1] - H[i + 1] - (n - i - 1) * c)\\n\\treturn res\\n\\nn, a, r, m = list(map(int, input().split()))\\nh = list(map(int, input().split()))\\nh.sort()\\nH = [None] * (n + 1)\\nH[0] = 0\\nfor i in range(1, n + 1):\\n\\tH[i] = H[i - 1] + h[i - 1]\\nmove = m < a + r\\nif not move:\\n\\tprint(min(cost(h[i], move) for i in range(n)))\\nelse:\\n\\ttt = min(cost(H[-1] // n, move), cost(H[-1] // n + 1, move))\\n\\tttt = min(cost(h[i], move) for i in range(n))\\n\\tprint(min(tt, ttt))\\n\", \"import sys\\nfrom copy import copy\\n\\ninput = sys.stdin.readline\\n\\ndef find(l, ile):\\n    pocz = 0\\n    kon = len(l) - 1\\n    while pocz + 1 < kon:\\n        mid = (pocz + kon) // 2\\n        if l[mid] < ile:\\n            pocz = mid\\n        else:\\n            kon = mid\\n    return pocz\\n\\ndef solve(l, sumpref, ile, A, R, M):\\n    pos = find(l, ile)\\n    \\n    dol = ile * (pos + 1) - sumpref[pos]\\n    gora = sumpref[-1] - sumpref[pos] - ile * (len(l) - pos - 1)\\n    \\n    m = min(dol, gora)\\n    return min(dol * A + gora * R, (dol - m) * A + (gora - m) * R + m * M)\\n\\nn, A, R, M = [int(a) for a in input().split()]\\nl = [int(a) for a in input().split()]\\nl.sort()\\npocz = l[0]\\nkon = l[-1]\\nsumpref = l.copy()\\nfor i in range(1, len(sumpref)):\\n    sumpref[i] += sumpref[i - 1]\\n\\nwhile pocz + 6 < kon:\\n    x = (2 * pocz + kon) // 3\\n    y = (pocz + 2 * kon) // 3\\n    \\n    s = [solve(l, sumpref, lol, A, R, M) for lol in [pocz, x, y, kon]]\\n    ms = min(s)\\n    if s[0] == ms or s[1] == ms:\\n        kon = y\\n    else:\\n        pocz = x\\n    \\nprint(min([solve(l, sumpref, lol, A, R, M) for lol in range(pocz, kon + 1)]))\\n\", \"import os\\nimport sys\\nif os.path.exists('/mnt/c/Users/Square/square/codeforces'):\\n    f = iter(open('E.txt').readlines())\\n    def input():\\n        return next(f)  \\nelse:\\n    input = lambda: sys.stdin.readline().strip()\\n\\nfprint = lambda *args: print(*args, flush=True)\\n\\nN, A, R, M = map(int, input().split())\\nH = list(map(int, input().split()))\\nH = sorted(H)\\n\\nM = min(M, A+R)\\n\\ndef calc(height):\\n    for cur in range(len(H)):\\n        if H[cur] >= height:\\n            break\\n    if H[cur] < height:\\n        cur += 1\\n\\n    up, down = 0, 0\\n    # print(height, cur, N, H[cur], H)\\n    for h in H[:cur]:\\n        down += (height-h)\\n    for h in H[cur:]:\\n        up += (h - height)\\n\\n    if up >= down:\\n        return down * M + (up-down) * R\\n    else:\\n        return up * M + (down - up) * A\\n\\n# print(calc(8))\\n\\n# print(Hs)\\nl, r = 0, max(H)+1\\nwhile l + 1 < r:\\n    cur = (l + r) // 2\\n    if calc(cur) < calc(cur+1):\\n        r = cur\\n    else:\\n        l = cur\\n# print(l, r)\\n# print(calc(l), calc(r))\\nprint(min(calc(l), calc(r)))\\n\", \"N,A,R,M=map(int,input().split())\\nh=list(map(int,input().split()))\\nif A*R==0:\\n    print(0)\\n    return\\n\\nif M>A+R:\\n    def condition(num):\\n        test=0\\n        for i in range(N):\\n            if num>h[i]:\\n                test+=A\\n            else:\\n                test-=R\\n        return 0>=test\\n    start=1\\n    end=10**10\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition(end):\\n        ans=0\\n        for i in range(N):\\n            if end>h[i]:\\n                ans+=A*(end-h[i])\\n            else:\\n                ans+=R*(h[i]-end)\\n        print(ans)\\n    elif condition(start):\\n        ans=0\\n        for i in range(N):\\n            if start>h[i]:\\n                ans+=A*(start-h[i])\\n            else:\\n                ans+=R*(h[i]-start)\\n        print(ans)\\n    else:\\n        print(R*sum(h))\\nelse:\\n    H=sum(h)\\n    q=H//N\\n    #0~q\\u5f3e\\u3067\\u8003\\u3048\\n    test1=0\\n    def condition1(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]<num))\\n        return 0>=M*count-R*N\\n\\n    start=1\\n    end=q\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition1(test):\\n            start=test\\n        else:\\n            end=test\\n    if condition1(end):\\n        for i in range(N):\\n            if end>h[i]:\\n                test1+=M*(end-h[i])\\n        test1+=R*(H-N*end)\\n    elif condition1(start):\\n        for i in range(N):\\n            if start>h[i]:\\n                test1+=M*(start-h[i])\\n        test1+=R*(H-N*start)\\n    else:\\n        test1=H*R\\n\\n    #q+1~max(h)\\n    test2=0\\n    def condition2(num):\\n        count=0\\n        for i in range(N):\\n            count+=int((h[i]>num))\\n        return 0>=count*M-A*N\\n    start=q+1\\n    end=max(h)-1\\n    while end-start>1:\\n        test=(end+start)//2\\n        if condition2(test):\\n            end=test\\n        else:\\n            start=test\\n    if condition2(start):\\n        for i in range(N):\\n            if h[i]>=start:\\n                test2+=M*(h[i]-start)\\n        test2+=A*(N*start-H)\\n    elif condition2(end):\\n        for i in range(N):\\n            if h[i]>=end:\\n                test2+=M*(h[i]-end)\\n        test2+=A*(N*end-H)\\n    else:\\n        test2=A*(N*max(h)-H)\\n    print(min(test1,test2))\", \"\\nimport bisect\\nN, A, R, M = list(map(int, input().split()))\\n\\naa = sorted(map(int, input().split()))\\n\\nraa = [0]\\nfor a in aa:\\n    raa.append(raa[-1] + a)\\n\\nans = 10 ** 15\\n\\n\\n# a \\u306b\\u63c3\\u3048\\u308b\\u6642\\u306e\\u30b3\\u30b9\\u30c8\\ndef calc(a):\\n    i = bisect.bisect_right(aa, a)\\n    add_n = a * i - raa[i]\\n    rem_n = (raa[-1] - raa[i]) - (a * (N - i))\\n\\n    # move \\u3059\\u308b\\n    if rem_n < add_n:\\n        tmp1 = rem_n * M + (add_n - rem_n) * A\\n    else:\\n        tmp1 = add_n * M + (rem_n - add_n) * R\\n\\n    # move \\u3057\\u306a\\u3044\\n    tmp2 = rem_n * R + add_n * A\\n\\n    return min(tmp1, tmp2)\\n\\n\\nans = min([calc(a) for a in set(aa)])\\n\\ntmp = sum(aa) // N\\n\\nans = min([ans, calc(tmp), calc(tmp + 1)])\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "10 7901 3681 1769\n286577406 276548631 281628869 796553324 632065579 736405456 932758091 211399795 789823590 924555879\n",
        "output": "2284083174243\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1355/E"
    },
    {
        "id": 1883,
        "task_id": 1774,
        "test_case_id": 1,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "HHHH\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1884,
        "task_id": 1774,
        "test_case_id": 2,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "HQHQH\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1885,
        "task_id": 1774,
        "test_case_id": 3,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "HHQHHQH\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1886,
        "task_id": 1774,
        "test_case_id": 4,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "HHQQHHQQHH\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1887,
        "task_id": 1774,
        "test_case_id": 5,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "Q\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1888,
        "task_id": 1774,
        "test_case_id": 6,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "HHHHHHHHHHQHHH\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1889,
        "task_id": 1774,
        "test_case_id": 7,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "HHQHQQQHHH\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1890,
        "task_id": 1774,
        "test_case_id": 8,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "QQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQHQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQ\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1891,
        "task_id": 1774,
        "test_case_id": 9,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "QHQHHQQQQQQQQQQQHQQHQHQQQQQQHQHQQQQQQQQQQQHQQQQQQQHQQHQQHQQQQQQQQQQQQQQQQQQQQHHQQQQQQQQQQHQQQQHHQHQQHQQQQQHQQQQQQQHQQQQQHQ\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1892,
        "task_id": 1774,
        "test_case_id": 10,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "QHQHQQHQQQQHQHHQQHQQHQHQQQQQQQHHQHHQQQHQQQQQQQQHQQQQQHQQHHQQHQQHQQHQQQHQQHQQHQQQQQQQQQHQQQQQQHQHQQQQQHQQQQHHQQQQQQQQQQQQQQQQHQQHQQQQH\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1893,
        "task_id": 1774,
        "test_case_id": 11,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "HQQQHQQHQHQQQQHQQQHQHQHQQQHQQQQHQQHHQQQQQHQQQQHQQQQQHQQQQQHQQQQQHHQQQQQHQQQQHHQQHHHQHQQQQQQQQHQHQHQHQQQQQQHHHQQHHQQQHQQQHQQQQQQHHQQQHQHQQHQHHHQQ\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1894,
        "task_id": 1774,
        "test_case_id": 12,
        "question": "The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ...\n\n\n-----Input-----\n\nThe only line of the input is a string between 1 and 10^6 characters long.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\nHHHH\n\nOutput\nYes\n\nInput\nHQHQH\n\nOutput\nNo\n\nInput\nHHQHHQH\n\nOutput\nNo\n\nInput\nHHQQHHQQHH\n\nOutput\nYes\n\n\n\n-----Note-----\n\nThe rest of the problem statement was destroyed by a stray raccoon. We are terribly sorry for the inconvenience.",
        "solutions": "[\"import sys\\n\\ns = input()\\nqc = s.count('Q')\\nqs = int(qc ** 0.5)\\nhc = s.count('H')\\nif qs == 0:\\n    print('Yes')\\n    return\\nif not qc == qs ** 2:\\n    print('No')\\n    return\\nif not hc % (qs + 1) == 0:\\n    print('No')\\n    return\\n\\nt = s.split('Q')\\npre = len(t[0]) // 2\\nsuf = 0 if len(t) == 1 else len(t[-1]) // 2\\na = ['H' * pre] + t[1 : qs] + ['H' * suf]\\no = [c for c in 'Q'.join(a)]\\ng = []\\nfor c in o:\\n    if c == 'H':\\n        g += ['H']\\n    else:\\n        g += o\\n\\nprint('Yes' if ''.join(g) == s else 'No')\\n\", \"a = input()\\nb = []\\nh = ''\\nc = 0\\nfor i in a:\\n\\tif i == 'Q':\\n\\t\\tc += 1\\nif c == 0:\\n\\tprint('Yes')\\n\\treturn\\nr = -1\\nfor i in range(1001):\\n\\tif i*i == c:\\n\\t\\tr = i\\n\\t\\tbreak\\nif r == -1:\\n\\tprint('No')\\n\\treturn\\nh = [a.split('Q')[0], a.split('Q')[-1]]\\nc = [len(h[0]), len(h[1])]\\nif c[0] % 2 != 0 or c[1] % 2 != 0:\\n\\tprint('No')\\n\\treturn\\nc[0] //= 2\\nc[1] //= 2\\nresp = ''\\ni = c[0]\\nwhile True:\\n\\tif i >= len(a):\\n\\t\\tbreak\\n\\tif r == 0 and a[i] == 'Q':\\n\\t\\tbreak\\n\\tresp += a[i]\\n\\tif r == 0 and a[i] == 'H':\\n\\t\\tc[1] -= 1\\n\\tif c[1] == 0 and r == 0:\\n\\t\\tbreak\\n\\tif a[i] == 'Q':\\n\\t\\tr -= 1\\n\\tif r == -1:\\n\\t\\tprint('No')\\n\\t\\treturn\\n\\ti += 1\\n\\n\\ndef hq(a):\\n\\tresp = ''\\n\\tfor i in a:\\n\\t\\tif i == 'H':\\n\\t\\t\\tresp += 'H'\\n\\t\\telse:\\n\\t\\t\\tresp += a\\n\\treturn resp\\n\\nif a == hq(resp):\\n\\tprint('Yes')\\nelse:\\n\\tprint('No')\\n\"]",
        "difficulty": "interview",
        "input": "HQQQQQQQHQQQQHQHQQQHHQHHHQQHQQQQHHQHHQHHHHHHQQQQQQQQHHQQQQQHHQQQQHHHQQQQQQQQHQQQHQHQQQQQQHHHQHHQHQHHQQQQQHQQHQHQQQHQHQHHHHQQHQHQQQQQHQQQHQQQHQQHQHQQHQQQQQQ\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/290/E"
    },
    {
        "id": 1895,
        "task_id": 1848,
        "test_case_id": 1,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "5\n20 30 10 50 40\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1896,
        "task_id": 1848,
        "test_case_id": 2,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "4\n200 100 100 200\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1897,
        "task_id": 1848,
        "test_case_id": 3,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "10\n2 2 2 2 2 2 2 2 2 2\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1898,
        "task_id": 1848,
        "test_case_id": 4,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "1\n1000\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1899,
        "task_id": 1848,
        "test_case_id": 5,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "2\n444 333\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1900,
        "task_id": 1848,
        "test_case_id": 6,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "100\n9 9 72 55 14 8 55 58 35 67 3 18 73 92 41 49 15 60 18 66 9 26 97 47 43 88 71 97 19 34 48 96 79 53 8 24 69 49 12 23 77 12 21 88 66 9 29 13 61 69 54 77 41 13 4 68 37 74 7 6 29 76 55 72 89 4 78 27 29 82 18 83 12 4 32 69 89 85 66 13 92 54 38 5 26 56 17 55 29 4 17 39 29 94 3 67 85 98 21 14\n",
        "output": "95\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1901,
        "task_id": 1848,
        "test_case_id": 7,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "1\n995\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1902,
        "task_id": 1848,
        "test_case_id": 8,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "10\n103 101 103 103 101 102 100 100 101 104\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1903,
        "task_id": 1848,
        "test_case_id": 9,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "20\n102 100 102 104 102 101 104 103 100 103 105 105 100 105 100 100 101 105 105 102\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1904,
        "task_id": 1848,
        "test_case_id": 10,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "20\n990 994 996 999 997 994 990 992 990 993 992 990 999 999 992 994 997 990 993 998\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1905,
        "task_id": 1848,
        "test_case_id": 11,
        "question": "There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\n\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1 ≤ i ≤ n - 1), such that a_{i} + 1 > a_{i}.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of painting.\n\nThe second line contains the sequence a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} means the beauty of the i-th painting.\n\n\n-----Output-----\n\nPrint one integer — the maximum possible number of neighbouring pairs, such that a_{i} + 1 > a_{i}, after the optimal rearrangement.\n\n\n-----Examples-----\nInput\n5\n20 30 10 50 40\n\nOutput\n4\n\nInput\n4\n200 100 100 200\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, the optimal order is: 10, 20, 30, 40, 50.\n\nIn the second sample, the optimal order is: 100, 200, 100, 200.",
        "solutions": "[\"from collections import defaultdict\\nn = int(input())\\nA = [int(x) for x in input().split()]\\nD = defaultdict(int)\\nfor a in A: D[a] += 1\\nS = set(D.keys())\\nans = len(S) - 1\\nwhile S:\\n    for k in D:\\n        D[k] -= 1\\n        if D[k] <= 0 and k in S:\\n            S.remove(k)\\n    ans += len(S) - 1\\nprint(ans + 1)\\n\", \"def seq(a, new):\\n    nonlocal count\\n    for i in range(1, len(a)):\\n        if a[i] == a[i - 1]:\\n            new.append(a[i])\\n    if len(a) > 1:\\n        count += len(a) - len(new) - 1\\n    if len(new) == 0:\\n        return\\n    else:\\n        a = new[:]\\n        new = []\\n        seq(a, new)\\n\\nn = int(input())\\na = list(map(int, input().split()))\\na.sort()\\nnew = []\\ncount = 0\\nseq(a, new)\\nprint(count)\\n\\n    \\n    \\n\", \"#! /usr/bin/env python3\\n\\ndef main():\\n    input()\\n    nums = map(int, input().split())\\n\\n    nums = sorted(nums)\\n    length = len(nums)\\n    count = 0\\n    last_num = nums[0]\\n    for i in range(length):\\n        if nums[i] is None:\\n            continue\\n        last_num = nums[i]\\n        for j in range(i + 1, length):\\n            if nums[j] is None:\\n                continue\\n            if nums[j] > last_num:\\n                count += 1\\n                last_num = nums[j]\\n                nums[j] = None\\n\\n    print(count)\\n\\n\\nmain()\", \"#!/usr/bin/env python3\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nA = sorted(A)\\nA = [(a, True) for a in A]\\n\\nhappiness = 0\\nuses_left = N\\n\\nwhile True:\\n\\tlast_a = None\\n\\tfor i in range(len(A)):\\n\\t\\ta, usable = A[i]\\n\\t\\tif not usable: continue\\n\\t\\tif last_a is None:\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tcontinue\\n\\t\\tif last_a < a:\\n\\t\\t\\thappiness += 1\\n\\t\\t\\tA[i] = (a, False)\\n\\t\\t\\tuses_left -= 1\\n\\t\\t\\tlast_a = a\\n\\t\\t\\tcontinue\\n\\tif uses_left == 0: break\\n\\nprint(happiness)\", \"from collections import *\\nans=0\\nc=Counter()\\nn=int(input())\\nfor x in input().split(): c[int(x)]+=1\\nwhile len(c)>1:\\n    ans+=len(c)-1\\n    for x in set(c): \\n        c[x]-=1\\n        if c[x]==0: del c[x]\\nprint(ans)\\n\", \"n = int(input())\\nA = list(map(int, input().split()))\\nA.sort()\\nfor i in range(n):\\n    A[i] = [A[i], 0]\\nanswer = 0\\nper2 = -float('infinity')\\nper = 0\\nfor i in range(n-1):\\n    if A[i][1] == 0:\\n        A[i][1] = 1\\n        per = A[i][0]\\n        for j in range(i+1, n):\\n            if A[j][1] == 0:\\n                if A[j][0] > per:\\n                    per = A[j][0]\\n                    A[j][1] = 1\\n                    answer+=1\\nprint(answer)\\n                    \\n    \\n\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nc = [0] * 1001\\nfor ai in a:\\n    c[ai] += 1\\nans = 0\\nfor t in range(max(c)):\\n    was = False\\n    for i in range(1, 1001):\\n        if c[i] > 0:\\n            if was:\\n                ans += 1\\n            else:\\n                was = True\\n            c[i] -= 1\\nprint(ans)\\n            \\n\", \"read = lambda: list(map(int, input().split()))\\nn = int(input())\\na = list(read())\\nwasr = [False] * n\\nwasl = [False] * n\\ncnt = 0\\ninf = 10 ** 9\\nfor i in range(n):\\n    if wasl[i]: continue\\n    wasl[i] = True\\n    cur = a[i]\\n    Min = inf\\n    ind = -1\\n    for j in range(n):\\n        if wasr[j]: continue\\n        if cur < a[j] < Min:\\n            Min = a[j]\\n            ind = j\\n    if ind != -1:\\n        wasr[ind] = True\\n        cnt += 1\\n        #print(cur, a[ind])\\nprint(cnt)\\n        \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = {}\\nfor x in a:\\n    if x in b:\\n        b[x] += 1\\n    else:\\n        b[x] = 1\\nsumma = 0\\nwhile len(b) > 0:\\n    count = 0\\n    c = b.copy()\\n    for x in b:\\n        c[x] -= 1\\n        if c[x] == 0:\\n            c.pop(x)\\n        count += 1\\n    b = c.copy()\\n    summa += (count - 1)\\nprint(summa)\\n\", \"from collections import Counter\\n\\n\\ndef read_input():\\n    N = int(input())\\n    A = [int(i) for i in input().strip().split()]\\n    return A\\n\\n\\ndef solution(A):\\n    c = Counter(A)\\n    ans = 0\\n    stop = False\\n    while not stop:\\n        stop = True\\n        count = 0\\n        for key in c:\\n            if c[key]:\\n                count += 1\\n                stop = False\\n                c[key] -= 1\\n        if count:\\n            ans += (count - 1)\\n    return ans\\n\\n\\ndef __starting_point():\\n    A = read_input()\\n    print(solution(A))\\n\\n__starting_point()\", \"import functools\\nimport math\\nimport sys\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nans = 0\\na.sort()\\nwhile len(a) > 1:\\n    t = []\\n    for i in range(1, len(a)):\\n        if a[i] > a[i - 1]:\\n            ans += 1\\n        else:\\n            t.append(a[i])\\n            #temp += 1\\n    a = t\\nprint(ans)\", \"from collections import Counter\\ninput()\\na = map(int, input().split())\\nb = Counter(a)\\nb = list(b.values())\\nprint(sum(b) - max(b))\", \"n = int(input())\\npictures = list(map(int, input().split()))\\nd = dict()\\nfor i in pictures:\\n    d[i] = 0\\nfor i in pictures:\\n    d[i] += 1\\na = sorted(d.values())\\ni = 1\\nr = 0\\nl = len(a) - 1\\ns = 0\\nwhile i < len(a):\\n    c = i\\n    while (i < len(a)) and (a[i] == a[i - 1]):\\n        i += 1\\n    s += l * (a[i - 1] - r)\\n    l -= (i - c + 1)\\n    r = a[i - 1]\\n    i += 1\\nprint(s)\", \"n=int(input().strip())\\nd={}\\nans=0\\nfor i in input().strip().split():\\n\\tif i in d:\\n\\t\\td[i]=d[i]+1\\n\\telse:\\n\\t\\td[i]=1\\nwhile d:\\n\\tl=list(d.keys())\\n\\tfor i in l:\\n\\t\\tif d[i]==1:\\n\\t\\t\\tdel d[i]\\n\\t\\telse:\\n\\t\\t\\td[i]=d[i]-1\\n\\tans=ans+len(l)-1\\nprint(ans)\", \"n=int(input())\\nx=[int(z) for z in input().split()]\\nx.sort()\\ny=[]\\ncur=x[0]\\ncurs=1\\ni=1\\ny=[]\\nwhile i<n:\\n    r=x[i]\\n    if r==cur:\\n        curs+=1\\n    else:\\n        d=[cur]*curs\\n        y+=[d]\\n        curs=1\\n        cur=r\\n    i+=1\\ny+=[[cur]*curs]\\nres=0\\n\\nwhile len(y)>1:\\n    u=[]\\n    for h in y:\\n        h.pop()\\n        if h!=[]:\\n            u+=[h]\\n    res+=len(y)-1\\n    y=u[:]\\nprint(res)\\n        \\n\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"# ATTENTION:\\n# never attend codeforces if u're drunk\\nn = int(input())\\na = sorted([int(x) for x in input().split()])\\nc = dict()\\nfor x in a: c[x] = c[x]+1 if x in c else 1\\nuniq = sorted(c.keys())\\nC=0\\nwhile n>0:\\n    t = 0\\n    for u in uniq:\\n        if c[u] == 0:\\n            continue\\n        c[u] -= 1\\n        n -= 1\\n        t += 1\\n    C += t-1\\nprint(C)\\n\", \"size = 1001\\nn = int(input())\\na = [0] * size\\nans = 0\\nnum = map(int, input().split())\\nfor b in num:\\n    a[b] += 1\\n    \\nwhile a.count(0) != size:\\n    cnt = 0\\n    for i in range(size):\\n        if a[i]:\\n            cnt += 1\\n            a[i] -= 1\\n    ans += cnt - 1\\n\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    lst = list(map(int,input().split(' ')))\\n    lst.sort()\\n    h,i = 0,0\\n    trav = []       #tracks travelled\\n    while i<n-1:\\n        if i in trav:\\n            i+=1\\n            continue\\n        j = i+1\\n        s = lst[i]\\n        while j<n:\\n            #print(j,trav)\\n            if lst[j]>s  and j not in trav:\\n                h+=1\\n                s=lst[j]\\n                trav.append(j)\\n            j+=1\\n        trav.append(i)\\n        i+=1  \\n    print(h)\\n'''\\nB. Beautiful Paintings\\ntime limit per test\\n1 second\\nmemory limit per test\\n256 megabytes\\ninput\\nstandard input\\noutput\\nstandard output\\n\\nThere are n pictures delivered for the new exhibition. The i-th painting has beauty ai. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.\\n\\nWe are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of a in any order. What is the maximum possible number of indices i (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009n\\u2009-\\u20091), such that ai\\u2009+\\u20091\\u2009>\\u2009ai.\\nInput\\n\\nThe first line of the input contains integer n (1\\u2009\\u2264\\u2009n\\u2009\\u2264\\u20091000) \\u2014 the number of painting.\\n\\nThe second line contains the sequence a1,\\u2009a2,\\u2009...,\\u2009an (1\\u2009\\u2264\\u2009ai\\u2009\\u2264\\u20091000), where ai means the beauty of the i-th painting.\\nOutput\\n\\nPrint one integer \\u2014 the maximum possible number of neighbouring pairs, such that ai\\u2009+\\u20091\\u2009>\\u2009ai, after the optimal rearrangement.\\nExamples\\nInput\\n\\n5\\n20 30 10 50 40\\n\\nOutput\\n\\n4\\n\\nInput\\n\\n4\\n200 100 100 200\\n\\nOutput\\n\\n2\\n\\nNote\\n\\nIn the first sample, the optimal order is: 10,\\u200920,\\u200930,\\u200940,\\u200950.\\n\\nIn the second sample, the optimal order is: 100,\\u2009200,\\u2009100,\\u2009200.\\n'''\\n        \\n        \\n        \\n            \\n        \\n\\n\\n    \\n\\n__starting_point()\", \"n = int(input())\\na = sorted(list(map(int,input().split())))\\nvis = [False for i in range(n)]\\nfor i in range(n) :\\n    for j in range(i+1,n) :\\n        if i==j : continue\\n        if a[i]<a[j] and  not vis[j] :\\n            vis[j] = True\\n            break\\n\\nprint(sum([fact for fact in vis]))\\n            \\n\", \"n = int(input())\\ncount = [0] * 1001\\nc = [0] * 1001\\npictures = list(map(int, input().split()))\\nfor i in pictures:\\n    count[i] += 1\\nres = 0\\nwhile count != c:\\n    res -= 1\\n    for i in range(len(count)):\\n        if count[i] > 0:\\n            count[i] -= 1\\n            res += 1\\nprint(res)\\n\", \"n = int(input())\\nx = [0 for i in range(0, 1010)]\\nfor i in map(int, input().split()):\\n    x[i] += 1\\nd = 0\\nfor i in range(0, 1010):\\n    d = max(d, x[i])\\nprint(n - d)\", \"from collections import Counter\\nn = int(input())\\nprint(n - Counter(list(map(int, input().split()))).most_common(1)[0][1])\\n\"]",
        "difficulty": "interview",
        "input": "100\n1 8 3 8 10 8 5 3 10 3 5 8 4 5 5 5 10 3 6 6 6 6 6 7 2 7 2 4 7 8 3 8 7 2 5 6 1 5 5 7 9 7 6 9 1 8 1 3 6 5 1 3 6 9 5 6 8 4 8 6 10 9 2 9 3 8 7 5 2 10 2 10 3 6 5 5 3 5 10 2 3 7 10 8 8 4 3 4 9 6 10 7 6 6 6 4 9 9 8 9\n",
        "output": "84\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/651/B"
    },
    {
        "id": 1906,
        "task_id": 1858,
        "test_case_id": 2,
        "question": "Find out if it is possible to partition the first $n$ positive integers into two non-empty disjoint sets $S_1$ and $S_2$ such that:$\\mathrm{gcd}(\\mathrm{sum}(S_1), \\mathrm{sum}(S_2)) > 1$ \n\nHere $\\mathrm{sum}(S)$ denotes the sum of all elements present in set $S$ and $\\mathrm{gcd}$ means thegreatest common divisor.\n\nEvery integer number from $1$ to $n$ should be present in exactly one of $S_1$ or $S_2$.\n\n\n-----Input-----\n\nThe only line of the input contains a single integer $n$ ($1 \\le n \\le 45\\,000$)\n\n\n-----Output-----\n\nIf such partition doesn't exist, print \"No\" (quotes for clarity).\n\nOtherwise, print \"Yes\" (quotes for clarity), followed by two lines, describing $S_1$ and $S_2$ respectively.\n\nEach set description starts with the set size, followed by the elements of the set in any order. Each set must be non-empty.\n\nIf there are multiple possible partitions — print any of them.\n\n\n-----Examples-----\nInput\n1\n\nOutput\nNo\nInput\n3\n\nOutput\nYes\n1 2\n2 1 3 \n\n\n\n-----Note-----\n\nIn the first example, there is no way to partition a single number into two non-empty sets, hence the answer is \"No\".\n\nIn the second example, the sums of the sets are $2$ and $4$ respectively. The $\\mathrm{gcd}(2, 4) = 2 > 1$, hence that is one of the possible answers.",
        "solutions": "[\"n = int(input())\\nif n <= 2:\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\\tprint(1, (n + 1) // 2)\\n\\tans = []\\n\\tfor i in range(1, n + 1):\\n\\t\\tif i != (n + 1) // 2:\\n\\t\\t\\tans.append(i)\\n\\tprint(n - 1, *ans)\\n\"]",
        "difficulty": "interview",
        "input": "3\n",
        "output": "Yes\n1 2\n2 1 3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1038/B"
    },
    {
        "id": 1907,
        "task_id": 1858,
        "test_case_id": 6,
        "question": "Find out if it is possible to partition the first $n$ positive integers into two non-empty disjoint sets $S_1$ and $S_2$ such that:$\\mathrm{gcd}(\\mathrm{sum}(S_1), \\mathrm{sum}(S_2)) > 1$ \n\nHere $\\mathrm{sum}(S)$ denotes the sum of all elements present in set $S$ and $\\mathrm{gcd}$ means thegreatest common divisor.\n\nEvery integer number from $1$ to $n$ should be present in exactly one of $S_1$ or $S_2$.\n\n\n-----Input-----\n\nThe only line of the input contains a single integer $n$ ($1 \\le n \\le 45\\,000$)\n\n\n-----Output-----\n\nIf such partition doesn't exist, print \"No\" (quotes for clarity).\n\nOtherwise, print \"Yes\" (quotes for clarity), followed by two lines, describing $S_1$ and $S_2$ respectively.\n\nEach set description starts with the set size, followed by the elements of the set in any order. Each set must be non-empty.\n\nIf there are multiple possible partitions — print any of them.\n\n\n-----Examples-----\nInput\n1\n\nOutput\nNo\nInput\n3\n\nOutput\nYes\n1 2\n2 1 3 \n\n\n\n-----Note-----\n\nIn the first example, there is no way to partition a single number into two non-empty sets, hence the answer is \"No\".\n\nIn the second example, the sums of the sets are $2$ and $4$ respectively. The $\\mathrm{gcd}(2, 4) = 2 > 1$, hence that is one of the possible answers.",
        "solutions": "[\"n = int(input())\\nif n <= 2:\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\\tprint(1, (n + 1) // 2)\\n\\tans = []\\n\\tfor i in range(1, n + 1):\\n\\t\\tif i != (n + 1) // 2:\\n\\t\\t\\tans.append(i)\\n\\tprint(n - 1, *ans)\\n\"]",
        "difficulty": "interview",
        "input": "20\n",
        "output": "Yes\n1 10\n19 1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1038/B"
    },
    {
        "id": 1908,
        "task_id": 1858,
        "test_case_id": 8,
        "question": "Find out if it is possible to partition the first $n$ positive integers into two non-empty disjoint sets $S_1$ and $S_2$ such that:$\\mathrm{gcd}(\\mathrm{sum}(S_1), \\mathrm{sum}(S_2)) > 1$ \n\nHere $\\mathrm{sum}(S)$ denotes the sum of all elements present in set $S$ and $\\mathrm{gcd}$ means thegreatest common divisor.\n\nEvery integer number from $1$ to $n$ should be present in exactly one of $S_1$ or $S_2$.\n\n\n-----Input-----\n\nThe only line of the input contains a single integer $n$ ($1 \\le n \\le 45\\,000$)\n\n\n-----Output-----\n\nIf such partition doesn't exist, print \"No\" (quotes for clarity).\n\nOtherwise, print \"Yes\" (quotes for clarity), followed by two lines, describing $S_1$ and $S_2$ respectively.\n\nEach set description starts with the set size, followed by the elements of the set in any order. Each set must be non-empty.\n\nIf there are multiple possible partitions — print any of them.\n\n\n-----Examples-----\nInput\n1\n\nOutput\nNo\nInput\n3\n\nOutput\nYes\n1 2\n2 1 3 \n\n\n\n-----Note-----\n\nIn the first example, there is no way to partition a single number into two non-empty sets, hence the answer is \"No\".\n\nIn the second example, the sums of the sets are $2$ and $4$ respectively. The $\\mathrm{gcd}(2, 4) = 2 > 1$, hence that is one of the possible answers.",
        "solutions": "[\"n = int(input())\\nif n <= 2:\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\\tprint(1, (n + 1) // 2)\\n\\tans = []\\n\\tfor i in range(1, n + 1):\\n\\t\\tif i != (n + 1) // 2:\\n\\t\\t\\tans.append(i)\\n\\tprint(n - 1, *ans)\\n\"]",
        "difficulty": "interview",
        "input": "4\n",
        "output": "Yes\n1 2\n3 1 3 4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1038/B"
    },
    {
        "id": 1909,
        "task_id": 1877,
        "test_case_id": 1,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "1\nU\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1910,
        "task_id": 1877,
        "test_case_id": 2,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "6\nRURUUR\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1911,
        "task_id": 1877,
        "test_case_id": 3,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "7\nURRRUUU\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1912,
        "task_id": 1877,
        "test_case_id": 4,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "100\nRUURUURRUURUUUUURRUUURRRRUURRURRURRRRUUUUUURRUURRRRURUUURUURURRRRRURUURRUURUURRUUURUUUUUURRUUUURUUUR\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1913,
        "task_id": 1877,
        "test_case_id": 5,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "7\nURURRUR\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1914,
        "task_id": 1877,
        "test_case_id": 6,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "15\nRUURRRRURRUUUUU\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1915,
        "task_id": 1877,
        "test_case_id": 7,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "6\nUURRRU\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1916,
        "task_id": 1877,
        "test_case_id": 8,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "7\nRRRRRRR\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1917,
        "task_id": 1877,
        "test_case_id": 9,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "2\nUR\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1918,
        "task_id": 1877,
        "test_case_id": 10,
        "question": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built along the identity line (i.e. the line with the equation x = y). Any point below the wall belongs to the first kingdom while any point above the wall belongs to the second kingdom. There is a gate at any integer point on the line (i.e. at points (0, 0), (1, 1), (2, 2), ...). The wall and the gates do not belong to any of the kingdoms. \n\nFafa is at the gate at position (0, 0) and he wants to walk around in the two kingdoms. He knows the sequence S of moves he will do. This sequence is a string where each character represents a move. The two possible moves Fafa will do are 'U' (move one step up, from (x, y) to (x, y + 1)) and 'R' (move one step right, from (x, y) to (x + 1, y)). \n\nFafa wants to know the number of silver coins he needs to pay to walk around the two kingdoms following the sequence S. Note that if Fafa visits a gate without moving from one kingdom to another, he pays no silver coins. Also assume that he doesn't pay at the gate at point (0, 0), i. e. he is initially on the side he needs. \n\n\n-----Input-----\n\nThe first line of the input contains single integer n (1 ≤ n ≤ 10^5) — the number of moves in the walking sequence.\n\nThe second line contains a string S of length n consisting of the characters 'U' and 'R' describing the required moves. Fafa will follow the sequence S in order from left to right.\n\n\n-----Output-----\n\nOn a single line, print one integer representing the number of silver coins Fafa needs to pay at the gates to follow the sequence S.\n\n\n-----Examples-----\nInput\n1\nU\n\nOutput\n0\n\nInput\n6\nRURUUR\n\nOutput\n1\n\nInput\n7\nURRRUUU\n\nOutput\n2\n\n\n\n-----Note-----\n\nThe figure below describes the third sample. The red arrows represent the sequence of moves Fafa will follow. The green gates represent the gates at which Fafa have to pay silver coins. [Image]",
        "solutions": "[\"n = int(input())\\ns = input()\\nx = 0\\ny = 0\\nans = 0\\npred = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        continue\\n    if x > y:\\n        cur = 0\\n    else:\\n        cur = 1\\n    if cur != pred and pred != -1:\\n        ans += 1\\n    pred = cur\\nprint(ans)\\n\", \"N = int(input())\\nmoves = input()\\n\\n# print(N)\\n# print(moves)\\n\\npos_x, pos_y = 0, 0\\ncoins = 0\\nkingdom = None\\nfor m in moves:\\n    if m == \\\"R\\\":\\n        pos_x += 1\\n    else:\\n        pos_y += 1\\n    if pos_x < pos_y:\\n        if kingdom == \\\"lower\\\":\\n            coins += 1\\n        kingdom = \\\"upper\\\"\\n    if pos_x > pos_y:\\n        if kingdom == \\\"upper\\\":\\n            coins += 1\\n        kingdom = \\\"lower\\\"\\n\\nprint(coins)\\n\", \"n = int(input())\\ns = input()\\nbal = 0\\nlast = 0\\nans = 0\\nfor i in s:\\n    if i == 'U':\\n        bal += 1\\n    else:\\n        bal -= 1\\n    if bal == 0:\\n        continue\\n    if last * bal < 0:\\n        ans += 1\\n    last = bal\\nprint(ans)\", \"n = int (input())\\ns = input()\\n\\nplace = 0\\nres = 0\\nprev_place = 0\\n\\nfor c  in s:\\n    if c == \\\"U\\\":\\n        place += 1\\n    else:\\n        place -= 1\\n    if place != 0 :\\n        if place *prev_place <0:\\n            res += 1\\n        prev_place = place\\n\\nprint(res)\\n\\n\", \"n=int(input())\\ns=input()\\nx=0\\ny=0\\nans=0\\nfor i in range(n-1):\\n    if s[i]=='U':\\n        y+=1\\n    else:\\n        x+=1\\n    if y==x and s[i+1]==s[i]:\\n        ans+=1\\nprint(ans)\\n\", \"n = int(input())\\nst = input()\\nisUp = st[0] == 'U'\\nx = 0\\ny = 0\\nif st[0] == 'U':\\n\\ty += 1\\nelse:\\n\\tx += 1\\nc = 0\\nfor i in range(1,n):\\n\\tif isUp and x == y and st[i] == 'R':\\n\\t\\tc += 1\\n\\t\\tisUp = False\\n\\telif not isUp and x == y and st[i] == 'U':\\n\\t\\tc += 1\\n\\t\\tisUp = True\\n\\tif st[i] == 'U':\\n\\t\\ty += 1\\n\\telse:\\n\\t\\tx += 1\\nprint(c)\", \"def getCoord(x, y, t):\\n\\tif t == 'U':\\n\\t\\treturn (x, y + 1)\\n\\treturn (x + 1, y)\\n\\nn = int(input())\\ns = input()\\nx, y = getCoord(0, 0, s[0])\\nt = 1\\nif x < y:\\n\\tt = 0\\nans = 0\\nfor ch in s[1:]:\\n\\tx, y = getCoord(x, y, ch)\\n\\tif x == y:\\n\\t\\tcontinue\\n\\tnt = 1\\n\\tif x < y:\\n\\t\\tnt = 0\\n\\tif t != nt:\\n\\t\\tt = nt\\n\\t\\tans += 1\\nprint(ans)\", \"n = int(input())\\ns = input()\\nr = 0\\nu = 0\\ncst = 0\\nif s[0] == 'R': r+=1\\nelse: u += 1\\nfor i in range(1,n-1):\\n    if s[i] == 'R': r+=1\\n    else: u+=1\\n    if u == r and s[i]==s[i+1]:\\n        cst += 1\\nprint(cst)\\n\", \"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\nS = input().strip()\\nx = y = c = 0\\nk = None\\nfor s in S:\\n    if s == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if y > x:\\n        if k == 'D': c += 1\\n        k = 'U'\\n    elif x > y:\\n        if k == 'U': c += 1\\n        k = 'D'\\n        \\nprint(c)\", \"import sys, math\\n\\n#f = open('input/input_2', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\nS = f.readline().strip()\\n\\nkingdom = 0\\nx = 0\\ny = 0\\nans = 0\\nfor action in S:\\n  if x == y and \\\\\\n    ((kingdom == 1 and action == 'U') or\\n     (kingdom == 2 and action == 'R')):\\n     ans += 1\\n\\n  if action == 'U':\\n    y += 1\\n  elif action == 'R':\\n    x += 1\\n\\n  if x > y:\\n    kingdom = 1\\n  elif x < y:\\n    kingdom = 2\\n\\nprint(ans)\\n\", \"def sgn(x):\\n  if x == 0:\\n    return 0\\n  return 1 if x > 0 else -1\\n\\nn = int(input())\\nx = 0\\ny = 0\\nres = 0\\nlast = 0\\nfor ch in input().strip():\\n  if ch == 'U':\\n    y += 1\\n  else:\\n    x += 1\\n  if sgn(x-y) * last < 0:\\n    res += 1\\n  if x != y:\\n    last = sgn(x-y)\\n\\nprint(res)\\n\", \"n = int(input())\\ns = input()\\ncount = 0\\nkindom = 0\\nx, y = 0, 0\\nfor i in s:\\n    if i == 'U':\\n        y += 1\\n    elif i == 'R':\\n        x += 1\\n    if x > y:\\n        if kindom == 2:\\n            count += 1\\n        kindom = 1\\n    if x < y:\\n        if kindom == 1:\\n            count += 1\\n        kindom = 2\\nprint(count)\\n\", \"import math\\nn = int(input())\\nans = 0\\nnr = 0\\nnu = 0\\nside = 0\\n\\n\\nmm = list(input())\\nfm = mm[0]\\nmm = mm[1:]\\n\\nif fm == \\\"U\\\":\\n    side = 1\\n    nu = 1\\nelse:\\n    side = -1\\n    nr = 1\\n\\n\\n\\nfor m in  mm:\\n    if nu==nr:\\n\\n        if m ==\\\"U\\\" and side == -1:\\n            ans +=1\\n            side = 1\\n        elif m == \\\"R\\\" and side == 1:\\n            ans += 1\\n            side = -1\\n\\n    if m == \\\"U\\\":\\n        nu += 1\\n    else:\\n        nr +=1\\n\\n\\nprint(ans)\\n\\n\", \"n = int(input())\\n\\ns = input()\\n\\nx = 0\\ny = 0\\n\\nk = 0\\nfor i in range(len(s) - 1):\\n    if s[i] == 'U':\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y:\\n        if s[i] == s[i + 1]:\\n            k += 1\\n\\nprint(k)\\n\", \"n = int(input())\\ns = list(input())\\n\\ncur = [0,0]\\nf  = 0\\nc = 0\\nfor i in s:\\n\\tif i=='U':\\n\\t\\tcur[1]+=1\\n\\telse:\\n\\t\\tcur[0]+=1\\n\\tif cur[0]>cur[1]:\\n\\t\\tif f==2:\\n\\t\\t\\tc+=1\\n\\t\\tf = 1\\n\\telif cur[1]>cur[0]:\\n\\t\\tif f==1:\\n\\t\\t\\tc+=1\\n\\t\\tf = 2\\nprint (c)\", \"n = input()\\ns = list(input())\\n\\nx, y = 0, 0\\nk = 0\\n\\ncc = 0\\n\\nfor m in s:\\n    nk = k\\n    if m == 'U':\\n        y += 1\\n    elif m == 'R':\\n        x += 1\\n    if y > x:\\n        nk = 1\\n    elif y < x:\\n        nk = -1\\n    if nk * k == -1:\\n        cc += 1\\n    k = nk\\n\\nprint(cc)\\n\\n\\n\\n\\n\", \"input()\\nx=y=0\\nl=[]\\ns=input()\\nfor ele in s:\\n  if ele=='U':\\n    y+=1\\n  else:\\n    x+=1\\n  if x>y:\\n    l.append(1)\\n  if x==y:\\n    l.append(l[-1])\\n  if x<y:\\n    l.append(0)\\ncnt=0\\nfor i in range(1,len(l)):\\n  if l[i]!=l[i-1]:\\n    cnt+=1\\nprint(cnt)\\n\", \"n=int(input())\\nx=0\\ny=0\\ns=input()\\nl=[]\\nfor i in range(0,len(s)):\\n    if s[i]=='R':\\n        x+=1\\n    else:\\n        y+=1\\n    l.append(x-y)\\nif n<=2:\\n    print(0)\\nelse:\\n    c=0\\n    for j in range(1,n-1):\\n        if l[j]==0 and l[j-1]*l[j+1]<0:\\n            c+=1\\n    print(c)\\n\\n\", \"n = int(input())\\ns = input()\\nx = y = 0\\np = 0\\nl = 'X'\\nlx = ly = -1\\nfor c in s:\\n    if c == 'U':\\n        y += 1\\n    elif c == 'R':\\n        x += 1\\n    if lx == ly and l == c:\\n        p += 1\\n    l = c\\n    lx = x\\n    ly = y\\nprint(p)\", \"n = int(input())\\nS = input()\\n\\nc = ([0, 1], [1, 0])[S[0] == 'R']\\nf = c[0] == 1\\n\\nans = 0\\nfor el in S[1:]:\\n    if el == 'R':\\n        c[0] += 1\\n\\n        if not f and c[0] - c[1] == 1:\\n            ans += 1\\n            f = not f\\n\\n    elif el == 'U':\\n        c[1] += 1\\n\\n        if f and c[1] - c[0] == 1:\\n            ans += 1\\n            f = not f\\n\\n    else:\\n        exit(100500)\\n\\nprint(ans)\\n\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\nn = int(input())\\ns = input()\\nx = 0; y = 0\\ncnt = 0\\nfor i in range(n):\\n    if s[i] == \\\"U\\\":\\n        y += 1\\n    else:\\n        x += 1\\n    if x == y and i+1 < n:\\n        if (s[i] == 'U' and s[i+1] == 'U') or (s[i] == 'R' and s[i+1] == 'R'):\\n            cnt += 1\\nprint(cnt)\", \"n = int(input())\\ns = input()\\ncnt = 0\\np = True\\nx = 0\\ny = 0\\nfor i in s:\\n    if not (x == 0 and y == 0):\\n        if p and x == y and i == 'R':\\n            cnt += 1\\n            p = False\\n        elif not p and x == y and i == 'U':\\n            cnt += 1\\n            p = True\\n    elif i == 'R':\\n        p = False\\n    else:\\n        p = True\\n\\n    if i == 'R':\\n        x += 1\\n    if i == 'U':\\n        y += 1\\nprint(cnt)\\n\", \"n = int(input())\\ns = input()\\nind = \\\"U\\\"\\nans = 0\\nif s[0] == \\\"R\\\":\\n\\tind = \\\"R\\\"\\ncountr = 0\\ncountu = 0\\nfor i in s:\\n\\tif i == \\\"R\\\":\\n\\t\\tcountr += 1\\n\\telse:\\n\\t\\tcountu += 1\\n\\tif ind == \\\"U\\\" and countr > countu:\\n\\t\\tind = \\\"R\\\"\\n\\t\\tcountr, countu = 1, 0\\n\\t\\tans += 1\\n\\telif ind == \\\"R\\\"\\tand countu > countr:\\n\\t\\tind = \\\"U\\\"\\n\\t\\tcountu, countr = 1, 0\\n\\t\\tans += 1\\nprint(ans)\\t\\t\\n\\n\\n\\n\", \"N=int(input())\\ns=input()\\n\\nnow=0\\nroot=[]\\n\\nfor c in s:\\n\\tif c=='R':\\n\\t\\tnow+=1\\n\\telse:\\n\\t\\tnow-=1\\n\\troot.append(now)\\n\\n\\nans=0\\nfor i in range(1,N-1):\\n\\tif root[i]==0:\\n\\t\\tif (root[i+1]>0) != (root[i-1]>0):\\n\\t\\t\\tans+=1\\n\\n\\nprint(ans)\\n\"]",
        "difficulty": "interview",
        "input": "2\nUU\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/935/B"
    },
    {
        "id": 1919,
        "task_id": 1940,
        "test_case_id": 3,
        "question": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each pocket at the same time. There are n different pebble types in the park, and there are w_{i} pebbles of the i-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.\n\nHelp her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.\n\nThe second line contains n integers w_1, w_2, ..., w_{n} (1 ≤ w_{i} ≤ 10^4) — number of pebbles of each type. \n\n\n-----Output-----\n\nThe only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.\n\n\n-----Examples-----\nInput\n3 2\n2 3 4\n\nOutput\n3\n\nInput\n5 4\n3 1 8 9 7\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.\n\nOptimal sequence of actions in the second sample case:   In the first day Anastasia collects 8 pebbles of the third type.  In the second day she collects 8 pebbles of the fourth type.  In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.  In the fourth day she collects 7 pebbles of the fifth type.  In the fifth day she collects 1 pebble of the second type.",
        "solutions": "[\"n, k = [int(i) for i in input().split()]\\n\\nw = [int(i) for i in input().split()]\\n\\ntot = 0\\nfor wi in w:\\n    tot += (wi+k-1)//k\\n\\nans = (tot+1)//2\\nprint(ans)\\n\", \"n,k=[int(i) for i in input().split()]\\na=[int(i) for i in input().split()]\\nx=0\\nfor i in range(n):\\n    x+=(a[i]+k-1)//k\\nprint((x+1)//2)\", \"N, K = list(map(int, input().split()))\\nW = [int(x) for x in input().split()]\\nans = 0\\nfor w in W:\\n    if w % K == 0:\\n        ans += w // K\\n    else:\\n        ans += w // K + 1\\nif ans % 2 == 0:\\n    print(ans // 2)\\nelse:\\n    print(ans // 2 + 1)\\n\", \"from sys import stdin\\nimport math\\n\\nN, K = list(map(int, stdin.readline().split()))\\npebbles = list(map(int, stdin.readline().split()))\\n\\nprint(math.ceil(sum(math.ceil(p / K) for p in pebbles) / 2))\\n\", \"n, k = map(int, input().split())\\narray = list(map(int, input().split()))\\nans = 0\\nfor i in range (n):\\n    ans += (array[i] + k - 1) // k\\nprint((ans + 1) // 2)\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\nres = 0\\nfor i in a:\\n    res += (i+k-1) // k\\n\\nprint((res+1)//2)\", \"from sys import stdin, stdout\\n\\n\\nn, k = list(map(int, stdin.readline().rstrip().split()))\\n\\npebbleList = [int(a) for a in stdin.readline().rstrip().split()]\\n\\nnTrips=[]\\nfor i in range(n):\\n    nTrips.append(pebbleList[i]//k)\\n    if pebbleList[i]%k!=0:\\n        nTrips[i]+=1\\n\\ntotal = sum(nTrips)//2 + sum(nTrips)%2\\nprint(total)\\n\", \"\\n\\nn, k = list(map(int, input().split()))\\n\\nws = list(int(x) for x in input().split())\\n\\nresult = 0\\nfree_pocket = False\\n\\n\\nfor w in ws:\\n    needed_pockets = (w + k - 1) // k\\n    if needed_pockets % 2 == 0:\\n        result += needed_pockets // 2\\n    else:\\n        if free_pocket:\\n            result += (needed_pockets - 1) // 2\\n        else:\\n            result += (needed_pockets + 1) // 2\\n        free_pocket = not free_pocket\\n\\nprint(result)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nans = 0\\nfor i in range(n):\\n    ans += (a[i] - 1) // k + 1\\n    \\nprint((ans - 1) // 2 + 1)\", \"import sys\\nn,k = list(map(int, input().split()))\\nw = list(map(int, input().split()))\\nrem = 0\\nans = 0\\nfor i in range(n):\\n    \\n    if w[i] % k != 0:\\n        rem +=1\\n    ans += w[i] // k;\\nres = 0\\nres += ans// 2\\nif ans % 2 != 0:\\n    rem += 1\\nres += rem // 2\\nif rem % 2 != 0:\\n    res += 1\\nprint(res)\\n\", \"n,k=map(int,input().split())\\nip=list(map(int,input().split()))\\ncount=0\\nfor i in ip:\\n    if i%k==0:\\n        count+=i//k\\n    else:\\n        count+=(i//k)+1\\nif count %2==0:\\n    print(count//2)\\nelse:\\n    print(count//2 + 1)\", \"import math\\nn,k=list(map(int,input().split()))\\nw=[int(i) for i in input().split()]\\nres=[]\\nfor i in range(n):\\n    res.append(w[i]//k)\\n    res.append(bool(w[i]%k))\\nprint(math.ceil(sum(res)/2))\\n\", \"n, k = map(int, input().split())\\ndays = 0\\nw = list(map(int, input().split()))\\nfor wi in w:\\n    days += (wi - 1) // k + 1\\nprint((days - 1) // 2 + 1)\", \"n,k=map(int,input().split())\\nl=sorted(map(int,input().split()))\\nans=0\\nfor i in range(n):\\n    ans+=-(-l[i]//k)\\nprint(-(-ans//2))\", \"n,k=map(int,input().split())\\nl=[int(i) for i in input().split()]\\nans=[]\\nfor i in l:\\n    ans.append((i+k-1)//k)\\nprint((sum(ans)+1)//2)\", \"#!/usr/bin/env python3\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\nn, k = ri()\\n\\nw = list(ri())\\n\\nans = 0\\nfor ww in w:\\n    if ww % k == 0:\\n        ans += ww//k\\n    else:\\n        ans += ww//k + 1\\n\\nif ans%2:\\n    print(ans//2+1)\\nelse:\\n    print(ans//2)\\n\\nprint()\\n\\n\", \"n,k=map(int,input().split())\\nd=0\\nt = sum(((i-1)//k + 1) for i in map(int,input().split()))\\nprint((t-1)//2 + 1)\", \"from math import *\\nn,k = list(map(int,input().split()))\\n*m,=list(map(int,input().split()))\\nd=0.0\\nfor i in m:\\n    d+=ceil(i/k)\\nprint(ceil(d/2))\\n\", \"n, k = [int(i) for i in input().split()]\\nw = [int(i) for i in input().split()]\\nw.sort()\\nm = 0\\nfor i in w:\\n    m += (i + k - 1) // k\\n\\nprint((m + 1) // 2)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\n\\npeb = list(map(int, input().split()))\\n\\nd = 0\\n\\nfor p in peb:\\n    d += ceil(p / s)\\n\\nprint(ceil(d/2))\\n\", \"def R():\\n    return [int(x) for x in input().split()]\\n\\ndef __starting_point():\\n    n, k = R()\\n    w = R()\\n    result = 0\\n    for _w in w:\\n        if _w < k:\\n            result += 1\\n        elif _w % k == 0:\\n            result += _w // k\\n        else:\\n            result += _w // k + 1\\n\\n    if result % 2 == 0:\\n        print(result // 2)\\n    else: \\n        print(result // 2 + 1)\\n\\n__starting_point()\", \"from collections import deque\\nfrom sys import stdin\\nfrom math import ceil\\nlines = deque(line.strip() for line in stdin.readlines())\\n\\ndef nextline():\\n    return lines.popleft()\\n\\ndef types(cast):\\n    return tuple(int(x) for x in nextline().split())\\n\\ndef ints():\\n    return types(int)\\n\\ndef strs():\\n    return nextline().split()\\n\\ndef main():\\n    # lines will now contain all of the input's lines in a list\\n    n, k = ints()\\n    ws = ints()\\n    count = ceil(sum(ceil(x/k) for x in ws)/2)\\n    print(count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport math\\n\\nfin = sys.stdin\\nfout = sys.stdout\\nn, k = list(map(int, fin.readline().split()))\\na = list(map(int, fin.readline().split()))\\nans = 0\\ni = 0\\nwhile i < n:\\n    ans += math.ceil(a[i] / k)\\n    i += 1\\nfout.write(str(math.ceil(ans / 2)))\\n\", \"import math\\nn,k=list(map(int,input().split()))\\nline=list(map(int,input().split()))\\ncnt=0\\nfor x in line:\\n\\tcnt+=math.ceil(x/k)\\nprint(math.ceil(cnt/2))\\n\", \"n, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ncounterS = 0\\ncounterL = 0\\n\\nfor i in arr:\\n    if i <= k:\\n        counterS += 1\\n    else:\\n        if i <= 2 * k:\\n            counterL += 1\\n        else:\\n            counterL += (i // (2 * k))\\n            y = i - (i // (2 * k))*(2*k)\\n            if y <= k:\\n                if y != 0:\\n                    counterS += 1\\n            else:\\n                counterL += 1\\nlastCounter = (counterS // 2) + (counterS % 2) + counterL\\nprint(lastCounter)\\n\"]",
        "difficulty": "interview",
        "input": "1 22\n1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/789/A"
    },
    {
        "id": 1920,
        "task_id": 1940,
        "test_case_id": 7,
        "question": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each pocket at the same time. There are n different pebble types in the park, and there are w_{i} pebbles of the i-th type. Anastasia is very responsible, so she never mixes pebbles of different types in same pocket. However, she can put different kinds of pebbles in different pockets at the same time. Unfortunately, she can't spend all her time collecting pebbles, so she can collect pebbles from the park only once a day.\n\nHelp her to find the minimum number of days needed to collect all the pebbles of Uzhlyandian Central Park, taking into consideration that Anastasia can't place pebbles of different types in same pocket.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9) — the number of different pebble types and number of pebbles Anastasia can place in one pocket.\n\nThe second line contains n integers w_1, w_2, ..., w_{n} (1 ≤ w_{i} ≤ 10^4) — number of pebbles of each type. \n\n\n-----Output-----\n\nThe only line of output contains one integer — the minimum number of days Anastasia needs to collect all the pebbles.\n\n\n-----Examples-----\nInput\n3 2\n2 3 4\n\nOutput\n3\n\nInput\n5 4\n3 1 8 9 7\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first sample case, Anastasia can collect all pebbles of the first type on the first day, of second type — on the second day, and of third type — on the third day.\n\nOptimal sequence of actions in the second sample case:   In the first day Anastasia collects 8 pebbles of the third type.  In the second day she collects 8 pebbles of the fourth type.  In the third day she collects 3 pebbles of the first type and 1 pebble of the fourth type.  In the fourth day she collects 7 pebbles of the fifth type.  In the fifth day she collects 1 pebble of the second type.",
        "solutions": "[\"n, k = [int(i) for i in input().split()]\\n\\nw = [int(i) for i in input().split()]\\n\\ntot = 0\\nfor wi in w:\\n    tot += (wi+k-1)//k\\n\\nans = (tot+1)//2\\nprint(ans)\\n\", \"n,k=[int(i) for i in input().split()]\\na=[int(i) for i in input().split()]\\nx=0\\nfor i in range(n):\\n    x+=(a[i]+k-1)//k\\nprint((x+1)//2)\", \"N, K = list(map(int, input().split()))\\nW = [int(x) for x in input().split()]\\nans = 0\\nfor w in W:\\n    if w % K == 0:\\n        ans += w // K\\n    else:\\n        ans += w // K + 1\\nif ans % 2 == 0:\\n    print(ans // 2)\\nelse:\\n    print(ans // 2 + 1)\\n\", \"from sys import stdin\\nimport math\\n\\nN, K = list(map(int, stdin.readline().split()))\\npebbles = list(map(int, stdin.readline().split()))\\n\\nprint(math.ceil(sum(math.ceil(p / K) for p in pebbles) / 2))\\n\", \"n, k = map(int, input().split())\\narray = list(map(int, input().split()))\\nans = 0\\nfor i in range (n):\\n    ans += (array[i] + k - 1) // k\\nprint((ans + 1) // 2)\", \"n, k = map(int, input().split(' '))\\na = list(map(int, input().split(' ')))\\nres = 0\\nfor i in a:\\n    res += (i+k-1) // k\\n\\nprint((res+1)//2)\", \"from sys import stdin, stdout\\n\\n\\nn, k = list(map(int, stdin.readline().rstrip().split()))\\n\\npebbleList = [int(a) for a in stdin.readline().rstrip().split()]\\n\\nnTrips=[]\\nfor i in range(n):\\n    nTrips.append(pebbleList[i]//k)\\n    if pebbleList[i]%k!=0:\\n        nTrips[i]+=1\\n\\ntotal = sum(nTrips)//2 + sum(nTrips)%2\\nprint(total)\\n\", \"\\n\\nn, k = list(map(int, input().split()))\\n\\nws = list(int(x) for x in input().split())\\n\\nresult = 0\\nfree_pocket = False\\n\\n\\nfor w in ws:\\n    needed_pockets = (w + k - 1) // k\\n    if needed_pockets % 2 == 0:\\n        result += needed_pockets // 2\\n    else:\\n        if free_pocket:\\n            result += (needed_pockets - 1) // 2\\n        else:\\n            result += (needed_pockets + 1) // 2\\n        free_pocket = not free_pocket\\n\\nprint(result)\\n\", \"n, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nans = 0\\nfor i in range(n):\\n    ans += (a[i] - 1) // k + 1\\n    \\nprint((ans - 1) // 2 + 1)\", \"import sys\\nn,k = list(map(int, input().split()))\\nw = list(map(int, input().split()))\\nrem = 0\\nans = 0\\nfor i in range(n):\\n    \\n    if w[i] % k != 0:\\n        rem +=1\\n    ans += w[i] // k;\\nres = 0\\nres += ans// 2\\nif ans % 2 != 0:\\n    rem += 1\\nres += rem // 2\\nif rem % 2 != 0:\\n    res += 1\\nprint(res)\\n\", \"n,k=map(int,input().split())\\nip=list(map(int,input().split()))\\ncount=0\\nfor i in ip:\\n    if i%k==0:\\n        count+=i//k\\n    else:\\n        count+=(i//k)+1\\nif count %2==0:\\n    print(count//2)\\nelse:\\n    print(count//2 + 1)\", \"import math\\nn,k=list(map(int,input().split()))\\nw=[int(i) for i in input().split()]\\nres=[]\\nfor i in range(n):\\n    res.append(w[i]//k)\\n    res.append(bool(w[i]%k))\\nprint(math.ceil(sum(res)/2))\\n\", \"n, k = map(int, input().split())\\ndays = 0\\nw = list(map(int, input().split()))\\nfor wi in w:\\n    days += (wi - 1) // k + 1\\nprint((days - 1) // 2 + 1)\", \"n,k=map(int,input().split())\\nl=sorted(map(int,input().split()))\\nans=0\\nfor i in range(n):\\n    ans+=-(-l[i]//k)\\nprint(-(-ans//2))\", \"n,k=map(int,input().split())\\nl=[int(i) for i in input().split()]\\nans=[]\\nfor i in l:\\n    ans.append((i+k-1)//k)\\nprint((sum(ans)+1)//2)\", \"#!/usr/bin/env python3\\n\\n\\ndef ri():\\n    return list(map(int, input().split()))\\n\\n\\nn, k = ri()\\n\\nw = list(ri())\\n\\nans = 0\\nfor ww in w:\\n    if ww % k == 0:\\n        ans += ww//k\\n    else:\\n        ans += ww//k + 1\\n\\nif ans%2:\\n    print(ans//2+1)\\nelse:\\n    print(ans//2)\\n\\nprint()\\n\\n\", \"n,k=map(int,input().split())\\nd=0\\nt = sum(((i-1)//k + 1) for i in map(int,input().split()))\\nprint((t-1)//2 + 1)\", \"from math import *\\nn,k = list(map(int,input().split()))\\n*m,=list(map(int,input().split()))\\nd=0.0\\nfor i in m:\\n    d+=ceil(i/k)\\nprint(ceil(d/2))\\n\", \"n, k = [int(i) for i in input().split()]\\nw = [int(i) for i in input().split()]\\nw.sort()\\nm = 0\\nfor i in w:\\n    m += (i + k - 1) // k\\n\\nprint((m + 1) // 2)\", \"from math import ceil\\n\\nn, s = list(map(int, input().split()))\\n\\npeb = list(map(int, input().split()))\\n\\nd = 0\\n\\nfor p in peb:\\n    d += ceil(p / s)\\n\\nprint(ceil(d/2))\\n\", \"def R():\\n    return [int(x) for x in input().split()]\\n\\ndef __starting_point():\\n    n, k = R()\\n    w = R()\\n    result = 0\\n    for _w in w:\\n        if _w < k:\\n            result += 1\\n        elif _w % k == 0:\\n            result += _w // k\\n        else:\\n            result += _w // k + 1\\n\\n    if result % 2 == 0:\\n        print(result // 2)\\n    else: \\n        print(result // 2 + 1)\\n\\n__starting_point()\", \"from collections import deque\\nfrom sys import stdin\\nfrom math import ceil\\nlines = deque(line.strip() for line in stdin.readlines())\\n\\ndef nextline():\\n    return lines.popleft()\\n\\ndef types(cast):\\n    return tuple(int(x) for x in nextline().split())\\n\\ndef ints():\\n    return types(int)\\n\\ndef strs():\\n    return nextline().split()\\n\\ndef main():\\n    # lines will now contain all of the input's lines in a list\\n    n, k = ints()\\n    ws = ints()\\n    count = ceil(sum(ceil(x/k) for x in ws)/2)\\n    print(count)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\nimport math\\n\\nfin = sys.stdin\\nfout = sys.stdout\\nn, k = list(map(int, fin.readline().split()))\\na = list(map(int, fin.readline().split()))\\nans = 0\\ni = 0\\nwhile i < n:\\n    ans += math.ceil(a[i] / k)\\n    i += 1\\nfout.write(str(math.ceil(ans / 2)))\\n\", \"import math\\nn,k=list(map(int,input().split()))\\nline=list(map(int,input().split()))\\ncnt=0\\nfor x in line:\\n\\tcnt+=math.ceil(x/k)\\nprint(math.ceil(cnt/2))\\n\", \"n, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\ncounterS = 0\\ncounterL = 0\\n\\nfor i in arr:\\n    if i <= k:\\n        counterS += 1\\n    else:\\n        if i <= 2 * k:\\n            counterL += 1\\n        else:\\n            counterL += (i // (2 * k))\\n            y = i - (i // (2 * k))*(2*k)\\n            if y <= k:\\n                if y != 0:\\n                    counterS += 1\\n            else:\\n                counterL += 1\\nlastCounter = (counterS // 2) + (counterS % 2) + counterL\\nprint(lastCounter)\\n\"]",
        "difficulty": "interview",
        "input": "1 1\n10000\n",
        "output": "5000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/789/A"
    },
    {
        "id": 1921,
        "task_id": 1973,
        "test_case_id": 1,
        "question": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $i$-th day has a ribbon with color $u_i$. Shiro wants to know the largest number $x$, such that if we consider the streak of the first $x$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $x - 1$ will have the same number of occurrences.\n\nFor example, consider the following sequence of $u_i$: $[2, 2, 1, 1, 5, 4, 4, 5]$. Then $x = 7$ makes a streak, since if we remove the leftmost $u_i = 5$, each ribbon color will appear exactly twice in the prefix of $x - 1$ days. Note that $x = 8$ doesn't form a streak, since you must remove exactly one day. \n\nSince Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^5$) — the total number of days.\n\nThe second line contains $n$ integers $u_1, u_2, \\ldots, u_n$ ($1 \\leq u_i \\leq 10$) — the colors of the ribbons the cats wear. \n\n\n-----Output-----\n\nPrint a single integer $x$ — the largest possible streak of days.\n\n\n-----Examples-----\nInput\n13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n\nOutput\n13\nInput\n5\n10 2 5 4 1\n\nOutput\n5\nInput\n1\n10\n\nOutput\n1\nInput\n7\n3 2 1 1 4 5 1\n\nOutput\n6\nInput\n6\n1 1 1 2 2 2\n\nOutput\n5\n\n\n-----Note-----\n\nIn the first example, we can choose the longest streak of $13$ days, since upon removing the last day out of the streak, all of the remaining colors $1$, $2$, $3$, and $4$ will have the same number of occurrences of $3$. Note that the streak can also be $10$ days (by removing the $10$-th day from this streak) but we are interested in the longest streak.\n\nIn the fourth example, if we take the streak of the first $6$ days, we can remove the third day from this streak then all of the remaining colors $1$, $2$, $3$, $4$ and $5$ will occur exactly once.",
        "solutions": "[\"n = int(input())\\nu = [int(u) for u in input().split()]\\n\\nNMAX = 100005\\n\\nsuma = [0 for _ in range(NMAX)]\\ntotal = [0 for _ in range(NMAX)]\\n\\ndiferentes = 0\\nsol = 0\\nmaximo = 1\\n\\nfor i, v in enumerate(u):\\n\\tif total[v] == 0:\\n\\t\\tdiferentes += 1\\n\\telse:\\n\\t\\tsuma[total[v]] -= 1\\n\\ttotal[v] += 1\\n\\tsuma[total[v]] += 1\\n\\n\\tmaximo = max(maximo, total[v])\\n\\n\\t#print(i, v, \\\":\\\", diferentes)\\n\\t#print(suma)\\n\\t#print(total)\\n\\t#print(maximo, \\\":\\\", suma[maximo], suma[maximo+1], diferentes-1)\\n\\t#print(maximo, \\\":\\\", suma[maximo-1], suma[maximo], diferentes-1)\\n\\n\\tif diferentes <= 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo-1] == diferentes-1 and suma[maximo] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo] == diferentes-1 and suma[1] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[1] == diferentes:\\n\\t\\tsol = i\\n\\t\\n\\t#print(\\\"SOL\\\", sol)\\n\\nprint(sol+1)\\n\", \"n = int(input())\\na = [int(x) - 1 for x in input().split()]\\ncounts = [0] * 10\\nfor ind, i in enumerate(a):\\n    counts[i] += 1\\n    k = sorted([i for i in counts if i])\\n    if len(k) == 1 or (k[0] == k[-2] and k[-1] - k[-2] == 1) or (k[0] == 1 and k[1] == k[-1]):\\n        best = ind\\nprint(best + 1)\", \"def main():\\n    from sys import stdin, stdout\\n\\n    def read():\\n        return stdin.readline().rstrip('\\\\n')\\n\\n    def read_array(sep=None, maxsplit=-1):\\n        return read().split(sep, maxsplit)\\n\\n    def read_int():\\n        return int(read())\\n\\n    def read_int_array(sep=None, maxsplit=-1):\\n        return [int(a) for a in read_array(sep, maxsplit)]\\n\\n    def write(*args, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in args) + end)\\n\\n    def write_array(array, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in array) + end)\\n\\n    n = read_int()\\n    nums = read_int_array()\\n    counts = {}\\n    import collections\\n    inv_counts = collections.defaultdict(int)\\n    out = 0\\n    for i, x in enumerate(nums):\\n        c = inv_counts[x]\\n        if c:\\n            counts[c].remove(x)\\n            if not counts[c]:\\n                counts.pop(c)\\n        c += 1\\n        inv_counts[x] = c\\n        counts.setdefault(c, set()).add(x)\\n        if len(counts) == 2 and any(len(s) == 1 and ((k-1 in counts) or k == 1) for k, s in list(counts.items())):\\n            out = i + 1\\n        elif len(counts) == 1:\\n            k = next(iter(list(counts.keys())))\\n            if k == 1 or len(counts[k]) == 1:\\n                out = i + 1\\n    write(out)\\n\\nmain()\\n\", \"NUMS = [0 for i in range(10)]\\n\\ndef check(nums):\\n    maxi = max(nums)\\n    category = nums.count(maxi)\\n    if category == 1:\\n        oneof = 0\\n        for n in nums:\\n            if n == maxi:\\n                continue\\n            if n == 0:\\n                continue\\n            if oneof != 0 and (n != oneof or n != maxi - 1):\\n                return False\\n            oneof = n\\n    \\n        return True\\n    \\n    else:\\n        if maxi != 1:\\n            if nums.count(1) != 1:\\n                return False\\n            if nums.count(0) != len(nums) - category - 1:\\n                return False\\n            return True\\n        else:\\n            return True\\n\\nn = int(input())\\ncolors = list(map(int, input().split()))\\nres = 0\\nfor i in range(n):\\n    NUMS[colors[i] - 1] += 1\\n    if check(NUMS):\\n        res = i + 1\\n\\nprint(res)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\n\\nC = [0] * 101010\\nma = 0\\nmacnt = 0\\nposcnt = 0\\ncntofone = 0\\nans = 0\\nfor i in range(N):\\n    C[A[i]] += 1\\n    if C[A[i]] > ma:\\n        ma = C[A[i]]\\n        macnt = 1\\n    elif ma == C[A[i]]:\\n        macnt += 1\\n    if C[A[i]] == 1:\\n        poscnt += 1\\n        cntofone += 1\\n    elif C[A[i]] == 2:\\n        cntofone -= 1\\n    if i <= 1 or (cntofone >= 1 and ((poscnt - 1) * ma == i)) or (macnt == 1 and (poscnt * (ma - 1) == i)):\\n        ans = i + 1\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nm =[0 for i in range(11)]\\nwyn = 0\\nfor i in range(n):\\n\\tm[l[i]] += 1\\n\\tb = [m[i] for i in range(11) if m[i] != 0]\\n\\tb = sorted(b)\\n\\t#print(b)\\n\\tif len(b) == 1:\\n\\t\\twyn = i + 1\\n\\tif len(b) > 1:\\n\\t\\tif b[0] == 1 and sum(b) == 1 + len(b)*b[1]-b[1]:\\n\\t\\t\\twyn = i + 1\\n\\t\\telse:\\n\\t\\t\\tif (b[0] == b[-2] and b[-1] == b[0] + 1):\\n\\t\\t\\t\\twyn = i + 1\\nprint(wyn)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = [0] * 11\\nma = 1\\nfor i in range(n):\\n    c[a[i]] += 1\\n    for k in range(1, 11):\\n        if c[k] > 0:\\n            c[k] -= 1\\n            s = {}\\n            for j in range(1, 11):\\n                if c[j] > 0:\\n                    if c[j] not in s:\\n                        s[c[j]] = 1\\n                    else:\\n                        s[c[j]] += 1\\n            c[k] += 1\\n            if len(s) == 1:\\n                ma = max(ma, i + 1)\\n                break\\n\\nprint(ma)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\nd = [0] * 10\\nmax_ = 1\\nfor i in range(n):\\n    d[arr[i] - 1] += 1\\n    lol = sorted([x for x in d if x > 0])\\n    kek = True\\n    for j in range(len(lol) - 2):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and len(lol) == 1:\\n        max_ = max(max_, i + 1)\\n        continue\\n    elif kek and lol[-1] - 1 == lol[-2]:\\n        max_ = max(max_, i + 1)\\n        continue\\n\\n    kek = True\\n    for j in range(1, len(lol) - 1):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and lol[0] - 1 == 0:\\n        max_ = max(max_, i + 1)\\nprint(max_)\\n\", \"ii = lambda:int(input())\\nkk=lambda:list(map(int,input().split()))\\nk2=lambda:[int(x)-1 for x in input().split()]\\nll=lambda:list(kk())\\nn=ii()\\nd = [0]*10\\nmaxi = 2\\nfor j,v in enumerate(k2()):\\n\\td[v]+=1\\n\\tvs = {}\\n\\tfor i in range(10):\\n\\t\\tif d[i] ==0: continue\\n\\t\\tif d[i] not in vs: vs[d[i]] = 0\\n\\t\\tvs[d[i]]+=1\\n\\tif len(vs) >2: continue\\n\\tif len(vs) == 2:\\n\\t\\tval = max(list(vs.keys()))\\n\\t\\tif (1 in vs and vs[1]==1) or(val-1 in vs and vs[val]==1): \\n\\t\\t\\tmaxi = j\\n\\telif len(vs) == 1 and (1 in vs or d.count(0) == 9):\\n\\t\\tmaxi = j\\n\\nprint(max(maxi+1, min(2, n)))\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = [0]*11\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"from random import random\\nfrom collections import defaultdict\\nimport math\\nimport re\\nimport fractions\\n\\nN = int(input())\\n# N, M = map(int, input().split(\\\" \\\"))\\nA = list(map(int, input().split(\\\" \\\")))\\narr = [0]*(10**5+1)\\nexisting = set()\\nfor a in A:\\n  arr[a] += 1\\n  existing.add(a)\\n\\naccumulate = defaultdict(int)\\nfor count in arr:\\n  accumulate[count] += 1\\n\\nfor i in range(len(A)-1, -1, -1):\\n  a = A[i]\\n  length = i+1\\n\\n  if len(existing) in [0, 1, length]:\\n    break\\n\\n  expected_1 = (i+1-1)//(len(existing)-1)\\n  if accumulate[expected_1] * expected_1 + 1 == length and accumulate[1] == 1:\\n    break\\n\\n  expected_k_1 = (i+1-1)//len(existing)\\n  if accumulate[expected_k_1] * expected_k_1 + expected_k_1 + 1 == length and accumulate[expected_k_1+1] == 1:\\n    break\\n\\n  accumulate[arr[a]] -= 1\\n  arr[a] -= 1\\n  if arr[a] == 0:\\n    existing.discard(a)\\n  accumulate[arr[a]] += 1\\n  # print(accumulate)\\nprint(length)\\n\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\n\\nd = {}\\nfor i in range(n):\\n\\td[a[i]] = 0\\n\\n\\n# numOdd = 0\\n# for i in range(n):\\n# \\td[a[i]] += 1\\n\\n# \\tif(d[a[i]] % 2 != 0):\\n# \\t\\tnumOdd += 1\\n\\n# \\telse:\\n# \\t\\tnumOdd -= 1\\n\\n# \\tif(numOdd == 1):\\n# \\t\\tx = i+1\\n\\n# print(x)\\n\\nx = 1\\nfor i in range(1,n):\\n\\tif(a[i] == a[i-1]):\\n\\t\\t# print(\\\"yo\\\")\\n\\t\\tx = i+1\\n\\telse:\\n\\t\\tbreak\\n\\nfor i in range(n):\\n\\td[a[i]] += 1\\n\\n\\tl = list(d.values())\\n\\tl = list(set(l))\\n\\tll = list(d.values())\\n\\tl.sort()\\n\\t# print(l)\\n\\tif(l[0] == 0):\\n\\t\\tl.pop(l[0])\\n\\t\\n\\tif(len(l) == 2):\\n\\t\\tif(abs(l[0] - l[1]) == 1 and ll.count(l[1]) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\t\\telif(l[0] == 1 and ll.count(1) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\tif(len(l) == 1 and l[0] == 1):\\n\\t\\tx = max(x,i+1)\\n\\nprint(x)\", \"n = int(input())\\n\\na = list(map(int,input().split()))\\nif(n == 1 or n == 2):\\n    print(n)\\n    return\\nnotpar = 0\\nocc = [0 for i in range(10**5 + 1)]\\nbase = 1\\ngotone = False\\nleader = -1\\nleadby = 0\\nbest = 0\\nocc[a[0]] += 1\\ncnt = 1\\nat1 = 1\\n\\n\\n\\nfor i in range(1, n):\\n    occ[a[i]] +=1\\n    \\n    if(occ[a[i]] == 1):\\n        notpar += 1\\n        at1 += 1\\n        cnt += 1\\n    elif(occ[a[i]] == 2):\\n        at1 -= 1\\n    if(occ[a[i]] == base):\\n        notpar -= 1\\n    elif(occ[a[i]] > base):\\n        if(gotone):\\n            if(a[i] != leader):\\n                base += 1\\n                notpar = cnt - 2\\n                leadby -= 1\\n                if(leadby == 0):\\n                    gotone = False\\n                    leader = -1\\n            else:\\n                leadby += 1\\n        else:\\n            gotone = True\\n            leader = a[i]\\n            leadby = 1\\n    if(notpar == 0 and (leadby == 1 or (leadby == 0 and base == 1)) or (notpar == 1 and leadby == 0 and at1 > 0)):\\n        best = i + 1\\n    if(cnt == 1):\\n        best = i + 1\\n    #print(i, base, leader, leadby, gotone, notpar, cnt)\\nprint(best)\\n                    \\n                    \\n\", \"\\n# -*- coding: utf-8 -*-\\n\\ndef __starting_point():\\n    n  = int(input())\\n    a = list(map(int, input().split()))\\n    b = [0 for i in range(10)]\\n    pos = 1\\n    for i in range(n):\\n        b[a[i]-1]+=1\\n        c = []\\n        for j in range(10):\\n            if (b[j]>0):\\n                c.append(b[j])\\n        c.sort()\\n        if (c[len(c)-1]==i+1) or (c[len(c)-1]==c[len(c)-2]+1 and c[len(c)-2]==c[0])\\\\\\n            or (c[len(c)-1]==c[1] and c[0]==1):\\n            pos = i+1\\n    print(pos)\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\ndic = {a[0]:1}\\n#board= ['*']*11\\nsu = 1\\nkq = 1\\nfor i in range(1, n):\\n    if dic.get(a[i], 0)==0:\\n        dic.update({a[i]:1})\\n    else:\\n        dic[a[i]]+=1\\n    su+=1\\n    cach = len(list(dic.keys()))\\n    c = 0\\n    c_=0\\n    for z in list(dic.keys()):\\n        if cach==1:\\n            continue\\n        if cach == su:\\n            kq = su\\n            continue\\n        if dic[z]== (su-1)/(cach-1):\\n            c+=1\\n        if dic[z]== (su-1)/cach:\\n            c_+=1\\n    if c==cach-1 or c_==cach-1:\\n        kq = su\\n\\nprint(kq)       \\n    \\n\", \"import sys\\n\\nn = int(input())\\nnums = list(map(int, input().split()))\\neleCount = {}\\npossibleMax = 1\\nfor i in range(n):\\n    if nums[i] in list(eleCount.keys()):\\n        eleCount[nums[i]] += 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\n    else:\\n        eleCount[nums[i]] = 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\nprint(possibleMax)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nb=[]\\nfor i in range(11):\\n    b.append(0)\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"def check():\\n    mn = float('inf')\\n    mx = 0\\n    k = 0\\n    for i in mas:\\n        if i != 0:\\n            k += 1\\n            mx = max(mx, i)\\n            mn = min(mn, i)\\n    if (mx - mn <= 1 and mas.count(mx) == 1) or (mn == 1 and k == 1 + mas.count(mx)) or (mn == mx == 1):\\n        return True\\n    return False\\nn = int(input())\\nl = list(map(int, input().split()))\\nmas = [0] * 10\\nans = 0\\nfor i in range(n):\\n    mas[l[i] - 1] += 1\\n    if check():\\n        #print(i)\\n        #print('check')\\n        ans = i\\nprint(ans + 1)\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/5/9 23:15\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B1. Cat Party (Easy Edition).py\\n\\nfrom collections import Counter\\n\\n\\ndef check(counter, curr_len, curr_color, curr_one):\\n    if curr_len == 1 or curr_color == 1 or curr_one == curr_len:\\n        return True\\n\\n    # if curr_len == 13:\\n    #     print(counter)\\n    if curr_one == 1:\\n        curr_color -= 1\\n    if (curr_len - 1) % curr_color != 0:\\n        return False\\n    correct_num = (curr_len - 1) // curr_color\\n    # if curr_len == 13:\\n    #     print(correct_num)\\n\\n    false_count, false_num = 0, 0\\n    for i in range(1, 11):\\n        if counter[i] != correct_num and counter[i] != 0:\\n            false_count += 1\\n            false_num = counter[i]\\n    # if curr_len == 13:\\n    #     print(false_count)\\n\\n    return false_count == 1 and (false_num - 1 == correct_num or false_count - 1 == 0)\\n\\n\\ndef main():\\n    n = int(input())\\n    u = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    max_days, curr_color, curr_one = 0, 0, 0\\n    for i in range(n):\\n        if counter[u[i]] == 0:\\n            curr_color += 1\\n            curr_one += 1\\n\\n        if counter[u[i]] == 1:\\n            curr_one -= 1\\n\\n        counter[u[i]] += 1\\n        if check(counter, i + 1, curr_color, curr_one):\\n            max_days = i + 1\\n    print(max_days)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n",
        "output": "13",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1163/B1"
    },
    {
        "id": 1922,
        "task_id": 1973,
        "test_case_id": 2,
        "question": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $i$-th day has a ribbon with color $u_i$. Shiro wants to know the largest number $x$, such that if we consider the streak of the first $x$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $x - 1$ will have the same number of occurrences.\n\nFor example, consider the following sequence of $u_i$: $[2, 2, 1, 1, 5, 4, 4, 5]$. Then $x = 7$ makes a streak, since if we remove the leftmost $u_i = 5$, each ribbon color will appear exactly twice in the prefix of $x - 1$ days. Note that $x = 8$ doesn't form a streak, since you must remove exactly one day. \n\nSince Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^5$) — the total number of days.\n\nThe second line contains $n$ integers $u_1, u_2, \\ldots, u_n$ ($1 \\leq u_i \\leq 10$) — the colors of the ribbons the cats wear. \n\n\n-----Output-----\n\nPrint a single integer $x$ — the largest possible streak of days.\n\n\n-----Examples-----\nInput\n13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n\nOutput\n13\nInput\n5\n10 2 5 4 1\n\nOutput\n5\nInput\n1\n10\n\nOutput\n1\nInput\n7\n3 2 1 1 4 5 1\n\nOutput\n6\nInput\n6\n1 1 1 2 2 2\n\nOutput\n5\n\n\n-----Note-----\n\nIn the first example, we can choose the longest streak of $13$ days, since upon removing the last day out of the streak, all of the remaining colors $1$, $2$, $3$, and $4$ will have the same number of occurrences of $3$. Note that the streak can also be $10$ days (by removing the $10$-th day from this streak) but we are interested in the longest streak.\n\nIn the fourth example, if we take the streak of the first $6$ days, we can remove the third day from this streak then all of the remaining colors $1$, $2$, $3$, $4$ and $5$ will occur exactly once.",
        "solutions": "[\"n = int(input())\\nu = [int(u) for u in input().split()]\\n\\nNMAX = 100005\\n\\nsuma = [0 for _ in range(NMAX)]\\ntotal = [0 for _ in range(NMAX)]\\n\\ndiferentes = 0\\nsol = 0\\nmaximo = 1\\n\\nfor i, v in enumerate(u):\\n\\tif total[v] == 0:\\n\\t\\tdiferentes += 1\\n\\telse:\\n\\t\\tsuma[total[v]] -= 1\\n\\ttotal[v] += 1\\n\\tsuma[total[v]] += 1\\n\\n\\tmaximo = max(maximo, total[v])\\n\\n\\t#print(i, v, \\\":\\\", diferentes)\\n\\t#print(suma)\\n\\t#print(total)\\n\\t#print(maximo, \\\":\\\", suma[maximo], suma[maximo+1], diferentes-1)\\n\\t#print(maximo, \\\":\\\", suma[maximo-1], suma[maximo], diferentes-1)\\n\\n\\tif diferentes <= 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo-1] == diferentes-1 and suma[maximo] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo] == diferentes-1 and suma[1] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[1] == diferentes:\\n\\t\\tsol = i\\n\\t\\n\\t#print(\\\"SOL\\\", sol)\\n\\nprint(sol+1)\\n\", \"n = int(input())\\na = [int(x) - 1 for x in input().split()]\\ncounts = [0] * 10\\nfor ind, i in enumerate(a):\\n    counts[i] += 1\\n    k = sorted([i for i in counts if i])\\n    if len(k) == 1 or (k[0] == k[-2] and k[-1] - k[-2] == 1) or (k[0] == 1 and k[1] == k[-1]):\\n        best = ind\\nprint(best + 1)\", \"def main():\\n    from sys import stdin, stdout\\n\\n    def read():\\n        return stdin.readline().rstrip('\\\\n')\\n\\n    def read_array(sep=None, maxsplit=-1):\\n        return read().split(sep, maxsplit)\\n\\n    def read_int():\\n        return int(read())\\n\\n    def read_int_array(sep=None, maxsplit=-1):\\n        return [int(a) for a in read_array(sep, maxsplit)]\\n\\n    def write(*args, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in args) + end)\\n\\n    def write_array(array, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in array) + end)\\n\\n    n = read_int()\\n    nums = read_int_array()\\n    counts = {}\\n    import collections\\n    inv_counts = collections.defaultdict(int)\\n    out = 0\\n    for i, x in enumerate(nums):\\n        c = inv_counts[x]\\n        if c:\\n            counts[c].remove(x)\\n            if not counts[c]:\\n                counts.pop(c)\\n        c += 1\\n        inv_counts[x] = c\\n        counts.setdefault(c, set()).add(x)\\n        if len(counts) == 2 and any(len(s) == 1 and ((k-1 in counts) or k == 1) for k, s in list(counts.items())):\\n            out = i + 1\\n        elif len(counts) == 1:\\n            k = next(iter(list(counts.keys())))\\n            if k == 1 or len(counts[k]) == 1:\\n                out = i + 1\\n    write(out)\\n\\nmain()\\n\", \"NUMS = [0 for i in range(10)]\\n\\ndef check(nums):\\n    maxi = max(nums)\\n    category = nums.count(maxi)\\n    if category == 1:\\n        oneof = 0\\n        for n in nums:\\n            if n == maxi:\\n                continue\\n            if n == 0:\\n                continue\\n            if oneof != 0 and (n != oneof or n != maxi - 1):\\n                return False\\n            oneof = n\\n    \\n        return True\\n    \\n    else:\\n        if maxi != 1:\\n            if nums.count(1) != 1:\\n                return False\\n            if nums.count(0) != len(nums) - category - 1:\\n                return False\\n            return True\\n        else:\\n            return True\\n\\nn = int(input())\\ncolors = list(map(int, input().split()))\\nres = 0\\nfor i in range(n):\\n    NUMS[colors[i] - 1] += 1\\n    if check(NUMS):\\n        res = i + 1\\n\\nprint(res)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\n\\nC = [0] * 101010\\nma = 0\\nmacnt = 0\\nposcnt = 0\\ncntofone = 0\\nans = 0\\nfor i in range(N):\\n    C[A[i]] += 1\\n    if C[A[i]] > ma:\\n        ma = C[A[i]]\\n        macnt = 1\\n    elif ma == C[A[i]]:\\n        macnt += 1\\n    if C[A[i]] == 1:\\n        poscnt += 1\\n        cntofone += 1\\n    elif C[A[i]] == 2:\\n        cntofone -= 1\\n    if i <= 1 or (cntofone >= 1 and ((poscnt - 1) * ma == i)) or (macnt == 1 and (poscnt * (ma - 1) == i)):\\n        ans = i + 1\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nm =[0 for i in range(11)]\\nwyn = 0\\nfor i in range(n):\\n\\tm[l[i]] += 1\\n\\tb = [m[i] for i in range(11) if m[i] != 0]\\n\\tb = sorted(b)\\n\\t#print(b)\\n\\tif len(b) == 1:\\n\\t\\twyn = i + 1\\n\\tif len(b) > 1:\\n\\t\\tif b[0] == 1 and sum(b) == 1 + len(b)*b[1]-b[1]:\\n\\t\\t\\twyn = i + 1\\n\\t\\telse:\\n\\t\\t\\tif (b[0] == b[-2] and b[-1] == b[0] + 1):\\n\\t\\t\\t\\twyn = i + 1\\nprint(wyn)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = [0] * 11\\nma = 1\\nfor i in range(n):\\n    c[a[i]] += 1\\n    for k in range(1, 11):\\n        if c[k] > 0:\\n            c[k] -= 1\\n            s = {}\\n            for j in range(1, 11):\\n                if c[j] > 0:\\n                    if c[j] not in s:\\n                        s[c[j]] = 1\\n                    else:\\n                        s[c[j]] += 1\\n            c[k] += 1\\n            if len(s) == 1:\\n                ma = max(ma, i + 1)\\n                break\\n\\nprint(ma)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\nd = [0] * 10\\nmax_ = 1\\nfor i in range(n):\\n    d[arr[i] - 1] += 1\\n    lol = sorted([x for x in d if x > 0])\\n    kek = True\\n    for j in range(len(lol) - 2):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and len(lol) == 1:\\n        max_ = max(max_, i + 1)\\n        continue\\n    elif kek and lol[-1] - 1 == lol[-2]:\\n        max_ = max(max_, i + 1)\\n        continue\\n\\n    kek = True\\n    for j in range(1, len(lol) - 1):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and lol[0] - 1 == 0:\\n        max_ = max(max_, i + 1)\\nprint(max_)\\n\", \"ii = lambda:int(input())\\nkk=lambda:list(map(int,input().split()))\\nk2=lambda:[int(x)-1 for x in input().split()]\\nll=lambda:list(kk())\\nn=ii()\\nd = [0]*10\\nmaxi = 2\\nfor j,v in enumerate(k2()):\\n\\td[v]+=1\\n\\tvs = {}\\n\\tfor i in range(10):\\n\\t\\tif d[i] ==0: continue\\n\\t\\tif d[i] not in vs: vs[d[i]] = 0\\n\\t\\tvs[d[i]]+=1\\n\\tif len(vs) >2: continue\\n\\tif len(vs) == 2:\\n\\t\\tval = max(list(vs.keys()))\\n\\t\\tif (1 in vs and vs[1]==1) or(val-1 in vs and vs[val]==1): \\n\\t\\t\\tmaxi = j\\n\\telif len(vs) == 1 and (1 in vs or d.count(0) == 9):\\n\\t\\tmaxi = j\\n\\nprint(max(maxi+1, min(2, n)))\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = [0]*11\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"from random import random\\nfrom collections import defaultdict\\nimport math\\nimport re\\nimport fractions\\n\\nN = int(input())\\n# N, M = map(int, input().split(\\\" \\\"))\\nA = list(map(int, input().split(\\\" \\\")))\\narr = [0]*(10**5+1)\\nexisting = set()\\nfor a in A:\\n  arr[a] += 1\\n  existing.add(a)\\n\\naccumulate = defaultdict(int)\\nfor count in arr:\\n  accumulate[count] += 1\\n\\nfor i in range(len(A)-1, -1, -1):\\n  a = A[i]\\n  length = i+1\\n\\n  if len(existing) in [0, 1, length]:\\n    break\\n\\n  expected_1 = (i+1-1)//(len(existing)-1)\\n  if accumulate[expected_1] * expected_1 + 1 == length and accumulate[1] == 1:\\n    break\\n\\n  expected_k_1 = (i+1-1)//len(existing)\\n  if accumulate[expected_k_1] * expected_k_1 + expected_k_1 + 1 == length and accumulate[expected_k_1+1] == 1:\\n    break\\n\\n  accumulate[arr[a]] -= 1\\n  arr[a] -= 1\\n  if arr[a] == 0:\\n    existing.discard(a)\\n  accumulate[arr[a]] += 1\\n  # print(accumulate)\\nprint(length)\\n\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\n\\nd = {}\\nfor i in range(n):\\n\\td[a[i]] = 0\\n\\n\\n# numOdd = 0\\n# for i in range(n):\\n# \\td[a[i]] += 1\\n\\n# \\tif(d[a[i]] % 2 != 0):\\n# \\t\\tnumOdd += 1\\n\\n# \\telse:\\n# \\t\\tnumOdd -= 1\\n\\n# \\tif(numOdd == 1):\\n# \\t\\tx = i+1\\n\\n# print(x)\\n\\nx = 1\\nfor i in range(1,n):\\n\\tif(a[i] == a[i-1]):\\n\\t\\t# print(\\\"yo\\\")\\n\\t\\tx = i+1\\n\\telse:\\n\\t\\tbreak\\n\\nfor i in range(n):\\n\\td[a[i]] += 1\\n\\n\\tl = list(d.values())\\n\\tl = list(set(l))\\n\\tll = list(d.values())\\n\\tl.sort()\\n\\t# print(l)\\n\\tif(l[0] == 0):\\n\\t\\tl.pop(l[0])\\n\\t\\n\\tif(len(l) == 2):\\n\\t\\tif(abs(l[0] - l[1]) == 1 and ll.count(l[1]) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\t\\telif(l[0] == 1 and ll.count(1) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\tif(len(l) == 1 and l[0] == 1):\\n\\t\\tx = max(x,i+1)\\n\\nprint(x)\", \"n = int(input())\\n\\na = list(map(int,input().split()))\\nif(n == 1 or n == 2):\\n    print(n)\\n    return\\nnotpar = 0\\nocc = [0 for i in range(10**5 + 1)]\\nbase = 1\\ngotone = False\\nleader = -1\\nleadby = 0\\nbest = 0\\nocc[a[0]] += 1\\ncnt = 1\\nat1 = 1\\n\\n\\n\\nfor i in range(1, n):\\n    occ[a[i]] +=1\\n    \\n    if(occ[a[i]] == 1):\\n        notpar += 1\\n        at1 += 1\\n        cnt += 1\\n    elif(occ[a[i]] == 2):\\n        at1 -= 1\\n    if(occ[a[i]] == base):\\n        notpar -= 1\\n    elif(occ[a[i]] > base):\\n        if(gotone):\\n            if(a[i] != leader):\\n                base += 1\\n                notpar = cnt - 2\\n                leadby -= 1\\n                if(leadby == 0):\\n                    gotone = False\\n                    leader = -1\\n            else:\\n                leadby += 1\\n        else:\\n            gotone = True\\n            leader = a[i]\\n            leadby = 1\\n    if(notpar == 0 and (leadby == 1 or (leadby == 0 and base == 1)) or (notpar == 1 and leadby == 0 and at1 > 0)):\\n        best = i + 1\\n    if(cnt == 1):\\n        best = i + 1\\n    #print(i, base, leader, leadby, gotone, notpar, cnt)\\nprint(best)\\n                    \\n                    \\n\", \"\\n# -*- coding: utf-8 -*-\\n\\ndef __starting_point():\\n    n  = int(input())\\n    a = list(map(int, input().split()))\\n    b = [0 for i in range(10)]\\n    pos = 1\\n    for i in range(n):\\n        b[a[i]-1]+=1\\n        c = []\\n        for j in range(10):\\n            if (b[j]>0):\\n                c.append(b[j])\\n        c.sort()\\n        if (c[len(c)-1]==i+1) or (c[len(c)-1]==c[len(c)-2]+1 and c[len(c)-2]==c[0])\\\\\\n            or (c[len(c)-1]==c[1] and c[0]==1):\\n            pos = i+1\\n    print(pos)\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\ndic = {a[0]:1}\\n#board= ['*']*11\\nsu = 1\\nkq = 1\\nfor i in range(1, n):\\n    if dic.get(a[i], 0)==0:\\n        dic.update({a[i]:1})\\n    else:\\n        dic[a[i]]+=1\\n    su+=1\\n    cach = len(list(dic.keys()))\\n    c = 0\\n    c_=0\\n    for z in list(dic.keys()):\\n        if cach==1:\\n            continue\\n        if cach == su:\\n            kq = su\\n            continue\\n        if dic[z]== (su-1)/(cach-1):\\n            c+=1\\n        if dic[z]== (su-1)/cach:\\n            c_+=1\\n    if c==cach-1 or c_==cach-1:\\n        kq = su\\n\\nprint(kq)       \\n    \\n\", \"import sys\\n\\nn = int(input())\\nnums = list(map(int, input().split()))\\neleCount = {}\\npossibleMax = 1\\nfor i in range(n):\\n    if nums[i] in list(eleCount.keys()):\\n        eleCount[nums[i]] += 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\n    else:\\n        eleCount[nums[i]] = 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\nprint(possibleMax)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nb=[]\\nfor i in range(11):\\n    b.append(0)\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"def check():\\n    mn = float('inf')\\n    mx = 0\\n    k = 0\\n    for i in mas:\\n        if i != 0:\\n            k += 1\\n            mx = max(mx, i)\\n            mn = min(mn, i)\\n    if (mx - mn <= 1 and mas.count(mx) == 1) or (mn == 1 and k == 1 + mas.count(mx)) or (mn == mx == 1):\\n        return True\\n    return False\\nn = int(input())\\nl = list(map(int, input().split()))\\nmas = [0] * 10\\nans = 0\\nfor i in range(n):\\n    mas[l[i] - 1] += 1\\n    if check():\\n        #print(i)\\n        #print('check')\\n        ans = i\\nprint(ans + 1)\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/5/9 23:15\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B1. Cat Party (Easy Edition).py\\n\\nfrom collections import Counter\\n\\n\\ndef check(counter, curr_len, curr_color, curr_one):\\n    if curr_len == 1 or curr_color == 1 or curr_one == curr_len:\\n        return True\\n\\n    # if curr_len == 13:\\n    #     print(counter)\\n    if curr_one == 1:\\n        curr_color -= 1\\n    if (curr_len - 1) % curr_color != 0:\\n        return False\\n    correct_num = (curr_len - 1) // curr_color\\n    # if curr_len == 13:\\n    #     print(correct_num)\\n\\n    false_count, false_num = 0, 0\\n    for i in range(1, 11):\\n        if counter[i] != correct_num and counter[i] != 0:\\n            false_count += 1\\n            false_num = counter[i]\\n    # if curr_len == 13:\\n    #     print(false_count)\\n\\n    return false_count == 1 and (false_num - 1 == correct_num or false_count - 1 == 0)\\n\\n\\ndef main():\\n    n = int(input())\\n    u = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    max_days, curr_color, curr_one = 0, 0, 0\\n    for i in range(n):\\n        if counter[u[i]] == 0:\\n            curr_color += 1\\n            curr_one += 1\\n\\n        if counter[u[i]] == 1:\\n            curr_one -= 1\\n\\n        counter[u[i]] += 1\\n        if check(counter, i + 1, curr_color, curr_one):\\n            max_days = i + 1\\n    print(max_days)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "5\n10 2 5 4 1\n",
        "output": "5",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1163/B1"
    },
    {
        "id": 1923,
        "task_id": 1973,
        "test_case_id": 3,
        "question": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $i$-th day has a ribbon with color $u_i$. Shiro wants to know the largest number $x$, such that if we consider the streak of the first $x$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $x - 1$ will have the same number of occurrences.\n\nFor example, consider the following sequence of $u_i$: $[2, 2, 1, 1, 5, 4, 4, 5]$. Then $x = 7$ makes a streak, since if we remove the leftmost $u_i = 5$, each ribbon color will appear exactly twice in the prefix of $x - 1$ days. Note that $x = 8$ doesn't form a streak, since you must remove exactly one day. \n\nSince Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^5$) — the total number of days.\n\nThe second line contains $n$ integers $u_1, u_2, \\ldots, u_n$ ($1 \\leq u_i \\leq 10$) — the colors of the ribbons the cats wear. \n\n\n-----Output-----\n\nPrint a single integer $x$ — the largest possible streak of days.\n\n\n-----Examples-----\nInput\n13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n\nOutput\n13\nInput\n5\n10 2 5 4 1\n\nOutput\n5\nInput\n1\n10\n\nOutput\n1\nInput\n7\n3 2 1 1 4 5 1\n\nOutput\n6\nInput\n6\n1 1 1 2 2 2\n\nOutput\n5\n\n\n-----Note-----\n\nIn the first example, we can choose the longest streak of $13$ days, since upon removing the last day out of the streak, all of the remaining colors $1$, $2$, $3$, and $4$ will have the same number of occurrences of $3$. Note that the streak can also be $10$ days (by removing the $10$-th day from this streak) but we are interested in the longest streak.\n\nIn the fourth example, if we take the streak of the first $6$ days, we can remove the third day from this streak then all of the remaining colors $1$, $2$, $3$, $4$ and $5$ will occur exactly once.",
        "solutions": "[\"n = int(input())\\nu = [int(u) for u in input().split()]\\n\\nNMAX = 100005\\n\\nsuma = [0 for _ in range(NMAX)]\\ntotal = [0 for _ in range(NMAX)]\\n\\ndiferentes = 0\\nsol = 0\\nmaximo = 1\\n\\nfor i, v in enumerate(u):\\n\\tif total[v] == 0:\\n\\t\\tdiferentes += 1\\n\\telse:\\n\\t\\tsuma[total[v]] -= 1\\n\\ttotal[v] += 1\\n\\tsuma[total[v]] += 1\\n\\n\\tmaximo = max(maximo, total[v])\\n\\n\\t#print(i, v, \\\":\\\", diferentes)\\n\\t#print(suma)\\n\\t#print(total)\\n\\t#print(maximo, \\\":\\\", suma[maximo], suma[maximo+1], diferentes-1)\\n\\t#print(maximo, \\\":\\\", suma[maximo-1], suma[maximo], diferentes-1)\\n\\n\\tif diferentes <= 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo-1] == diferentes-1 and suma[maximo] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo] == diferentes-1 and suma[1] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[1] == diferentes:\\n\\t\\tsol = i\\n\\t\\n\\t#print(\\\"SOL\\\", sol)\\n\\nprint(sol+1)\\n\", \"n = int(input())\\na = [int(x) - 1 for x in input().split()]\\ncounts = [0] * 10\\nfor ind, i in enumerate(a):\\n    counts[i] += 1\\n    k = sorted([i for i in counts if i])\\n    if len(k) == 1 or (k[0] == k[-2] and k[-1] - k[-2] == 1) or (k[0] == 1 and k[1] == k[-1]):\\n        best = ind\\nprint(best + 1)\", \"def main():\\n    from sys import stdin, stdout\\n\\n    def read():\\n        return stdin.readline().rstrip('\\\\n')\\n\\n    def read_array(sep=None, maxsplit=-1):\\n        return read().split(sep, maxsplit)\\n\\n    def read_int():\\n        return int(read())\\n\\n    def read_int_array(sep=None, maxsplit=-1):\\n        return [int(a) for a in read_array(sep, maxsplit)]\\n\\n    def write(*args, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in args) + end)\\n\\n    def write_array(array, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in array) + end)\\n\\n    n = read_int()\\n    nums = read_int_array()\\n    counts = {}\\n    import collections\\n    inv_counts = collections.defaultdict(int)\\n    out = 0\\n    for i, x in enumerate(nums):\\n        c = inv_counts[x]\\n        if c:\\n            counts[c].remove(x)\\n            if not counts[c]:\\n                counts.pop(c)\\n        c += 1\\n        inv_counts[x] = c\\n        counts.setdefault(c, set()).add(x)\\n        if len(counts) == 2 and any(len(s) == 1 and ((k-1 in counts) or k == 1) for k, s in list(counts.items())):\\n            out = i + 1\\n        elif len(counts) == 1:\\n            k = next(iter(list(counts.keys())))\\n            if k == 1 or len(counts[k]) == 1:\\n                out = i + 1\\n    write(out)\\n\\nmain()\\n\", \"NUMS = [0 for i in range(10)]\\n\\ndef check(nums):\\n    maxi = max(nums)\\n    category = nums.count(maxi)\\n    if category == 1:\\n        oneof = 0\\n        for n in nums:\\n            if n == maxi:\\n                continue\\n            if n == 0:\\n                continue\\n            if oneof != 0 and (n != oneof or n != maxi - 1):\\n                return False\\n            oneof = n\\n    \\n        return True\\n    \\n    else:\\n        if maxi != 1:\\n            if nums.count(1) != 1:\\n                return False\\n            if nums.count(0) != len(nums) - category - 1:\\n                return False\\n            return True\\n        else:\\n            return True\\n\\nn = int(input())\\ncolors = list(map(int, input().split()))\\nres = 0\\nfor i in range(n):\\n    NUMS[colors[i] - 1] += 1\\n    if check(NUMS):\\n        res = i + 1\\n\\nprint(res)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\n\\nC = [0] * 101010\\nma = 0\\nmacnt = 0\\nposcnt = 0\\ncntofone = 0\\nans = 0\\nfor i in range(N):\\n    C[A[i]] += 1\\n    if C[A[i]] > ma:\\n        ma = C[A[i]]\\n        macnt = 1\\n    elif ma == C[A[i]]:\\n        macnt += 1\\n    if C[A[i]] == 1:\\n        poscnt += 1\\n        cntofone += 1\\n    elif C[A[i]] == 2:\\n        cntofone -= 1\\n    if i <= 1 or (cntofone >= 1 and ((poscnt - 1) * ma == i)) or (macnt == 1 and (poscnt * (ma - 1) == i)):\\n        ans = i + 1\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nm =[0 for i in range(11)]\\nwyn = 0\\nfor i in range(n):\\n\\tm[l[i]] += 1\\n\\tb = [m[i] for i in range(11) if m[i] != 0]\\n\\tb = sorted(b)\\n\\t#print(b)\\n\\tif len(b) == 1:\\n\\t\\twyn = i + 1\\n\\tif len(b) > 1:\\n\\t\\tif b[0] == 1 and sum(b) == 1 + len(b)*b[1]-b[1]:\\n\\t\\t\\twyn = i + 1\\n\\t\\telse:\\n\\t\\t\\tif (b[0] == b[-2] and b[-1] == b[0] + 1):\\n\\t\\t\\t\\twyn = i + 1\\nprint(wyn)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = [0] * 11\\nma = 1\\nfor i in range(n):\\n    c[a[i]] += 1\\n    for k in range(1, 11):\\n        if c[k] > 0:\\n            c[k] -= 1\\n            s = {}\\n            for j in range(1, 11):\\n                if c[j] > 0:\\n                    if c[j] not in s:\\n                        s[c[j]] = 1\\n                    else:\\n                        s[c[j]] += 1\\n            c[k] += 1\\n            if len(s) == 1:\\n                ma = max(ma, i + 1)\\n                break\\n\\nprint(ma)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\nd = [0] * 10\\nmax_ = 1\\nfor i in range(n):\\n    d[arr[i] - 1] += 1\\n    lol = sorted([x for x in d if x > 0])\\n    kek = True\\n    for j in range(len(lol) - 2):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and len(lol) == 1:\\n        max_ = max(max_, i + 1)\\n        continue\\n    elif kek and lol[-1] - 1 == lol[-2]:\\n        max_ = max(max_, i + 1)\\n        continue\\n\\n    kek = True\\n    for j in range(1, len(lol) - 1):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and lol[0] - 1 == 0:\\n        max_ = max(max_, i + 1)\\nprint(max_)\\n\", \"ii = lambda:int(input())\\nkk=lambda:list(map(int,input().split()))\\nk2=lambda:[int(x)-1 for x in input().split()]\\nll=lambda:list(kk())\\nn=ii()\\nd = [0]*10\\nmaxi = 2\\nfor j,v in enumerate(k2()):\\n\\td[v]+=1\\n\\tvs = {}\\n\\tfor i in range(10):\\n\\t\\tif d[i] ==0: continue\\n\\t\\tif d[i] not in vs: vs[d[i]] = 0\\n\\t\\tvs[d[i]]+=1\\n\\tif len(vs) >2: continue\\n\\tif len(vs) == 2:\\n\\t\\tval = max(list(vs.keys()))\\n\\t\\tif (1 in vs and vs[1]==1) or(val-1 in vs and vs[val]==1): \\n\\t\\t\\tmaxi = j\\n\\telif len(vs) == 1 and (1 in vs or d.count(0) == 9):\\n\\t\\tmaxi = j\\n\\nprint(max(maxi+1, min(2, n)))\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = [0]*11\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"from random import random\\nfrom collections import defaultdict\\nimport math\\nimport re\\nimport fractions\\n\\nN = int(input())\\n# N, M = map(int, input().split(\\\" \\\"))\\nA = list(map(int, input().split(\\\" \\\")))\\narr = [0]*(10**5+1)\\nexisting = set()\\nfor a in A:\\n  arr[a] += 1\\n  existing.add(a)\\n\\naccumulate = defaultdict(int)\\nfor count in arr:\\n  accumulate[count] += 1\\n\\nfor i in range(len(A)-1, -1, -1):\\n  a = A[i]\\n  length = i+1\\n\\n  if len(existing) in [0, 1, length]:\\n    break\\n\\n  expected_1 = (i+1-1)//(len(existing)-1)\\n  if accumulate[expected_1] * expected_1 + 1 == length and accumulate[1] == 1:\\n    break\\n\\n  expected_k_1 = (i+1-1)//len(existing)\\n  if accumulate[expected_k_1] * expected_k_1 + expected_k_1 + 1 == length and accumulate[expected_k_1+1] == 1:\\n    break\\n\\n  accumulate[arr[a]] -= 1\\n  arr[a] -= 1\\n  if arr[a] == 0:\\n    existing.discard(a)\\n  accumulate[arr[a]] += 1\\n  # print(accumulate)\\nprint(length)\\n\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\n\\nd = {}\\nfor i in range(n):\\n\\td[a[i]] = 0\\n\\n\\n# numOdd = 0\\n# for i in range(n):\\n# \\td[a[i]] += 1\\n\\n# \\tif(d[a[i]] % 2 != 0):\\n# \\t\\tnumOdd += 1\\n\\n# \\telse:\\n# \\t\\tnumOdd -= 1\\n\\n# \\tif(numOdd == 1):\\n# \\t\\tx = i+1\\n\\n# print(x)\\n\\nx = 1\\nfor i in range(1,n):\\n\\tif(a[i] == a[i-1]):\\n\\t\\t# print(\\\"yo\\\")\\n\\t\\tx = i+1\\n\\telse:\\n\\t\\tbreak\\n\\nfor i in range(n):\\n\\td[a[i]] += 1\\n\\n\\tl = list(d.values())\\n\\tl = list(set(l))\\n\\tll = list(d.values())\\n\\tl.sort()\\n\\t# print(l)\\n\\tif(l[0] == 0):\\n\\t\\tl.pop(l[0])\\n\\t\\n\\tif(len(l) == 2):\\n\\t\\tif(abs(l[0] - l[1]) == 1 and ll.count(l[1]) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\t\\telif(l[0] == 1 and ll.count(1) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\tif(len(l) == 1 and l[0] == 1):\\n\\t\\tx = max(x,i+1)\\n\\nprint(x)\", \"n = int(input())\\n\\na = list(map(int,input().split()))\\nif(n == 1 or n == 2):\\n    print(n)\\n    return\\nnotpar = 0\\nocc = [0 for i in range(10**5 + 1)]\\nbase = 1\\ngotone = False\\nleader = -1\\nleadby = 0\\nbest = 0\\nocc[a[0]] += 1\\ncnt = 1\\nat1 = 1\\n\\n\\n\\nfor i in range(1, n):\\n    occ[a[i]] +=1\\n    \\n    if(occ[a[i]] == 1):\\n        notpar += 1\\n        at1 += 1\\n        cnt += 1\\n    elif(occ[a[i]] == 2):\\n        at1 -= 1\\n    if(occ[a[i]] == base):\\n        notpar -= 1\\n    elif(occ[a[i]] > base):\\n        if(gotone):\\n            if(a[i] != leader):\\n                base += 1\\n                notpar = cnt - 2\\n                leadby -= 1\\n                if(leadby == 0):\\n                    gotone = False\\n                    leader = -1\\n            else:\\n                leadby += 1\\n        else:\\n            gotone = True\\n            leader = a[i]\\n            leadby = 1\\n    if(notpar == 0 and (leadby == 1 or (leadby == 0 and base == 1)) or (notpar == 1 and leadby == 0 and at1 > 0)):\\n        best = i + 1\\n    if(cnt == 1):\\n        best = i + 1\\n    #print(i, base, leader, leadby, gotone, notpar, cnt)\\nprint(best)\\n                    \\n                    \\n\", \"\\n# -*- coding: utf-8 -*-\\n\\ndef __starting_point():\\n    n  = int(input())\\n    a = list(map(int, input().split()))\\n    b = [0 for i in range(10)]\\n    pos = 1\\n    for i in range(n):\\n        b[a[i]-1]+=1\\n        c = []\\n        for j in range(10):\\n            if (b[j]>0):\\n                c.append(b[j])\\n        c.sort()\\n        if (c[len(c)-1]==i+1) or (c[len(c)-1]==c[len(c)-2]+1 and c[len(c)-2]==c[0])\\\\\\n            or (c[len(c)-1]==c[1] and c[0]==1):\\n            pos = i+1\\n    print(pos)\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\ndic = {a[0]:1}\\n#board= ['*']*11\\nsu = 1\\nkq = 1\\nfor i in range(1, n):\\n    if dic.get(a[i], 0)==0:\\n        dic.update({a[i]:1})\\n    else:\\n        dic[a[i]]+=1\\n    su+=1\\n    cach = len(list(dic.keys()))\\n    c = 0\\n    c_=0\\n    for z in list(dic.keys()):\\n        if cach==1:\\n            continue\\n        if cach == su:\\n            kq = su\\n            continue\\n        if dic[z]== (su-1)/(cach-1):\\n            c+=1\\n        if dic[z]== (su-1)/cach:\\n            c_+=1\\n    if c==cach-1 or c_==cach-1:\\n        kq = su\\n\\nprint(kq)       \\n    \\n\", \"import sys\\n\\nn = int(input())\\nnums = list(map(int, input().split()))\\neleCount = {}\\npossibleMax = 1\\nfor i in range(n):\\n    if nums[i] in list(eleCount.keys()):\\n        eleCount[nums[i]] += 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\n    else:\\n        eleCount[nums[i]] = 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\nprint(possibleMax)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nb=[]\\nfor i in range(11):\\n    b.append(0)\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"def check():\\n    mn = float('inf')\\n    mx = 0\\n    k = 0\\n    for i in mas:\\n        if i != 0:\\n            k += 1\\n            mx = max(mx, i)\\n            mn = min(mn, i)\\n    if (mx - mn <= 1 and mas.count(mx) == 1) or (mn == 1 and k == 1 + mas.count(mx)) or (mn == mx == 1):\\n        return True\\n    return False\\nn = int(input())\\nl = list(map(int, input().split()))\\nmas = [0] * 10\\nans = 0\\nfor i in range(n):\\n    mas[l[i] - 1] += 1\\n    if check():\\n        #print(i)\\n        #print('check')\\n        ans = i\\nprint(ans + 1)\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/5/9 23:15\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B1. Cat Party (Easy Edition).py\\n\\nfrom collections import Counter\\n\\n\\ndef check(counter, curr_len, curr_color, curr_one):\\n    if curr_len == 1 or curr_color == 1 or curr_one == curr_len:\\n        return True\\n\\n    # if curr_len == 13:\\n    #     print(counter)\\n    if curr_one == 1:\\n        curr_color -= 1\\n    if (curr_len - 1) % curr_color != 0:\\n        return False\\n    correct_num = (curr_len - 1) // curr_color\\n    # if curr_len == 13:\\n    #     print(correct_num)\\n\\n    false_count, false_num = 0, 0\\n    for i in range(1, 11):\\n        if counter[i] != correct_num and counter[i] != 0:\\n            false_count += 1\\n            false_num = counter[i]\\n    # if curr_len == 13:\\n    #     print(false_count)\\n\\n    return false_count == 1 and (false_num - 1 == correct_num or false_count - 1 == 0)\\n\\n\\ndef main():\\n    n = int(input())\\n    u = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    max_days, curr_color, curr_one = 0, 0, 0\\n    for i in range(n):\\n        if counter[u[i]] == 0:\\n            curr_color += 1\\n            curr_one += 1\\n\\n        if counter[u[i]] == 1:\\n            curr_one -= 1\\n\\n        counter[u[i]] += 1\\n        if check(counter, i + 1, curr_color, curr_one):\\n            max_days = i + 1\\n    print(max_days)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "1\n10\n",
        "output": "1",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1163/B1"
    },
    {
        "id": 1924,
        "task_id": 1973,
        "test_case_id": 4,
        "question": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $i$-th day has a ribbon with color $u_i$. Shiro wants to know the largest number $x$, such that if we consider the streak of the first $x$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $x - 1$ will have the same number of occurrences.\n\nFor example, consider the following sequence of $u_i$: $[2, 2, 1, 1, 5, 4, 4, 5]$. Then $x = 7$ makes a streak, since if we remove the leftmost $u_i = 5$, each ribbon color will appear exactly twice in the prefix of $x - 1$ days. Note that $x = 8$ doesn't form a streak, since you must remove exactly one day. \n\nSince Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^5$) — the total number of days.\n\nThe second line contains $n$ integers $u_1, u_2, \\ldots, u_n$ ($1 \\leq u_i \\leq 10$) — the colors of the ribbons the cats wear. \n\n\n-----Output-----\n\nPrint a single integer $x$ — the largest possible streak of days.\n\n\n-----Examples-----\nInput\n13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n\nOutput\n13\nInput\n5\n10 2 5 4 1\n\nOutput\n5\nInput\n1\n10\n\nOutput\n1\nInput\n7\n3 2 1 1 4 5 1\n\nOutput\n6\nInput\n6\n1 1 1 2 2 2\n\nOutput\n5\n\n\n-----Note-----\n\nIn the first example, we can choose the longest streak of $13$ days, since upon removing the last day out of the streak, all of the remaining colors $1$, $2$, $3$, and $4$ will have the same number of occurrences of $3$. Note that the streak can also be $10$ days (by removing the $10$-th day from this streak) but we are interested in the longest streak.\n\nIn the fourth example, if we take the streak of the first $6$ days, we can remove the third day from this streak then all of the remaining colors $1$, $2$, $3$, $4$ and $5$ will occur exactly once.",
        "solutions": "[\"n = int(input())\\nu = [int(u) for u in input().split()]\\n\\nNMAX = 100005\\n\\nsuma = [0 for _ in range(NMAX)]\\ntotal = [0 for _ in range(NMAX)]\\n\\ndiferentes = 0\\nsol = 0\\nmaximo = 1\\n\\nfor i, v in enumerate(u):\\n\\tif total[v] == 0:\\n\\t\\tdiferentes += 1\\n\\telse:\\n\\t\\tsuma[total[v]] -= 1\\n\\ttotal[v] += 1\\n\\tsuma[total[v]] += 1\\n\\n\\tmaximo = max(maximo, total[v])\\n\\n\\t#print(i, v, \\\":\\\", diferentes)\\n\\t#print(suma)\\n\\t#print(total)\\n\\t#print(maximo, \\\":\\\", suma[maximo], suma[maximo+1], diferentes-1)\\n\\t#print(maximo, \\\":\\\", suma[maximo-1], suma[maximo], diferentes-1)\\n\\n\\tif diferentes <= 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo-1] == diferentes-1 and suma[maximo] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo] == diferentes-1 and suma[1] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[1] == diferentes:\\n\\t\\tsol = i\\n\\t\\n\\t#print(\\\"SOL\\\", sol)\\n\\nprint(sol+1)\\n\", \"n = int(input())\\na = [int(x) - 1 for x in input().split()]\\ncounts = [0] * 10\\nfor ind, i in enumerate(a):\\n    counts[i] += 1\\n    k = sorted([i for i in counts if i])\\n    if len(k) == 1 or (k[0] == k[-2] and k[-1] - k[-2] == 1) or (k[0] == 1 and k[1] == k[-1]):\\n        best = ind\\nprint(best + 1)\", \"def main():\\n    from sys import stdin, stdout\\n\\n    def read():\\n        return stdin.readline().rstrip('\\\\n')\\n\\n    def read_array(sep=None, maxsplit=-1):\\n        return read().split(sep, maxsplit)\\n\\n    def read_int():\\n        return int(read())\\n\\n    def read_int_array(sep=None, maxsplit=-1):\\n        return [int(a) for a in read_array(sep, maxsplit)]\\n\\n    def write(*args, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in args) + end)\\n\\n    def write_array(array, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in array) + end)\\n\\n    n = read_int()\\n    nums = read_int_array()\\n    counts = {}\\n    import collections\\n    inv_counts = collections.defaultdict(int)\\n    out = 0\\n    for i, x in enumerate(nums):\\n        c = inv_counts[x]\\n        if c:\\n            counts[c].remove(x)\\n            if not counts[c]:\\n                counts.pop(c)\\n        c += 1\\n        inv_counts[x] = c\\n        counts.setdefault(c, set()).add(x)\\n        if len(counts) == 2 and any(len(s) == 1 and ((k-1 in counts) or k == 1) for k, s in list(counts.items())):\\n            out = i + 1\\n        elif len(counts) == 1:\\n            k = next(iter(list(counts.keys())))\\n            if k == 1 or len(counts[k]) == 1:\\n                out = i + 1\\n    write(out)\\n\\nmain()\\n\", \"NUMS = [0 for i in range(10)]\\n\\ndef check(nums):\\n    maxi = max(nums)\\n    category = nums.count(maxi)\\n    if category == 1:\\n        oneof = 0\\n        for n in nums:\\n            if n == maxi:\\n                continue\\n            if n == 0:\\n                continue\\n            if oneof != 0 and (n != oneof or n != maxi - 1):\\n                return False\\n            oneof = n\\n    \\n        return True\\n    \\n    else:\\n        if maxi != 1:\\n            if nums.count(1) != 1:\\n                return False\\n            if nums.count(0) != len(nums) - category - 1:\\n                return False\\n            return True\\n        else:\\n            return True\\n\\nn = int(input())\\ncolors = list(map(int, input().split()))\\nres = 0\\nfor i in range(n):\\n    NUMS[colors[i] - 1] += 1\\n    if check(NUMS):\\n        res = i + 1\\n\\nprint(res)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\n\\nC = [0] * 101010\\nma = 0\\nmacnt = 0\\nposcnt = 0\\ncntofone = 0\\nans = 0\\nfor i in range(N):\\n    C[A[i]] += 1\\n    if C[A[i]] > ma:\\n        ma = C[A[i]]\\n        macnt = 1\\n    elif ma == C[A[i]]:\\n        macnt += 1\\n    if C[A[i]] == 1:\\n        poscnt += 1\\n        cntofone += 1\\n    elif C[A[i]] == 2:\\n        cntofone -= 1\\n    if i <= 1 or (cntofone >= 1 and ((poscnt - 1) * ma == i)) or (macnt == 1 and (poscnt * (ma - 1) == i)):\\n        ans = i + 1\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nm =[0 for i in range(11)]\\nwyn = 0\\nfor i in range(n):\\n\\tm[l[i]] += 1\\n\\tb = [m[i] for i in range(11) if m[i] != 0]\\n\\tb = sorted(b)\\n\\t#print(b)\\n\\tif len(b) == 1:\\n\\t\\twyn = i + 1\\n\\tif len(b) > 1:\\n\\t\\tif b[0] == 1 and sum(b) == 1 + len(b)*b[1]-b[1]:\\n\\t\\t\\twyn = i + 1\\n\\t\\telse:\\n\\t\\t\\tif (b[0] == b[-2] and b[-1] == b[0] + 1):\\n\\t\\t\\t\\twyn = i + 1\\nprint(wyn)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = [0] * 11\\nma = 1\\nfor i in range(n):\\n    c[a[i]] += 1\\n    for k in range(1, 11):\\n        if c[k] > 0:\\n            c[k] -= 1\\n            s = {}\\n            for j in range(1, 11):\\n                if c[j] > 0:\\n                    if c[j] not in s:\\n                        s[c[j]] = 1\\n                    else:\\n                        s[c[j]] += 1\\n            c[k] += 1\\n            if len(s) == 1:\\n                ma = max(ma, i + 1)\\n                break\\n\\nprint(ma)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\nd = [0] * 10\\nmax_ = 1\\nfor i in range(n):\\n    d[arr[i] - 1] += 1\\n    lol = sorted([x for x in d if x > 0])\\n    kek = True\\n    for j in range(len(lol) - 2):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and len(lol) == 1:\\n        max_ = max(max_, i + 1)\\n        continue\\n    elif kek and lol[-1] - 1 == lol[-2]:\\n        max_ = max(max_, i + 1)\\n        continue\\n\\n    kek = True\\n    for j in range(1, len(lol) - 1):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and lol[0] - 1 == 0:\\n        max_ = max(max_, i + 1)\\nprint(max_)\\n\", \"ii = lambda:int(input())\\nkk=lambda:list(map(int,input().split()))\\nk2=lambda:[int(x)-1 for x in input().split()]\\nll=lambda:list(kk())\\nn=ii()\\nd = [0]*10\\nmaxi = 2\\nfor j,v in enumerate(k2()):\\n\\td[v]+=1\\n\\tvs = {}\\n\\tfor i in range(10):\\n\\t\\tif d[i] ==0: continue\\n\\t\\tif d[i] not in vs: vs[d[i]] = 0\\n\\t\\tvs[d[i]]+=1\\n\\tif len(vs) >2: continue\\n\\tif len(vs) == 2:\\n\\t\\tval = max(list(vs.keys()))\\n\\t\\tif (1 in vs and vs[1]==1) or(val-1 in vs and vs[val]==1): \\n\\t\\t\\tmaxi = j\\n\\telif len(vs) == 1 and (1 in vs or d.count(0) == 9):\\n\\t\\tmaxi = j\\n\\nprint(max(maxi+1, min(2, n)))\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = [0]*11\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"from random import random\\nfrom collections import defaultdict\\nimport math\\nimport re\\nimport fractions\\n\\nN = int(input())\\n# N, M = map(int, input().split(\\\" \\\"))\\nA = list(map(int, input().split(\\\" \\\")))\\narr = [0]*(10**5+1)\\nexisting = set()\\nfor a in A:\\n  arr[a] += 1\\n  existing.add(a)\\n\\naccumulate = defaultdict(int)\\nfor count in arr:\\n  accumulate[count] += 1\\n\\nfor i in range(len(A)-1, -1, -1):\\n  a = A[i]\\n  length = i+1\\n\\n  if len(existing) in [0, 1, length]:\\n    break\\n\\n  expected_1 = (i+1-1)//(len(existing)-1)\\n  if accumulate[expected_1] * expected_1 + 1 == length and accumulate[1] == 1:\\n    break\\n\\n  expected_k_1 = (i+1-1)//len(existing)\\n  if accumulate[expected_k_1] * expected_k_1 + expected_k_1 + 1 == length and accumulate[expected_k_1+1] == 1:\\n    break\\n\\n  accumulate[arr[a]] -= 1\\n  arr[a] -= 1\\n  if arr[a] == 0:\\n    existing.discard(a)\\n  accumulate[arr[a]] += 1\\n  # print(accumulate)\\nprint(length)\\n\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\n\\nd = {}\\nfor i in range(n):\\n\\td[a[i]] = 0\\n\\n\\n# numOdd = 0\\n# for i in range(n):\\n# \\td[a[i]] += 1\\n\\n# \\tif(d[a[i]] % 2 != 0):\\n# \\t\\tnumOdd += 1\\n\\n# \\telse:\\n# \\t\\tnumOdd -= 1\\n\\n# \\tif(numOdd == 1):\\n# \\t\\tx = i+1\\n\\n# print(x)\\n\\nx = 1\\nfor i in range(1,n):\\n\\tif(a[i] == a[i-1]):\\n\\t\\t# print(\\\"yo\\\")\\n\\t\\tx = i+1\\n\\telse:\\n\\t\\tbreak\\n\\nfor i in range(n):\\n\\td[a[i]] += 1\\n\\n\\tl = list(d.values())\\n\\tl = list(set(l))\\n\\tll = list(d.values())\\n\\tl.sort()\\n\\t# print(l)\\n\\tif(l[0] == 0):\\n\\t\\tl.pop(l[0])\\n\\t\\n\\tif(len(l) == 2):\\n\\t\\tif(abs(l[0] - l[1]) == 1 and ll.count(l[1]) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\t\\telif(l[0] == 1 and ll.count(1) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\tif(len(l) == 1 and l[0] == 1):\\n\\t\\tx = max(x,i+1)\\n\\nprint(x)\", \"n = int(input())\\n\\na = list(map(int,input().split()))\\nif(n == 1 or n == 2):\\n    print(n)\\n    return\\nnotpar = 0\\nocc = [0 for i in range(10**5 + 1)]\\nbase = 1\\ngotone = False\\nleader = -1\\nleadby = 0\\nbest = 0\\nocc[a[0]] += 1\\ncnt = 1\\nat1 = 1\\n\\n\\n\\nfor i in range(1, n):\\n    occ[a[i]] +=1\\n    \\n    if(occ[a[i]] == 1):\\n        notpar += 1\\n        at1 += 1\\n        cnt += 1\\n    elif(occ[a[i]] == 2):\\n        at1 -= 1\\n    if(occ[a[i]] == base):\\n        notpar -= 1\\n    elif(occ[a[i]] > base):\\n        if(gotone):\\n            if(a[i] != leader):\\n                base += 1\\n                notpar = cnt - 2\\n                leadby -= 1\\n                if(leadby == 0):\\n                    gotone = False\\n                    leader = -1\\n            else:\\n                leadby += 1\\n        else:\\n            gotone = True\\n            leader = a[i]\\n            leadby = 1\\n    if(notpar == 0 and (leadby == 1 or (leadby == 0 and base == 1)) or (notpar == 1 and leadby == 0 and at1 > 0)):\\n        best = i + 1\\n    if(cnt == 1):\\n        best = i + 1\\n    #print(i, base, leader, leadby, gotone, notpar, cnt)\\nprint(best)\\n                    \\n                    \\n\", \"\\n# -*- coding: utf-8 -*-\\n\\ndef __starting_point():\\n    n  = int(input())\\n    a = list(map(int, input().split()))\\n    b = [0 for i in range(10)]\\n    pos = 1\\n    for i in range(n):\\n        b[a[i]-1]+=1\\n        c = []\\n        for j in range(10):\\n            if (b[j]>0):\\n                c.append(b[j])\\n        c.sort()\\n        if (c[len(c)-1]==i+1) or (c[len(c)-1]==c[len(c)-2]+1 and c[len(c)-2]==c[0])\\\\\\n            or (c[len(c)-1]==c[1] and c[0]==1):\\n            pos = i+1\\n    print(pos)\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\ndic = {a[0]:1}\\n#board= ['*']*11\\nsu = 1\\nkq = 1\\nfor i in range(1, n):\\n    if dic.get(a[i], 0)==0:\\n        dic.update({a[i]:1})\\n    else:\\n        dic[a[i]]+=1\\n    su+=1\\n    cach = len(list(dic.keys()))\\n    c = 0\\n    c_=0\\n    for z in list(dic.keys()):\\n        if cach==1:\\n            continue\\n        if cach == su:\\n            kq = su\\n            continue\\n        if dic[z]== (su-1)/(cach-1):\\n            c+=1\\n        if dic[z]== (su-1)/cach:\\n            c_+=1\\n    if c==cach-1 or c_==cach-1:\\n        kq = su\\n\\nprint(kq)       \\n    \\n\", \"import sys\\n\\nn = int(input())\\nnums = list(map(int, input().split()))\\neleCount = {}\\npossibleMax = 1\\nfor i in range(n):\\n    if nums[i] in list(eleCount.keys()):\\n        eleCount[nums[i]] += 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\n    else:\\n        eleCount[nums[i]] = 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\nprint(possibleMax)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nb=[]\\nfor i in range(11):\\n    b.append(0)\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"def check():\\n    mn = float('inf')\\n    mx = 0\\n    k = 0\\n    for i in mas:\\n        if i != 0:\\n            k += 1\\n            mx = max(mx, i)\\n            mn = min(mn, i)\\n    if (mx - mn <= 1 and mas.count(mx) == 1) or (mn == 1 and k == 1 + mas.count(mx)) or (mn == mx == 1):\\n        return True\\n    return False\\nn = int(input())\\nl = list(map(int, input().split()))\\nmas = [0] * 10\\nans = 0\\nfor i in range(n):\\n    mas[l[i] - 1] += 1\\n    if check():\\n        #print(i)\\n        #print('check')\\n        ans = i\\nprint(ans + 1)\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/5/9 23:15\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B1. Cat Party (Easy Edition).py\\n\\nfrom collections import Counter\\n\\n\\ndef check(counter, curr_len, curr_color, curr_one):\\n    if curr_len == 1 or curr_color == 1 or curr_one == curr_len:\\n        return True\\n\\n    # if curr_len == 13:\\n    #     print(counter)\\n    if curr_one == 1:\\n        curr_color -= 1\\n    if (curr_len - 1) % curr_color != 0:\\n        return False\\n    correct_num = (curr_len - 1) // curr_color\\n    # if curr_len == 13:\\n    #     print(correct_num)\\n\\n    false_count, false_num = 0, 0\\n    for i in range(1, 11):\\n        if counter[i] != correct_num and counter[i] != 0:\\n            false_count += 1\\n            false_num = counter[i]\\n    # if curr_len == 13:\\n    #     print(false_count)\\n\\n    return false_count == 1 and (false_num - 1 == correct_num or false_count - 1 == 0)\\n\\n\\ndef main():\\n    n = int(input())\\n    u = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    max_days, curr_color, curr_one = 0, 0, 0\\n    for i in range(n):\\n        if counter[u[i]] == 0:\\n            curr_color += 1\\n            curr_one += 1\\n\\n        if counter[u[i]] == 1:\\n            curr_one -= 1\\n\\n        counter[u[i]] += 1\\n        if check(counter, i + 1, curr_color, curr_one):\\n            max_days = i + 1\\n    print(max_days)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "7\n3 2 1 1 4 5 1\n",
        "output": "6",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1163/B1"
    },
    {
        "id": 1925,
        "task_id": 1973,
        "test_case_id": 5,
        "question": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $i$-th day has a ribbon with color $u_i$. Shiro wants to know the largest number $x$, such that if we consider the streak of the first $x$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $x - 1$ will have the same number of occurrences.\n\nFor example, consider the following sequence of $u_i$: $[2, 2, 1, 1, 5, 4, 4, 5]$. Then $x = 7$ makes a streak, since if we remove the leftmost $u_i = 5$, each ribbon color will appear exactly twice in the prefix of $x - 1$ days. Note that $x = 8$ doesn't form a streak, since you must remove exactly one day. \n\nSince Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^5$) — the total number of days.\n\nThe second line contains $n$ integers $u_1, u_2, \\ldots, u_n$ ($1 \\leq u_i \\leq 10$) — the colors of the ribbons the cats wear. \n\n\n-----Output-----\n\nPrint a single integer $x$ — the largest possible streak of days.\n\n\n-----Examples-----\nInput\n13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n\nOutput\n13\nInput\n5\n10 2 5 4 1\n\nOutput\n5\nInput\n1\n10\n\nOutput\n1\nInput\n7\n3 2 1 1 4 5 1\n\nOutput\n6\nInput\n6\n1 1 1 2 2 2\n\nOutput\n5\n\n\n-----Note-----\n\nIn the first example, we can choose the longest streak of $13$ days, since upon removing the last day out of the streak, all of the remaining colors $1$, $2$, $3$, and $4$ will have the same number of occurrences of $3$. Note that the streak can also be $10$ days (by removing the $10$-th day from this streak) but we are interested in the longest streak.\n\nIn the fourth example, if we take the streak of the first $6$ days, we can remove the third day from this streak then all of the remaining colors $1$, $2$, $3$, $4$ and $5$ will occur exactly once.",
        "solutions": "[\"n = int(input())\\nu = [int(u) for u in input().split()]\\n\\nNMAX = 100005\\n\\nsuma = [0 for _ in range(NMAX)]\\ntotal = [0 for _ in range(NMAX)]\\n\\ndiferentes = 0\\nsol = 0\\nmaximo = 1\\n\\nfor i, v in enumerate(u):\\n\\tif total[v] == 0:\\n\\t\\tdiferentes += 1\\n\\telse:\\n\\t\\tsuma[total[v]] -= 1\\n\\ttotal[v] += 1\\n\\tsuma[total[v]] += 1\\n\\n\\tmaximo = max(maximo, total[v])\\n\\n\\t#print(i, v, \\\":\\\", diferentes)\\n\\t#print(suma)\\n\\t#print(total)\\n\\t#print(maximo, \\\":\\\", suma[maximo], suma[maximo+1], diferentes-1)\\n\\t#print(maximo, \\\":\\\", suma[maximo-1], suma[maximo], diferentes-1)\\n\\n\\tif diferentes <= 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo-1] == diferentes-1 and suma[maximo] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo] == diferentes-1 and suma[1] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[1] == diferentes:\\n\\t\\tsol = i\\n\\t\\n\\t#print(\\\"SOL\\\", sol)\\n\\nprint(sol+1)\\n\", \"n = int(input())\\na = [int(x) - 1 for x in input().split()]\\ncounts = [0] * 10\\nfor ind, i in enumerate(a):\\n    counts[i] += 1\\n    k = sorted([i for i in counts if i])\\n    if len(k) == 1 or (k[0] == k[-2] and k[-1] - k[-2] == 1) or (k[0] == 1 and k[1] == k[-1]):\\n        best = ind\\nprint(best + 1)\", \"def main():\\n    from sys import stdin, stdout\\n\\n    def read():\\n        return stdin.readline().rstrip('\\\\n')\\n\\n    def read_array(sep=None, maxsplit=-1):\\n        return read().split(sep, maxsplit)\\n\\n    def read_int():\\n        return int(read())\\n\\n    def read_int_array(sep=None, maxsplit=-1):\\n        return [int(a) for a in read_array(sep, maxsplit)]\\n\\n    def write(*args, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in args) + end)\\n\\n    def write_array(array, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in array) + end)\\n\\n    n = read_int()\\n    nums = read_int_array()\\n    counts = {}\\n    import collections\\n    inv_counts = collections.defaultdict(int)\\n    out = 0\\n    for i, x in enumerate(nums):\\n        c = inv_counts[x]\\n        if c:\\n            counts[c].remove(x)\\n            if not counts[c]:\\n                counts.pop(c)\\n        c += 1\\n        inv_counts[x] = c\\n        counts.setdefault(c, set()).add(x)\\n        if len(counts) == 2 and any(len(s) == 1 and ((k-1 in counts) or k == 1) for k, s in list(counts.items())):\\n            out = i + 1\\n        elif len(counts) == 1:\\n            k = next(iter(list(counts.keys())))\\n            if k == 1 or len(counts[k]) == 1:\\n                out = i + 1\\n    write(out)\\n\\nmain()\\n\", \"NUMS = [0 for i in range(10)]\\n\\ndef check(nums):\\n    maxi = max(nums)\\n    category = nums.count(maxi)\\n    if category == 1:\\n        oneof = 0\\n        for n in nums:\\n            if n == maxi:\\n                continue\\n            if n == 0:\\n                continue\\n            if oneof != 0 and (n != oneof or n != maxi - 1):\\n                return False\\n            oneof = n\\n    \\n        return True\\n    \\n    else:\\n        if maxi != 1:\\n            if nums.count(1) != 1:\\n                return False\\n            if nums.count(0) != len(nums) - category - 1:\\n                return False\\n            return True\\n        else:\\n            return True\\n\\nn = int(input())\\ncolors = list(map(int, input().split()))\\nres = 0\\nfor i in range(n):\\n    NUMS[colors[i] - 1] += 1\\n    if check(NUMS):\\n        res = i + 1\\n\\nprint(res)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\n\\nC = [0] * 101010\\nma = 0\\nmacnt = 0\\nposcnt = 0\\ncntofone = 0\\nans = 0\\nfor i in range(N):\\n    C[A[i]] += 1\\n    if C[A[i]] > ma:\\n        ma = C[A[i]]\\n        macnt = 1\\n    elif ma == C[A[i]]:\\n        macnt += 1\\n    if C[A[i]] == 1:\\n        poscnt += 1\\n        cntofone += 1\\n    elif C[A[i]] == 2:\\n        cntofone -= 1\\n    if i <= 1 or (cntofone >= 1 and ((poscnt - 1) * ma == i)) or (macnt == 1 and (poscnt * (ma - 1) == i)):\\n        ans = i + 1\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nm =[0 for i in range(11)]\\nwyn = 0\\nfor i in range(n):\\n\\tm[l[i]] += 1\\n\\tb = [m[i] for i in range(11) if m[i] != 0]\\n\\tb = sorted(b)\\n\\t#print(b)\\n\\tif len(b) == 1:\\n\\t\\twyn = i + 1\\n\\tif len(b) > 1:\\n\\t\\tif b[0] == 1 and sum(b) == 1 + len(b)*b[1]-b[1]:\\n\\t\\t\\twyn = i + 1\\n\\t\\telse:\\n\\t\\t\\tif (b[0] == b[-2] and b[-1] == b[0] + 1):\\n\\t\\t\\t\\twyn = i + 1\\nprint(wyn)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = [0] * 11\\nma = 1\\nfor i in range(n):\\n    c[a[i]] += 1\\n    for k in range(1, 11):\\n        if c[k] > 0:\\n            c[k] -= 1\\n            s = {}\\n            for j in range(1, 11):\\n                if c[j] > 0:\\n                    if c[j] not in s:\\n                        s[c[j]] = 1\\n                    else:\\n                        s[c[j]] += 1\\n            c[k] += 1\\n            if len(s) == 1:\\n                ma = max(ma, i + 1)\\n                break\\n\\nprint(ma)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\nd = [0] * 10\\nmax_ = 1\\nfor i in range(n):\\n    d[arr[i] - 1] += 1\\n    lol = sorted([x for x in d if x > 0])\\n    kek = True\\n    for j in range(len(lol) - 2):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and len(lol) == 1:\\n        max_ = max(max_, i + 1)\\n        continue\\n    elif kek and lol[-1] - 1 == lol[-2]:\\n        max_ = max(max_, i + 1)\\n        continue\\n\\n    kek = True\\n    for j in range(1, len(lol) - 1):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and lol[0] - 1 == 0:\\n        max_ = max(max_, i + 1)\\nprint(max_)\\n\", \"ii = lambda:int(input())\\nkk=lambda:list(map(int,input().split()))\\nk2=lambda:[int(x)-1 for x in input().split()]\\nll=lambda:list(kk())\\nn=ii()\\nd = [0]*10\\nmaxi = 2\\nfor j,v in enumerate(k2()):\\n\\td[v]+=1\\n\\tvs = {}\\n\\tfor i in range(10):\\n\\t\\tif d[i] ==0: continue\\n\\t\\tif d[i] not in vs: vs[d[i]] = 0\\n\\t\\tvs[d[i]]+=1\\n\\tif len(vs) >2: continue\\n\\tif len(vs) == 2:\\n\\t\\tval = max(list(vs.keys()))\\n\\t\\tif (1 in vs and vs[1]==1) or(val-1 in vs and vs[val]==1): \\n\\t\\t\\tmaxi = j\\n\\telif len(vs) == 1 and (1 in vs or d.count(0) == 9):\\n\\t\\tmaxi = j\\n\\nprint(max(maxi+1, min(2, n)))\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = [0]*11\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"from random import random\\nfrom collections import defaultdict\\nimport math\\nimport re\\nimport fractions\\n\\nN = int(input())\\n# N, M = map(int, input().split(\\\" \\\"))\\nA = list(map(int, input().split(\\\" \\\")))\\narr = [0]*(10**5+1)\\nexisting = set()\\nfor a in A:\\n  arr[a] += 1\\n  existing.add(a)\\n\\naccumulate = defaultdict(int)\\nfor count in arr:\\n  accumulate[count] += 1\\n\\nfor i in range(len(A)-1, -1, -1):\\n  a = A[i]\\n  length = i+1\\n\\n  if len(existing) in [0, 1, length]:\\n    break\\n\\n  expected_1 = (i+1-1)//(len(existing)-1)\\n  if accumulate[expected_1] * expected_1 + 1 == length and accumulate[1] == 1:\\n    break\\n\\n  expected_k_1 = (i+1-1)//len(existing)\\n  if accumulate[expected_k_1] * expected_k_1 + expected_k_1 + 1 == length and accumulate[expected_k_1+1] == 1:\\n    break\\n\\n  accumulate[arr[a]] -= 1\\n  arr[a] -= 1\\n  if arr[a] == 0:\\n    existing.discard(a)\\n  accumulate[arr[a]] += 1\\n  # print(accumulate)\\nprint(length)\\n\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\n\\nd = {}\\nfor i in range(n):\\n\\td[a[i]] = 0\\n\\n\\n# numOdd = 0\\n# for i in range(n):\\n# \\td[a[i]] += 1\\n\\n# \\tif(d[a[i]] % 2 != 0):\\n# \\t\\tnumOdd += 1\\n\\n# \\telse:\\n# \\t\\tnumOdd -= 1\\n\\n# \\tif(numOdd == 1):\\n# \\t\\tx = i+1\\n\\n# print(x)\\n\\nx = 1\\nfor i in range(1,n):\\n\\tif(a[i] == a[i-1]):\\n\\t\\t# print(\\\"yo\\\")\\n\\t\\tx = i+1\\n\\telse:\\n\\t\\tbreak\\n\\nfor i in range(n):\\n\\td[a[i]] += 1\\n\\n\\tl = list(d.values())\\n\\tl = list(set(l))\\n\\tll = list(d.values())\\n\\tl.sort()\\n\\t# print(l)\\n\\tif(l[0] == 0):\\n\\t\\tl.pop(l[0])\\n\\t\\n\\tif(len(l) == 2):\\n\\t\\tif(abs(l[0] - l[1]) == 1 and ll.count(l[1]) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\t\\telif(l[0] == 1 and ll.count(1) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\tif(len(l) == 1 and l[0] == 1):\\n\\t\\tx = max(x,i+1)\\n\\nprint(x)\", \"n = int(input())\\n\\na = list(map(int,input().split()))\\nif(n == 1 or n == 2):\\n    print(n)\\n    return\\nnotpar = 0\\nocc = [0 for i in range(10**5 + 1)]\\nbase = 1\\ngotone = False\\nleader = -1\\nleadby = 0\\nbest = 0\\nocc[a[0]] += 1\\ncnt = 1\\nat1 = 1\\n\\n\\n\\nfor i in range(1, n):\\n    occ[a[i]] +=1\\n    \\n    if(occ[a[i]] == 1):\\n        notpar += 1\\n        at1 += 1\\n        cnt += 1\\n    elif(occ[a[i]] == 2):\\n        at1 -= 1\\n    if(occ[a[i]] == base):\\n        notpar -= 1\\n    elif(occ[a[i]] > base):\\n        if(gotone):\\n            if(a[i] != leader):\\n                base += 1\\n                notpar = cnt - 2\\n                leadby -= 1\\n                if(leadby == 0):\\n                    gotone = False\\n                    leader = -1\\n            else:\\n                leadby += 1\\n        else:\\n            gotone = True\\n            leader = a[i]\\n            leadby = 1\\n    if(notpar == 0 and (leadby == 1 or (leadby == 0 and base == 1)) or (notpar == 1 and leadby == 0 and at1 > 0)):\\n        best = i + 1\\n    if(cnt == 1):\\n        best = i + 1\\n    #print(i, base, leader, leadby, gotone, notpar, cnt)\\nprint(best)\\n                    \\n                    \\n\", \"\\n# -*- coding: utf-8 -*-\\n\\ndef __starting_point():\\n    n  = int(input())\\n    a = list(map(int, input().split()))\\n    b = [0 for i in range(10)]\\n    pos = 1\\n    for i in range(n):\\n        b[a[i]-1]+=1\\n        c = []\\n        for j in range(10):\\n            if (b[j]>0):\\n                c.append(b[j])\\n        c.sort()\\n        if (c[len(c)-1]==i+1) or (c[len(c)-1]==c[len(c)-2]+1 and c[len(c)-2]==c[0])\\\\\\n            or (c[len(c)-1]==c[1] and c[0]==1):\\n            pos = i+1\\n    print(pos)\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\ndic = {a[0]:1}\\n#board= ['*']*11\\nsu = 1\\nkq = 1\\nfor i in range(1, n):\\n    if dic.get(a[i], 0)==0:\\n        dic.update({a[i]:1})\\n    else:\\n        dic[a[i]]+=1\\n    su+=1\\n    cach = len(list(dic.keys()))\\n    c = 0\\n    c_=0\\n    for z in list(dic.keys()):\\n        if cach==1:\\n            continue\\n        if cach == su:\\n            kq = su\\n            continue\\n        if dic[z]== (su-1)/(cach-1):\\n            c+=1\\n        if dic[z]== (su-1)/cach:\\n            c_+=1\\n    if c==cach-1 or c_==cach-1:\\n        kq = su\\n\\nprint(kq)       \\n    \\n\", \"import sys\\n\\nn = int(input())\\nnums = list(map(int, input().split()))\\neleCount = {}\\npossibleMax = 1\\nfor i in range(n):\\n    if nums[i] in list(eleCount.keys()):\\n        eleCount[nums[i]] += 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\n    else:\\n        eleCount[nums[i]] = 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\nprint(possibleMax)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nb=[]\\nfor i in range(11):\\n    b.append(0)\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"def check():\\n    mn = float('inf')\\n    mx = 0\\n    k = 0\\n    for i in mas:\\n        if i != 0:\\n            k += 1\\n            mx = max(mx, i)\\n            mn = min(mn, i)\\n    if (mx - mn <= 1 and mas.count(mx) == 1) or (mn == 1 and k == 1 + mas.count(mx)) or (mn == mx == 1):\\n        return True\\n    return False\\nn = int(input())\\nl = list(map(int, input().split()))\\nmas = [0] * 10\\nans = 0\\nfor i in range(n):\\n    mas[l[i] - 1] += 1\\n    if check():\\n        #print(i)\\n        #print('check')\\n        ans = i\\nprint(ans + 1)\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/5/9 23:15\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B1. Cat Party (Easy Edition).py\\n\\nfrom collections import Counter\\n\\n\\ndef check(counter, curr_len, curr_color, curr_one):\\n    if curr_len == 1 or curr_color == 1 or curr_one == curr_len:\\n        return True\\n\\n    # if curr_len == 13:\\n    #     print(counter)\\n    if curr_one == 1:\\n        curr_color -= 1\\n    if (curr_len - 1) % curr_color != 0:\\n        return False\\n    correct_num = (curr_len - 1) // curr_color\\n    # if curr_len == 13:\\n    #     print(correct_num)\\n\\n    false_count, false_num = 0, 0\\n    for i in range(1, 11):\\n        if counter[i] != correct_num and counter[i] != 0:\\n            false_count += 1\\n            false_num = counter[i]\\n    # if curr_len == 13:\\n    #     print(false_count)\\n\\n    return false_count == 1 and (false_num - 1 == correct_num or false_count - 1 == 0)\\n\\n\\ndef main():\\n    n = int(input())\\n    u = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    max_days, curr_color, curr_one = 0, 0, 0\\n    for i in range(n):\\n        if counter[u[i]] == 0:\\n            curr_color += 1\\n            curr_one += 1\\n\\n        if counter[u[i]] == 1:\\n            curr_one -= 1\\n\\n        counter[u[i]] += 1\\n        if check(counter, i + 1, curr_color, curr_one):\\n            max_days = i + 1\\n    print(max_days)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "6\n1 1 1 2 2 2\n",
        "output": "5",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1163/B1"
    },
    {
        "id": 1926,
        "task_id": 1973,
        "test_case_id": 6,
        "question": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $i$-th day has a ribbon with color $u_i$. Shiro wants to know the largest number $x$, such that if we consider the streak of the first $x$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $x - 1$ will have the same number of occurrences.\n\nFor example, consider the following sequence of $u_i$: $[2, 2, 1, 1, 5, 4, 4, 5]$. Then $x = 7$ makes a streak, since if we remove the leftmost $u_i = 5$, each ribbon color will appear exactly twice in the prefix of $x - 1$ days. Note that $x = 8$ doesn't form a streak, since you must remove exactly one day. \n\nSince Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^5$) — the total number of days.\n\nThe second line contains $n$ integers $u_1, u_2, \\ldots, u_n$ ($1 \\leq u_i \\leq 10$) — the colors of the ribbons the cats wear. \n\n\n-----Output-----\n\nPrint a single integer $x$ — the largest possible streak of days.\n\n\n-----Examples-----\nInput\n13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n\nOutput\n13\nInput\n5\n10 2 5 4 1\n\nOutput\n5\nInput\n1\n10\n\nOutput\n1\nInput\n7\n3 2 1 1 4 5 1\n\nOutput\n6\nInput\n6\n1 1 1 2 2 2\n\nOutput\n5\n\n\n-----Note-----\n\nIn the first example, we can choose the longest streak of $13$ days, since upon removing the last day out of the streak, all of the remaining colors $1$, $2$, $3$, and $4$ will have the same number of occurrences of $3$. Note that the streak can also be $10$ days (by removing the $10$-th day from this streak) but we are interested in the longest streak.\n\nIn the fourth example, if we take the streak of the first $6$ days, we can remove the third day from this streak then all of the remaining colors $1$, $2$, $3$, $4$ and $5$ will occur exactly once.",
        "solutions": "[\"n = int(input())\\nu = [int(u) for u in input().split()]\\n\\nNMAX = 100005\\n\\nsuma = [0 for _ in range(NMAX)]\\ntotal = [0 for _ in range(NMAX)]\\n\\ndiferentes = 0\\nsol = 0\\nmaximo = 1\\n\\nfor i, v in enumerate(u):\\n\\tif total[v] == 0:\\n\\t\\tdiferentes += 1\\n\\telse:\\n\\t\\tsuma[total[v]] -= 1\\n\\ttotal[v] += 1\\n\\tsuma[total[v]] += 1\\n\\n\\tmaximo = max(maximo, total[v])\\n\\n\\t#print(i, v, \\\":\\\", diferentes)\\n\\t#print(suma)\\n\\t#print(total)\\n\\t#print(maximo, \\\":\\\", suma[maximo], suma[maximo+1], diferentes-1)\\n\\t#print(maximo, \\\":\\\", suma[maximo-1], suma[maximo], diferentes-1)\\n\\n\\tif diferentes <= 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo-1] == diferentes-1 and suma[maximo] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo] == diferentes-1 and suma[1] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[1] == diferentes:\\n\\t\\tsol = i\\n\\t\\n\\t#print(\\\"SOL\\\", sol)\\n\\nprint(sol+1)\\n\", \"n = int(input())\\na = [int(x) - 1 for x in input().split()]\\ncounts = [0] * 10\\nfor ind, i in enumerate(a):\\n    counts[i] += 1\\n    k = sorted([i for i in counts if i])\\n    if len(k) == 1 or (k[0] == k[-2] and k[-1] - k[-2] == 1) or (k[0] == 1 and k[1] == k[-1]):\\n        best = ind\\nprint(best + 1)\", \"def main():\\n    from sys import stdin, stdout\\n\\n    def read():\\n        return stdin.readline().rstrip('\\\\n')\\n\\n    def read_array(sep=None, maxsplit=-1):\\n        return read().split(sep, maxsplit)\\n\\n    def read_int():\\n        return int(read())\\n\\n    def read_int_array(sep=None, maxsplit=-1):\\n        return [int(a) for a in read_array(sep, maxsplit)]\\n\\n    def write(*args, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in args) + end)\\n\\n    def write_array(array, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in array) + end)\\n\\n    n = read_int()\\n    nums = read_int_array()\\n    counts = {}\\n    import collections\\n    inv_counts = collections.defaultdict(int)\\n    out = 0\\n    for i, x in enumerate(nums):\\n        c = inv_counts[x]\\n        if c:\\n            counts[c].remove(x)\\n            if not counts[c]:\\n                counts.pop(c)\\n        c += 1\\n        inv_counts[x] = c\\n        counts.setdefault(c, set()).add(x)\\n        if len(counts) == 2 and any(len(s) == 1 and ((k-1 in counts) or k == 1) for k, s in list(counts.items())):\\n            out = i + 1\\n        elif len(counts) == 1:\\n            k = next(iter(list(counts.keys())))\\n            if k == 1 or len(counts[k]) == 1:\\n                out = i + 1\\n    write(out)\\n\\nmain()\\n\", \"NUMS = [0 for i in range(10)]\\n\\ndef check(nums):\\n    maxi = max(nums)\\n    category = nums.count(maxi)\\n    if category == 1:\\n        oneof = 0\\n        for n in nums:\\n            if n == maxi:\\n                continue\\n            if n == 0:\\n                continue\\n            if oneof != 0 and (n != oneof or n != maxi - 1):\\n                return False\\n            oneof = n\\n    \\n        return True\\n    \\n    else:\\n        if maxi != 1:\\n            if nums.count(1) != 1:\\n                return False\\n            if nums.count(0) != len(nums) - category - 1:\\n                return False\\n            return True\\n        else:\\n            return True\\n\\nn = int(input())\\ncolors = list(map(int, input().split()))\\nres = 0\\nfor i in range(n):\\n    NUMS[colors[i] - 1] += 1\\n    if check(NUMS):\\n        res = i + 1\\n\\nprint(res)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\n\\nC = [0] * 101010\\nma = 0\\nmacnt = 0\\nposcnt = 0\\ncntofone = 0\\nans = 0\\nfor i in range(N):\\n    C[A[i]] += 1\\n    if C[A[i]] > ma:\\n        ma = C[A[i]]\\n        macnt = 1\\n    elif ma == C[A[i]]:\\n        macnt += 1\\n    if C[A[i]] == 1:\\n        poscnt += 1\\n        cntofone += 1\\n    elif C[A[i]] == 2:\\n        cntofone -= 1\\n    if i <= 1 or (cntofone >= 1 and ((poscnt - 1) * ma == i)) or (macnt == 1 and (poscnt * (ma - 1) == i)):\\n        ans = i + 1\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nm =[0 for i in range(11)]\\nwyn = 0\\nfor i in range(n):\\n\\tm[l[i]] += 1\\n\\tb = [m[i] for i in range(11) if m[i] != 0]\\n\\tb = sorted(b)\\n\\t#print(b)\\n\\tif len(b) == 1:\\n\\t\\twyn = i + 1\\n\\tif len(b) > 1:\\n\\t\\tif b[0] == 1 and sum(b) == 1 + len(b)*b[1]-b[1]:\\n\\t\\t\\twyn = i + 1\\n\\t\\telse:\\n\\t\\t\\tif (b[0] == b[-2] and b[-1] == b[0] + 1):\\n\\t\\t\\t\\twyn = i + 1\\nprint(wyn)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = [0] * 11\\nma = 1\\nfor i in range(n):\\n    c[a[i]] += 1\\n    for k in range(1, 11):\\n        if c[k] > 0:\\n            c[k] -= 1\\n            s = {}\\n            for j in range(1, 11):\\n                if c[j] > 0:\\n                    if c[j] not in s:\\n                        s[c[j]] = 1\\n                    else:\\n                        s[c[j]] += 1\\n            c[k] += 1\\n            if len(s) == 1:\\n                ma = max(ma, i + 1)\\n                break\\n\\nprint(ma)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\nd = [0] * 10\\nmax_ = 1\\nfor i in range(n):\\n    d[arr[i] - 1] += 1\\n    lol = sorted([x for x in d if x > 0])\\n    kek = True\\n    for j in range(len(lol) - 2):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and len(lol) == 1:\\n        max_ = max(max_, i + 1)\\n        continue\\n    elif kek and lol[-1] - 1 == lol[-2]:\\n        max_ = max(max_, i + 1)\\n        continue\\n\\n    kek = True\\n    for j in range(1, len(lol) - 1):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and lol[0] - 1 == 0:\\n        max_ = max(max_, i + 1)\\nprint(max_)\\n\", \"ii = lambda:int(input())\\nkk=lambda:list(map(int,input().split()))\\nk2=lambda:[int(x)-1 for x in input().split()]\\nll=lambda:list(kk())\\nn=ii()\\nd = [0]*10\\nmaxi = 2\\nfor j,v in enumerate(k2()):\\n\\td[v]+=1\\n\\tvs = {}\\n\\tfor i in range(10):\\n\\t\\tif d[i] ==0: continue\\n\\t\\tif d[i] not in vs: vs[d[i]] = 0\\n\\t\\tvs[d[i]]+=1\\n\\tif len(vs) >2: continue\\n\\tif len(vs) == 2:\\n\\t\\tval = max(list(vs.keys()))\\n\\t\\tif (1 in vs and vs[1]==1) or(val-1 in vs and vs[val]==1): \\n\\t\\t\\tmaxi = j\\n\\telif len(vs) == 1 and (1 in vs or d.count(0) == 9):\\n\\t\\tmaxi = j\\n\\nprint(max(maxi+1, min(2, n)))\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = [0]*11\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"from random import random\\nfrom collections import defaultdict\\nimport math\\nimport re\\nimport fractions\\n\\nN = int(input())\\n# N, M = map(int, input().split(\\\" \\\"))\\nA = list(map(int, input().split(\\\" \\\")))\\narr = [0]*(10**5+1)\\nexisting = set()\\nfor a in A:\\n  arr[a] += 1\\n  existing.add(a)\\n\\naccumulate = defaultdict(int)\\nfor count in arr:\\n  accumulate[count] += 1\\n\\nfor i in range(len(A)-1, -1, -1):\\n  a = A[i]\\n  length = i+1\\n\\n  if len(existing) in [0, 1, length]:\\n    break\\n\\n  expected_1 = (i+1-1)//(len(existing)-1)\\n  if accumulate[expected_1] * expected_1 + 1 == length and accumulate[1] == 1:\\n    break\\n\\n  expected_k_1 = (i+1-1)//len(existing)\\n  if accumulate[expected_k_1] * expected_k_1 + expected_k_1 + 1 == length and accumulate[expected_k_1+1] == 1:\\n    break\\n\\n  accumulate[arr[a]] -= 1\\n  arr[a] -= 1\\n  if arr[a] == 0:\\n    existing.discard(a)\\n  accumulate[arr[a]] += 1\\n  # print(accumulate)\\nprint(length)\\n\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\n\\nd = {}\\nfor i in range(n):\\n\\td[a[i]] = 0\\n\\n\\n# numOdd = 0\\n# for i in range(n):\\n# \\td[a[i]] += 1\\n\\n# \\tif(d[a[i]] % 2 != 0):\\n# \\t\\tnumOdd += 1\\n\\n# \\telse:\\n# \\t\\tnumOdd -= 1\\n\\n# \\tif(numOdd == 1):\\n# \\t\\tx = i+1\\n\\n# print(x)\\n\\nx = 1\\nfor i in range(1,n):\\n\\tif(a[i] == a[i-1]):\\n\\t\\t# print(\\\"yo\\\")\\n\\t\\tx = i+1\\n\\telse:\\n\\t\\tbreak\\n\\nfor i in range(n):\\n\\td[a[i]] += 1\\n\\n\\tl = list(d.values())\\n\\tl = list(set(l))\\n\\tll = list(d.values())\\n\\tl.sort()\\n\\t# print(l)\\n\\tif(l[0] == 0):\\n\\t\\tl.pop(l[0])\\n\\t\\n\\tif(len(l) == 2):\\n\\t\\tif(abs(l[0] - l[1]) == 1 and ll.count(l[1]) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\t\\telif(l[0] == 1 and ll.count(1) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\tif(len(l) == 1 and l[0] == 1):\\n\\t\\tx = max(x,i+1)\\n\\nprint(x)\", \"n = int(input())\\n\\na = list(map(int,input().split()))\\nif(n == 1 or n == 2):\\n    print(n)\\n    return\\nnotpar = 0\\nocc = [0 for i in range(10**5 + 1)]\\nbase = 1\\ngotone = False\\nleader = -1\\nleadby = 0\\nbest = 0\\nocc[a[0]] += 1\\ncnt = 1\\nat1 = 1\\n\\n\\n\\nfor i in range(1, n):\\n    occ[a[i]] +=1\\n    \\n    if(occ[a[i]] == 1):\\n        notpar += 1\\n        at1 += 1\\n        cnt += 1\\n    elif(occ[a[i]] == 2):\\n        at1 -= 1\\n    if(occ[a[i]] == base):\\n        notpar -= 1\\n    elif(occ[a[i]] > base):\\n        if(gotone):\\n            if(a[i] != leader):\\n                base += 1\\n                notpar = cnt - 2\\n                leadby -= 1\\n                if(leadby == 0):\\n                    gotone = False\\n                    leader = -1\\n            else:\\n                leadby += 1\\n        else:\\n            gotone = True\\n            leader = a[i]\\n            leadby = 1\\n    if(notpar == 0 and (leadby == 1 or (leadby == 0 and base == 1)) or (notpar == 1 and leadby == 0 and at1 > 0)):\\n        best = i + 1\\n    if(cnt == 1):\\n        best = i + 1\\n    #print(i, base, leader, leadby, gotone, notpar, cnt)\\nprint(best)\\n                    \\n                    \\n\", \"\\n# -*- coding: utf-8 -*-\\n\\ndef __starting_point():\\n    n  = int(input())\\n    a = list(map(int, input().split()))\\n    b = [0 for i in range(10)]\\n    pos = 1\\n    for i in range(n):\\n        b[a[i]-1]+=1\\n        c = []\\n        for j in range(10):\\n            if (b[j]>0):\\n                c.append(b[j])\\n        c.sort()\\n        if (c[len(c)-1]==i+1) or (c[len(c)-1]==c[len(c)-2]+1 and c[len(c)-2]==c[0])\\\\\\n            or (c[len(c)-1]==c[1] and c[0]==1):\\n            pos = i+1\\n    print(pos)\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\ndic = {a[0]:1}\\n#board= ['*']*11\\nsu = 1\\nkq = 1\\nfor i in range(1, n):\\n    if dic.get(a[i], 0)==0:\\n        dic.update({a[i]:1})\\n    else:\\n        dic[a[i]]+=1\\n    su+=1\\n    cach = len(list(dic.keys()))\\n    c = 0\\n    c_=0\\n    for z in list(dic.keys()):\\n        if cach==1:\\n            continue\\n        if cach == su:\\n            kq = su\\n            continue\\n        if dic[z]== (su-1)/(cach-1):\\n            c+=1\\n        if dic[z]== (su-1)/cach:\\n            c_+=1\\n    if c==cach-1 or c_==cach-1:\\n        kq = su\\n\\nprint(kq)       \\n    \\n\", \"import sys\\n\\nn = int(input())\\nnums = list(map(int, input().split()))\\neleCount = {}\\npossibleMax = 1\\nfor i in range(n):\\n    if nums[i] in list(eleCount.keys()):\\n        eleCount[nums[i]] += 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\n    else:\\n        eleCount[nums[i]] = 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\nprint(possibleMax)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nb=[]\\nfor i in range(11):\\n    b.append(0)\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"def check():\\n    mn = float('inf')\\n    mx = 0\\n    k = 0\\n    for i in mas:\\n        if i != 0:\\n            k += 1\\n            mx = max(mx, i)\\n            mn = min(mn, i)\\n    if (mx - mn <= 1 and mas.count(mx) == 1) or (mn == 1 and k == 1 + mas.count(mx)) or (mn == mx == 1):\\n        return True\\n    return False\\nn = int(input())\\nl = list(map(int, input().split()))\\nmas = [0] * 10\\nans = 0\\nfor i in range(n):\\n    mas[l[i] - 1] += 1\\n    if check():\\n        #print(i)\\n        #print('check')\\n        ans = i\\nprint(ans + 1)\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/5/9 23:15\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B1. Cat Party (Easy Edition).py\\n\\nfrom collections import Counter\\n\\n\\ndef check(counter, curr_len, curr_color, curr_one):\\n    if curr_len == 1 or curr_color == 1 or curr_one == curr_len:\\n        return True\\n\\n    # if curr_len == 13:\\n    #     print(counter)\\n    if curr_one == 1:\\n        curr_color -= 1\\n    if (curr_len - 1) % curr_color != 0:\\n        return False\\n    correct_num = (curr_len - 1) // curr_color\\n    # if curr_len == 13:\\n    #     print(correct_num)\\n\\n    false_count, false_num = 0, 0\\n    for i in range(1, 11):\\n        if counter[i] != correct_num and counter[i] != 0:\\n            false_count += 1\\n            false_num = counter[i]\\n    # if curr_len == 13:\\n    #     print(false_count)\\n\\n    return false_count == 1 and (false_num - 1 == correct_num or false_count - 1 == 0)\\n\\n\\ndef main():\\n    n = int(input())\\n    u = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    max_days, curr_color, curr_one = 0, 0, 0\\n    for i in range(n):\\n        if counter[u[i]] == 0:\\n            curr_color += 1\\n            curr_one += 1\\n\\n        if counter[u[i]] == 1:\\n            curr_one -= 1\\n\\n        counter[u[i]] += 1\\n        if check(counter, i + 1, curr_color, curr_one):\\n            max_days = i + 1\\n    print(max_days)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "10\n8 8 1 1 1 2 7 7 8 4\n",
        "output": "5",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1163/B1"
    },
    {
        "id": 1927,
        "task_id": 1973,
        "test_case_id": 7,
        "question": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $i$-th day has a ribbon with color $u_i$. Shiro wants to know the largest number $x$, such that if we consider the streak of the first $x$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $x - 1$ will have the same number of occurrences.\n\nFor example, consider the following sequence of $u_i$: $[2, 2, 1, 1, 5, 4, 4, 5]$. Then $x = 7$ makes a streak, since if we remove the leftmost $u_i = 5$, each ribbon color will appear exactly twice in the prefix of $x - 1$ days. Note that $x = 8$ doesn't form a streak, since you must remove exactly one day. \n\nSince Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^5$) — the total number of days.\n\nThe second line contains $n$ integers $u_1, u_2, \\ldots, u_n$ ($1 \\leq u_i \\leq 10$) — the colors of the ribbons the cats wear. \n\n\n-----Output-----\n\nPrint a single integer $x$ — the largest possible streak of days.\n\n\n-----Examples-----\nInput\n13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n\nOutput\n13\nInput\n5\n10 2 5 4 1\n\nOutput\n5\nInput\n1\n10\n\nOutput\n1\nInput\n7\n3 2 1 1 4 5 1\n\nOutput\n6\nInput\n6\n1 1 1 2 2 2\n\nOutput\n5\n\n\n-----Note-----\n\nIn the first example, we can choose the longest streak of $13$ days, since upon removing the last day out of the streak, all of the remaining colors $1$, $2$, $3$, and $4$ will have the same number of occurrences of $3$. Note that the streak can also be $10$ days (by removing the $10$-th day from this streak) but we are interested in the longest streak.\n\nIn the fourth example, if we take the streak of the first $6$ days, we can remove the third day from this streak then all of the remaining colors $1$, $2$, $3$, $4$ and $5$ will occur exactly once.",
        "solutions": "[\"n = int(input())\\nu = [int(u) for u in input().split()]\\n\\nNMAX = 100005\\n\\nsuma = [0 for _ in range(NMAX)]\\ntotal = [0 for _ in range(NMAX)]\\n\\ndiferentes = 0\\nsol = 0\\nmaximo = 1\\n\\nfor i, v in enumerate(u):\\n\\tif total[v] == 0:\\n\\t\\tdiferentes += 1\\n\\telse:\\n\\t\\tsuma[total[v]] -= 1\\n\\ttotal[v] += 1\\n\\tsuma[total[v]] += 1\\n\\n\\tmaximo = max(maximo, total[v])\\n\\n\\t#print(i, v, \\\":\\\", diferentes)\\n\\t#print(suma)\\n\\t#print(total)\\n\\t#print(maximo, \\\":\\\", suma[maximo], suma[maximo+1], diferentes-1)\\n\\t#print(maximo, \\\":\\\", suma[maximo-1], suma[maximo], diferentes-1)\\n\\n\\tif diferentes <= 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo-1] == diferentes-1 and suma[maximo] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo] == diferentes-1 and suma[1] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[1] == diferentes:\\n\\t\\tsol = i\\n\\t\\n\\t#print(\\\"SOL\\\", sol)\\n\\nprint(sol+1)\\n\", \"n = int(input())\\na = [int(x) - 1 for x in input().split()]\\ncounts = [0] * 10\\nfor ind, i in enumerate(a):\\n    counts[i] += 1\\n    k = sorted([i for i in counts if i])\\n    if len(k) == 1 or (k[0] == k[-2] and k[-1] - k[-2] == 1) or (k[0] == 1 and k[1] == k[-1]):\\n        best = ind\\nprint(best + 1)\", \"def main():\\n    from sys import stdin, stdout\\n\\n    def read():\\n        return stdin.readline().rstrip('\\\\n')\\n\\n    def read_array(sep=None, maxsplit=-1):\\n        return read().split(sep, maxsplit)\\n\\n    def read_int():\\n        return int(read())\\n\\n    def read_int_array(sep=None, maxsplit=-1):\\n        return [int(a) for a in read_array(sep, maxsplit)]\\n\\n    def write(*args, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in args) + end)\\n\\n    def write_array(array, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in array) + end)\\n\\n    n = read_int()\\n    nums = read_int_array()\\n    counts = {}\\n    import collections\\n    inv_counts = collections.defaultdict(int)\\n    out = 0\\n    for i, x in enumerate(nums):\\n        c = inv_counts[x]\\n        if c:\\n            counts[c].remove(x)\\n            if not counts[c]:\\n                counts.pop(c)\\n        c += 1\\n        inv_counts[x] = c\\n        counts.setdefault(c, set()).add(x)\\n        if len(counts) == 2 and any(len(s) == 1 and ((k-1 in counts) or k == 1) for k, s in list(counts.items())):\\n            out = i + 1\\n        elif len(counts) == 1:\\n            k = next(iter(list(counts.keys())))\\n            if k == 1 or len(counts[k]) == 1:\\n                out = i + 1\\n    write(out)\\n\\nmain()\\n\", \"NUMS = [0 for i in range(10)]\\n\\ndef check(nums):\\n    maxi = max(nums)\\n    category = nums.count(maxi)\\n    if category == 1:\\n        oneof = 0\\n        for n in nums:\\n            if n == maxi:\\n                continue\\n            if n == 0:\\n                continue\\n            if oneof != 0 and (n != oneof or n != maxi - 1):\\n                return False\\n            oneof = n\\n    \\n        return True\\n    \\n    else:\\n        if maxi != 1:\\n            if nums.count(1) != 1:\\n                return False\\n            if nums.count(0) != len(nums) - category - 1:\\n                return False\\n            return True\\n        else:\\n            return True\\n\\nn = int(input())\\ncolors = list(map(int, input().split()))\\nres = 0\\nfor i in range(n):\\n    NUMS[colors[i] - 1] += 1\\n    if check(NUMS):\\n        res = i + 1\\n\\nprint(res)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\n\\nC = [0] * 101010\\nma = 0\\nmacnt = 0\\nposcnt = 0\\ncntofone = 0\\nans = 0\\nfor i in range(N):\\n    C[A[i]] += 1\\n    if C[A[i]] > ma:\\n        ma = C[A[i]]\\n        macnt = 1\\n    elif ma == C[A[i]]:\\n        macnt += 1\\n    if C[A[i]] == 1:\\n        poscnt += 1\\n        cntofone += 1\\n    elif C[A[i]] == 2:\\n        cntofone -= 1\\n    if i <= 1 or (cntofone >= 1 and ((poscnt - 1) * ma == i)) or (macnt == 1 and (poscnt * (ma - 1) == i)):\\n        ans = i + 1\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nm =[0 for i in range(11)]\\nwyn = 0\\nfor i in range(n):\\n\\tm[l[i]] += 1\\n\\tb = [m[i] for i in range(11) if m[i] != 0]\\n\\tb = sorted(b)\\n\\t#print(b)\\n\\tif len(b) == 1:\\n\\t\\twyn = i + 1\\n\\tif len(b) > 1:\\n\\t\\tif b[0] == 1 and sum(b) == 1 + len(b)*b[1]-b[1]:\\n\\t\\t\\twyn = i + 1\\n\\t\\telse:\\n\\t\\t\\tif (b[0] == b[-2] and b[-1] == b[0] + 1):\\n\\t\\t\\t\\twyn = i + 1\\nprint(wyn)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = [0] * 11\\nma = 1\\nfor i in range(n):\\n    c[a[i]] += 1\\n    for k in range(1, 11):\\n        if c[k] > 0:\\n            c[k] -= 1\\n            s = {}\\n            for j in range(1, 11):\\n                if c[j] > 0:\\n                    if c[j] not in s:\\n                        s[c[j]] = 1\\n                    else:\\n                        s[c[j]] += 1\\n            c[k] += 1\\n            if len(s) == 1:\\n                ma = max(ma, i + 1)\\n                break\\n\\nprint(ma)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\nd = [0] * 10\\nmax_ = 1\\nfor i in range(n):\\n    d[arr[i] - 1] += 1\\n    lol = sorted([x for x in d if x > 0])\\n    kek = True\\n    for j in range(len(lol) - 2):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and len(lol) == 1:\\n        max_ = max(max_, i + 1)\\n        continue\\n    elif kek and lol[-1] - 1 == lol[-2]:\\n        max_ = max(max_, i + 1)\\n        continue\\n\\n    kek = True\\n    for j in range(1, len(lol) - 1):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and lol[0] - 1 == 0:\\n        max_ = max(max_, i + 1)\\nprint(max_)\\n\", \"ii = lambda:int(input())\\nkk=lambda:list(map(int,input().split()))\\nk2=lambda:[int(x)-1 for x in input().split()]\\nll=lambda:list(kk())\\nn=ii()\\nd = [0]*10\\nmaxi = 2\\nfor j,v in enumerate(k2()):\\n\\td[v]+=1\\n\\tvs = {}\\n\\tfor i in range(10):\\n\\t\\tif d[i] ==0: continue\\n\\t\\tif d[i] not in vs: vs[d[i]] = 0\\n\\t\\tvs[d[i]]+=1\\n\\tif len(vs) >2: continue\\n\\tif len(vs) == 2:\\n\\t\\tval = max(list(vs.keys()))\\n\\t\\tif (1 in vs and vs[1]==1) or(val-1 in vs and vs[val]==1): \\n\\t\\t\\tmaxi = j\\n\\telif len(vs) == 1 and (1 in vs or d.count(0) == 9):\\n\\t\\tmaxi = j\\n\\nprint(max(maxi+1, min(2, n)))\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = [0]*11\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"from random import random\\nfrom collections import defaultdict\\nimport math\\nimport re\\nimport fractions\\n\\nN = int(input())\\n# N, M = map(int, input().split(\\\" \\\"))\\nA = list(map(int, input().split(\\\" \\\")))\\narr = [0]*(10**5+1)\\nexisting = set()\\nfor a in A:\\n  arr[a] += 1\\n  existing.add(a)\\n\\naccumulate = defaultdict(int)\\nfor count in arr:\\n  accumulate[count] += 1\\n\\nfor i in range(len(A)-1, -1, -1):\\n  a = A[i]\\n  length = i+1\\n\\n  if len(existing) in [0, 1, length]:\\n    break\\n\\n  expected_1 = (i+1-1)//(len(existing)-1)\\n  if accumulate[expected_1] * expected_1 + 1 == length and accumulate[1] == 1:\\n    break\\n\\n  expected_k_1 = (i+1-1)//len(existing)\\n  if accumulate[expected_k_1] * expected_k_1 + expected_k_1 + 1 == length and accumulate[expected_k_1+1] == 1:\\n    break\\n\\n  accumulate[arr[a]] -= 1\\n  arr[a] -= 1\\n  if arr[a] == 0:\\n    existing.discard(a)\\n  accumulate[arr[a]] += 1\\n  # print(accumulate)\\nprint(length)\\n\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\n\\nd = {}\\nfor i in range(n):\\n\\td[a[i]] = 0\\n\\n\\n# numOdd = 0\\n# for i in range(n):\\n# \\td[a[i]] += 1\\n\\n# \\tif(d[a[i]] % 2 != 0):\\n# \\t\\tnumOdd += 1\\n\\n# \\telse:\\n# \\t\\tnumOdd -= 1\\n\\n# \\tif(numOdd == 1):\\n# \\t\\tx = i+1\\n\\n# print(x)\\n\\nx = 1\\nfor i in range(1,n):\\n\\tif(a[i] == a[i-1]):\\n\\t\\t# print(\\\"yo\\\")\\n\\t\\tx = i+1\\n\\telse:\\n\\t\\tbreak\\n\\nfor i in range(n):\\n\\td[a[i]] += 1\\n\\n\\tl = list(d.values())\\n\\tl = list(set(l))\\n\\tll = list(d.values())\\n\\tl.sort()\\n\\t# print(l)\\n\\tif(l[0] == 0):\\n\\t\\tl.pop(l[0])\\n\\t\\n\\tif(len(l) == 2):\\n\\t\\tif(abs(l[0] - l[1]) == 1 and ll.count(l[1]) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\t\\telif(l[0] == 1 and ll.count(1) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\tif(len(l) == 1 and l[0] == 1):\\n\\t\\tx = max(x,i+1)\\n\\nprint(x)\", \"n = int(input())\\n\\na = list(map(int,input().split()))\\nif(n == 1 or n == 2):\\n    print(n)\\n    return\\nnotpar = 0\\nocc = [0 for i in range(10**5 + 1)]\\nbase = 1\\ngotone = False\\nleader = -1\\nleadby = 0\\nbest = 0\\nocc[a[0]] += 1\\ncnt = 1\\nat1 = 1\\n\\n\\n\\nfor i in range(1, n):\\n    occ[a[i]] +=1\\n    \\n    if(occ[a[i]] == 1):\\n        notpar += 1\\n        at1 += 1\\n        cnt += 1\\n    elif(occ[a[i]] == 2):\\n        at1 -= 1\\n    if(occ[a[i]] == base):\\n        notpar -= 1\\n    elif(occ[a[i]] > base):\\n        if(gotone):\\n            if(a[i] != leader):\\n                base += 1\\n                notpar = cnt - 2\\n                leadby -= 1\\n                if(leadby == 0):\\n                    gotone = False\\n                    leader = -1\\n            else:\\n                leadby += 1\\n        else:\\n            gotone = True\\n            leader = a[i]\\n            leadby = 1\\n    if(notpar == 0 and (leadby == 1 or (leadby == 0 and base == 1)) or (notpar == 1 and leadby == 0 and at1 > 0)):\\n        best = i + 1\\n    if(cnt == 1):\\n        best = i + 1\\n    #print(i, base, leader, leadby, gotone, notpar, cnt)\\nprint(best)\\n                    \\n                    \\n\", \"\\n# -*- coding: utf-8 -*-\\n\\ndef __starting_point():\\n    n  = int(input())\\n    a = list(map(int, input().split()))\\n    b = [0 for i in range(10)]\\n    pos = 1\\n    for i in range(n):\\n        b[a[i]-1]+=1\\n        c = []\\n        for j in range(10):\\n            if (b[j]>0):\\n                c.append(b[j])\\n        c.sort()\\n        if (c[len(c)-1]==i+1) or (c[len(c)-1]==c[len(c)-2]+1 and c[len(c)-2]==c[0])\\\\\\n            or (c[len(c)-1]==c[1] and c[0]==1):\\n            pos = i+1\\n    print(pos)\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\ndic = {a[0]:1}\\n#board= ['*']*11\\nsu = 1\\nkq = 1\\nfor i in range(1, n):\\n    if dic.get(a[i], 0)==0:\\n        dic.update({a[i]:1})\\n    else:\\n        dic[a[i]]+=1\\n    su+=1\\n    cach = len(list(dic.keys()))\\n    c = 0\\n    c_=0\\n    for z in list(dic.keys()):\\n        if cach==1:\\n            continue\\n        if cach == su:\\n            kq = su\\n            continue\\n        if dic[z]== (su-1)/(cach-1):\\n            c+=1\\n        if dic[z]== (su-1)/cach:\\n            c_+=1\\n    if c==cach-1 or c_==cach-1:\\n        kq = su\\n\\nprint(kq)       \\n    \\n\", \"import sys\\n\\nn = int(input())\\nnums = list(map(int, input().split()))\\neleCount = {}\\npossibleMax = 1\\nfor i in range(n):\\n    if nums[i] in list(eleCount.keys()):\\n        eleCount[nums[i]] += 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\n    else:\\n        eleCount[nums[i]] = 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\nprint(possibleMax)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nb=[]\\nfor i in range(11):\\n    b.append(0)\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"def check():\\n    mn = float('inf')\\n    mx = 0\\n    k = 0\\n    for i in mas:\\n        if i != 0:\\n            k += 1\\n            mx = max(mx, i)\\n            mn = min(mn, i)\\n    if (mx - mn <= 1 and mas.count(mx) == 1) or (mn == 1 and k == 1 + mas.count(mx)) or (mn == mx == 1):\\n        return True\\n    return False\\nn = int(input())\\nl = list(map(int, input().split()))\\nmas = [0] * 10\\nans = 0\\nfor i in range(n):\\n    mas[l[i] - 1] += 1\\n    if check():\\n        #print(i)\\n        #print('check')\\n        ans = i\\nprint(ans + 1)\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/5/9 23:15\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B1. Cat Party (Easy Edition).py\\n\\nfrom collections import Counter\\n\\n\\ndef check(counter, curr_len, curr_color, curr_one):\\n    if curr_len == 1 or curr_color == 1 or curr_one == curr_len:\\n        return True\\n\\n    # if curr_len == 13:\\n    #     print(counter)\\n    if curr_one == 1:\\n        curr_color -= 1\\n    if (curr_len - 1) % curr_color != 0:\\n        return False\\n    correct_num = (curr_len - 1) // curr_color\\n    # if curr_len == 13:\\n    #     print(correct_num)\\n\\n    false_count, false_num = 0, 0\\n    for i in range(1, 11):\\n        if counter[i] != correct_num and counter[i] != 0:\\n            false_count += 1\\n            false_num = counter[i]\\n    # if curr_len == 13:\\n    #     print(false_count)\\n\\n    return false_count == 1 and (false_num - 1 == correct_num or false_count - 1 == 0)\\n\\n\\ndef main():\\n    n = int(input())\\n    u = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    max_days, curr_color, curr_one = 0, 0, 0\\n    for i in range(n):\\n        if counter[u[i]] == 0:\\n            curr_color += 1\\n            curr_one += 1\\n\\n        if counter[u[i]] == 1:\\n            curr_one -= 1\\n\\n        counter[u[i]] += 1\\n        if check(counter, i + 1, curr_color, curr_one):\\n            max_days = i + 1\\n    print(max_days)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "10\n4 10 4 4 5 10 10 4 10 10\n",
        "output": "9",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1163/B1"
    },
    {
        "id": 1928,
        "task_id": 1973,
        "test_case_id": 8,
        "question": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $i$-th day has a ribbon with color $u_i$. Shiro wants to know the largest number $x$, such that if we consider the streak of the first $x$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $x - 1$ will have the same number of occurrences.\n\nFor example, consider the following sequence of $u_i$: $[2, 2, 1, 1, 5, 4, 4, 5]$. Then $x = 7$ makes a streak, since if we remove the leftmost $u_i = 5$, each ribbon color will appear exactly twice in the prefix of $x - 1$ days. Note that $x = 8$ doesn't form a streak, since you must remove exactly one day. \n\nSince Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^5$) — the total number of days.\n\nThe second line contains $n$ integers $u_1, u_2, \\ldots, u_n$ ($1 \\leq u_i \\leq 10$) — the colors of the ribbons the cats wear. \n\n\n-----Output-----\n\nPrint a single integer $x$ — the largest possible streak of days.\n\n\n-----Examples-----\nInput\n13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n\nOutput\n13\nInput\n5\n10 2 5 4 1\n\nOutput\n5\nInput\n1\n10\n\nOutput\n1\nInput\n7\n3 2 1 1 4 5 1\n\nOutput\n6\nInput\n6\n1 1 1 2 2 2\n\nOutput\n5\n\n\n-----Note-----\n\nIn the first example, we can choose the longest streak of $13$ days, since upon removing the last day out of the streak, all of the remaining colors $1$, $2$, $3$, and $4$ will have the same number of occurrences of $3$. Note that the streak can also be $10$ days (by removing the $10$-th day from this streak) but we are interested in the longest streak.\n\nIn the fourth example, if we take the streak of the first $6$ days, we can remove the third day from this streak then all of the remaining colors $1$, $2$, $3$, $4$ and $5$ will occur exactly once.",
        "solutions": "[\"n = int(input())\\nu = [int(u) for u in input().split()]\\n\\nNMAX = 100005\\n\\nsuma = [0 for _ in range(NMAX)]\\ntotal = [0 for _ in range(NMAX)]\\n\\ndiferentes = 0\\nsol = 0\\nmaximo = 1\\n\\nfor i, v in enumerate(u):\\n\\tif total[v] == 0:\\n\\t\\tdiferentes += 1\\n\\telse:\\n\\t\\tsuma[total[v]] -= 1\\n\\ttotal[v] += 1\\n\\tsuma[total[v]] += 1\\n\\n\\tmaximo = max(maximo, total[v])\\n\\n\\t#print(i, v, \\\":\\\", diferentes)\\n\\t#print(suma)\\n\\t#print(total)\\n\\t#print(maximo, \\\":\\\", suma[maximo], suma[maximo+1], diferentes-1)\\n\\t#print(maximo, \\\":\\\", suma[maximo-1], suma[maximo], diferentes-1)\\n\\n\\tif diferentes <= 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo-1] == diferentes-1 and suma[maximo] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo] == diferentes-1 and suma[1] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[1] == diferentes:\\n\\t\\tsol = i\\n\\t\\n\\t#print(\\\"SOL\\\", sol)\\n\\nprint(sol+1)\\n\", \"n = int(input())\\na = [int(x) - 1 for x in input().split()]\\ncounts = [0] * 10\\nfor ind, i in enumerate(a):\\n    counts[i] += 1\\n    k = sorted([i for i in counts if i])\\n    if len(k) == 1 or (k[0] == k[-2] and k[-1] - k[-2] == 1) or (k[0] == 1 and k[1] == k[-1]):\\n        best = ind\\nprint(best + 1)\", \"def main():\\n    from sys import stdin, stdout\\n\\n    def read():\\n        return stdin.readline().rstrip('\\\\n')\\n\\n    def read_array(sep=None, maxsplit=-1):\\n        return read().split(sep, maxsplit)\\n\\n    def read_int():\\n        return int(read())\\n\\n    def read_int_array(sep=None, maxsplit=-1):\\n        return [int(a) for a in read_array(sep, maxsplit)]\\n\\n    def write(*args, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in args) + end)\\n\\n    def write_array(array, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in array) + end)\\n\\n    n = read_int()\\n    nums = read_int_array()\\n    counts = {}\\n    import collections\\n    inv_counts = collections.defaultdict(int)\\n    out = 0\\n    for i, x in enumerate(nums):\\n        c = inv_counts[x]\\n        if c:\\n            counts[c].remove(x)\\n            if not counts[c]:\\n                counts.pop(c)\\n        c += 1\\n        inv_counts[x] = c\\n        counts.setdefault(c, set()).add(x)\\n        if len(counts) == 2 and any(len(s) == 1 and ((k-1 in counts) or k == 1) for k, s in list(counts.items())):\\n            out = i + 1\\n        elif len(counts) == 1:\\n            k = next(iter(list(counts.keys())))\\n            if k == 1 or len(counts[k]) == 1:\\n                out = i + 1\\n    write(out)\\n\\nmain()\\n\", \"NUMS = [0 for i in range(10)]\\n\\ndef check(nums):\\n    maxi = max(nums)\\n    category = nums.count(maxi)\\n    if category == 1:\\n        oneof = 0\\n        for n in nums:\\n            if n == maxi:\\n                continue\\n            if n == 0:\\n                continue\\n            if oneof != 0 and (n != oneof or n != maxi - 1):\\n                return False\\n            oneof = n\\n    \\n        return True\\n    \\n    else:\\n        if maxi != 1:\\n            if nums.count(1) != 1:\\n                return False\\n            if nums.count(0) != len(nums) - category - 1:\\n                return False\\n            return True\\n        else:\\n            return True\\n\\nn = int(input())\\ncolors = list(map(int, input().split()))\\nres = 0\\nfor i in range(n):\\n    NUMS[colors[i] - 1] += 1\\n    if check(NUMS):\\n        res = i + 1\\n\\nprint(res)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\n\\nC = [0] * 101010\\nma = 0\\nmacnt = 0\\nposcnt = 0\\ncntofone = 0\\nans = 0\\nfor i in range(N):\\n    C[A[i]] += 1\\n    if C[A[i]] > ma:\\n        ma = C[A[i]]\\n        macnt = 1\\n    elif ma == C[A[i]]:\\n        macnt += 1\\n    if C[A[i]] == 1:\\n        poscnt += 1\\n        cntofone += 1\\n    elif C[A[i]] == 2:\\n        cntofone -= 1\\n    if i <= 1 or (cntofone >= 1 and ((poscnt - 1) * ma == i)) or (macnt == 1 and (poscnt * (ma - 1) == i)):\\n        ans = i + 1\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nm =[0 for i in range(11)]\\nwyn = 0\\nfor i in range(n):\\n\\tm[l[i]] += 1\\n\\tb = [m[i] for i in range(11) if m[i] != 0]\\n\\tb = sorted(b)\\n\\t#print(b)\\n\\tif len(b) == 1:\\n\\t\\twyn = i + 1\\n\\tif len(b) > 1:\\n\\t\\tif b[0] == 1 and sum(b) == 1 + len(b)*b[1]-b[1]:\\n\\t\\t\\twyn = i + 1\\n\\t\\telse:\\n\\t\\t\\tif (b[0] == b[-2] and b[-1] == b[0] + 1):\\n\\t\\t\\t\\twyn = i + 1\\nprint(wyn)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = [0] * 11\\nma = 1\\nfor i in range(n):\\n    c[a[i]] += 1\\n    for k in range(1, 11):\\n        if c[k] > 0:\\n            c[k] -= 1\\n            s = {}\\n            for j in range(1, 11):\\n                if c[j] > 0:\\n                    if c[j] not in s:\\n                        s[c[j]] = 1\\n                    else:\\n                        s[c[j]] += 1\\n            c[k] += 1\\n            if len(s) == 1:\\n                ma = max(ma, i + 1)\\n                break\\n\\nprint(ma)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\nd = [0] * 10\\nmax_ = 1\\nfor i in range(n):\\n    d[arr[i] - 1] += 1\\n    lol = sorted([x for x in d if x > 0])\\n    kek = True\\n    for j in range(len(lol) - 2):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and len(lol) == 1:\\n        max_ = max(max_, i + 1)\\n        continue\\n    elif kek and lol[-1] - 1 == lol[-2]:\\n        max_ = max(max_, i + 1)\\n        continue\\n\\n    kek = True\\n    for j in range(1, len(lol) - 1):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and lol[0] - 1 == 0:\\n        max_ = max(max_, i + 1)\\nprint(max_)\\n\", \"ii = lambda:int(input())\\nkk=lambda:list(map(int,input().split()))\\nk2=lambda:[int(x)-1 for x in input().split()]\\nll=lambda:list(kk())\\nn=ii()\\nd = [0]*10\\nmaxi = 2\\nfor j,v in enumerate(k2()):\\n\\td[v]+=1\\n\\tvs = {}\\n\\tfor i in range(10):\\n\\t\\tif d[i] ==0: continue\\n\\t\\tif d[i] not in vs: vs[d[i]] = 0\\n\\t\\tvs[d[i]]+=1\\n\\tif len(vs) >2: continue\\n\\tif len(vs) == 2:\\n\\t\\tval = max(list(vs.keys()))\\n\\t\\tif (1 in vs and vs[1]==1) or(val-1 in vs and vs[val]==1): \\n\\t\\t\\tmaxi = j\\n\\telif len(vs) == 1 and (1 in vs or d.count(0) == 9):\\n\\t\\tmaxi = j\\n\\nprint(max(maxi+1, min(2, n)))\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = [0]*11\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"from random import random\\nfrom collections import defaultdict\\nimport math\\nimport re\\nimport fractions\\n\\nN = int(input())\\n# N, M = map(int, input().split(\\\" \\\"))\\nA = list(map(int, input().split(\\\" \\\")))\\narr = [0]*(10**5+1)\\nexisting = set()\\nfor a in A:\\n  arr[a] += 1\\n  existing.add(a)\\n\\naccumulate = defaultdict(int)\\nfor count in arr:\\n  accumulate[count] += 1\\n\\nfor i in range(len(A)-1, -1, -1):\\n  a = A[i]\\n  length = i+1\\n\\n  if len(existing) in [0, 1, length]:\\n    break\\n\\n  expected_1 = (i+1-1)//(len(existing)-1)\\n  if accumulate[expected_1] * expected_1 + 1 == length and accumulate[1] == 1:\\n    break\\n\\n  expected_k_1 = (i+1-1)//len(existing)\\n  if accumulate[expected_k_1] * expected_k_1 + expected_k_1 + 1 == length and accumulate[expected_k_1+1] == 1:\\n    break\\n\\n  accumulate[arr[a]] -= 1\\n  arr[a] -= 1\\n  if arr[a] == 0:\\n    existing.discard(a)\\n  accumulate[arr[a]] += 1\\n  # print(accumulate)\\nprint(length)\\n\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\n\\nd = {}\\nfor i in range(n):\\n\\td[a[i]] = 0\\n\\n\\n# numOdd = 0\\n# for i in range(n):\\n# \\td[a[i]] += 1\\n\\n# \\tif(d[a[i]] % 2 != 0):\\n# \\t\\tnumOdd += 1\\n\\n# \\telse:\\n# \\t\\tnumOdd -= 1\\n\\n# \\tif(numOdd == 1):\\n# \\t\\tx = i+1\\n\\n# print(x)\\n\\nx = 1\\nfor i in range(1,n):\\n\\tif(a[i] == a[i-1]):\\n\\t\\t# print(\\\"yo\\\")\\n\\t\\tx = i+1\\n\\telse:\\n\\t\\tbreak\\n\\nfor i in range(n):\\n\\td[a[i]] += 1\\n\\n\\tl = list(d.values())\\n\\tl = list(set(l))\\n\\tll = list(d.values())\\n\\tl.sort()\\n\\t# print(l)\\n\\tif(l[0] == 0):\\n\\t\\tl.pop(l[0])\\n\\t\\n\\tif(len(l) == 2):\\n\\t\\tif(abs(l[0] - l[1]) == 1 and ll.count(l[1]) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\t\\telif(l[0] == 1 and ll.count(1) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\tif(len(l) == 1 and l[0] == 1):\\n\\t\\tx = max(x,i+1)\\n\\nprint(x)\", \"n = int(input())\\n\\na = list(map(int,input().split()))\\nif(n == 1 or n == 2):\\n    print(n)\\n    return\\nnotpar = 0\\nocc = [0 for i in range(10**5 + 1)]\\nbase = 1\\ngotone = False\\nleader = -1\\nleadby = 0\\nbest = 0\\nocc[a[0]] += 1\\ncnt = 1\\nat1 = 1\\n\\n\\n\\nfor i in range(1, n):\\n    occ[a[i]] +=1\\n    \\n    if(occ[a[i]] == 1):\\n        notpar += 1\\n        at1 += 1\\n        cnt += 1\\n    elif(occ[a[i]] == 2):\\n        at1 -= 1\\n    if(occ[a[i]] == base):\\n        notpar -= 1\\n    elif(occ[a[i]] > base):\\n        if(gotone):\\n            if(a[i] != leader):\\n                base += 1\\n                notpar = cnt - 2\\n                leadby -= 1\\n                if(leadby == 0):\\n                    gotone = False\\n                    leader = -1\\n            else:\\n                leadby += 1\\n        else:\\n            gotone = True\\n            leader = a[i]\\n            leadby = 1\\n    if(notpar == 0 and (leadby == 1 or (leadby == 0 and base == 1)) or (notpar == 1 and leadby == 0 and at1 > 0)):\\n        best = i + 1\\n    if(cnt == 1):\\n        best = i + 1\\n    #print(i, base, leader, leadby, gotone, notpar, cnt)\\nprint(best)\\n                    \\n                    \\n\", \"\\n# -*- coding: utf-8 -*-\\n\\ndef __starting_point():\\n    n  = int(input())\\n    a = list(map(int, input().split()))\\n    b = [0 for i in range(10)]\\n    pos = 1\\n    for i in range(n):\\n        b[a[i]-1]+=1\\n        c = []\\n        for j in range(10):\\n            if (b[j]>0):\\n                c.append(b[j])\\n        c.sort()\\n        if (c[len(c)-1]==i+1) or (c[len(c)-1]==c[len(c)-2]+1 and c[len(c)-2]==c[0])\\\\\\n            or (c[len(c)-1]==c[1] and c[0]==1):\\n            pos = i+1\\n    print(pos)\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\ndic = {a[0]:1}\\n#board= ['*']*11\\nsu = 1\\nkq = 1\\nfor i in range(1, n):\\n    if dic.get(a[i], 0)==0:\\n        dic.update({a[i]:1})\\n    else:\\n        dic[a[i]]+=1\\n    su+=1\\n    cach = len(list(dic.keys()))\\n    c = 0\\n    c_=0\\n    for z in list(dic.keys()):\\n        if cach==1:\\n            continue\\n        if cach == su:\\n            kq = su\\n            continue\\n        if dic[z]== (su-1)/(cach-1):\\n            c+=1\\n        if dic[z]== (su-1)/cach:\\n            c_+=1\\n    if c==cach-1 or c_==cach-1:\\n        kq = su\\n\\nprint(kq)       \\n    \\n\", \"import sys\\n\\nn = int(input())\\nnums = list(map(int, input().split()))\\neleCount = {}\\npossibleMax = 1\\nfor i in range(n):\\n    if nums[i] in list(eleCount.keys()):\\n        eleCount[nums[i]] += 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\n    else:\\n        eleCount[nums[i]] = 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\nprint(possibleMax)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nb=[]\\nfor i in range(11):\\n    b.append(0)\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"def check():\\n    mn = float('inf')\\n    mx = 0\\n    k = 0\\n    for i in mas:\\n        if i != 0:\\n            k += 1\\n            mx = max(mx, i)\\n            mn = min(mn, i)\\n    if (mx - mn <= 1 and mas.count(mx) == 1) or (mn == 1 and k == 1 + mas.count(mx)) or (mn == mx == 1):\\n        return True\\n    return False\\nn = int(input())\\nl = list(map(int, input().split()))\\nmas = [0] * 10\\nans = 0\\nfor i in range(n):\\n    mas[l[i] - 1] += 1\\n    if check():\\n        #print(i)\\n        #print('check')\\n        ans = i\\nprint(ans + 1)\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/5/9 23:15\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B1. Cat Party (Easy Edition).py\\n\\nfrom collections import Counter\\n\\n\\ndef check(counter, curr_len, curr_color, curr_one):\\n    if curr_len == 1 or curr_color == 1 or curr_one == curr_len:\\n        return True\\n\\n    # if curr_len == 13:\\n    #     print(counter)\\n    if curr_one == 1:\\n        curr_color -= 1\\n    if (curr_len - 1) % curr_color != 0:\\n        return False\\n    correct_num = (curr_len - 1) // curr_color\\n    # if curr_len == 13:\\n    #     print(correct_num)\\n\\n    false_count, false_num = 0, 0\\n    for i in range(1, 11):\\n        if counter[i] != correct_num and counter[i] != 0:\\n            false_count += 1\\n            false_num = counter[i]\\n    # if curr_len == 13:\\n    #     print(false_count)\\n\\n    return false_count == 1 and (false_num - 1 == correct_num or false_count - 1 == 0)\\n\\n\\ndef main():\\n    n = int(input())\\n    u = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    max_days, curr_color, curr_one = 0, 0, 0\\n    for i in range(n):\\n        if counter[u[i]] == 0:\\n            curr_color += 1\\n            curr_one += 1\\n\\n        if counter[u[i]] == 1:\\n            curr_one -= 1\\n\\n        counter[u[i]] += 1\\n        if check(counter, i + 1, curr_color, curr_one):\\n            max_days = i + 1\\n    print(max_days)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "10\n8 8 8 8 8 8 8 8 8 8\n",
        "output": "10",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1163/B1"
    },
    {
        "id": 1929,
        "task_id": 1973,
        "test_case_id": 9,
        "question": "This problem is same as the next one, but has smaller constraints.\n\nShiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend at a time.\n\nFor each of the $n$ days since the day Shiro moved to the new house, there will be exactly one cat coming to the Shiro's house. The cat coming in the $i$-th day has a ribbon with color $u_i$. Shiro wants to know the largest number $x$, such that if we consider the streak of the first $x$ days, it is possible to remove exactly one day from this streak so that every ribbon color that has appeared among the remaining $x - 1$ will have the same number of occurrences.\n\nFor example, consider the following sequence of $u_i$: $[2, 2, 1, 1, 5, 4, 4, 5]$. Then $x = 7$ makes a streak, since if we remove the leftmost $u_i = 5$, each ribbon color will appear exactly twice in the prefix of $x - 1$ days. Note that $x = 8$ doesn't form a streak, since you must remove exactly one day. \n\nSince Shiro is just a cat, she is not very good at counting and needs your help finding the longest streak.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^5$) — the total number of days.\n\nThe second line contains $n$ integers $u_1, u_2, \\ldots, u_n$ ($1 \\leq u_i \\leq 10$) — the colors of the ribbons the cats wear. \n\n\n-----Output-----\n\nPrint a single integer $x$ — the largest possible streak of days.\n\n\n-----Examples-----\nInput\n13\n1 1 1 2 2 2 3 3 3 4 4 4 5\n\nOutput\n13\nInput\n5\n10 2 5 4 1\n\nOutput\n5\nInput\n1\n10\n\nOutput\n1\nInput\n7\n3 2 1 1 4 5 1\n\nOutput\n6\nInput\n6\n1 1 1 2 2 2\n\nOutput\n5\n\n\n-----Note-----\n\nIn the first example, we can choose the longest streak of $13$ days, since upon removing the last day out of the streak, all of the remaining colors $1$, $2$, $3$, and $4$ will have the same number of occurrences of $3$. Note that the streak can also be $10$ days (by removing the $10$-th day from this streak) but we are interested in the longest streak.\n\nIn the fourth example, if we take the streak of the first $6$ days, we can remove the third day from this streak then all of the remaining colors $1$, $2$, $3$, $4$ and $5$ will occur exactly once.",
        "solutions": "[\"n = int(input())\\nu = [int(u) for u in input().split()]\\n\\nNMAX = 100005\\n\\nsuma = [0 for _ in range(NMAX)]\\ntotal = [0 for _ in range(NMAX)]\\n\\ndiferentes = 0\\nsol = 0\\nmaximo = 1\\n\\nfor i, v in enumerate(u):\\n\\tif total[v] == 0:\\n\\t\\tdiferentes += 1\\n\\telse:\\n\\t\\tsuma[total[v]] -= 1\\n\\ttotal[v] += 1\\n\\tsuma[total[v]] += 1\\n\\n\\tmaximo = max(maximo, total[v])\\n\\n\\t#print(i, v, \\\":\\\", diferentes)\\n\\t#print(suma)\\n\\t#print(total)\\n\\t#print(maximo, \\\":\\\", suma[maximo], suma[maximo+1], diferentes-1)\\n\\t#print(maximo, \\\":\\\", suma[maximo-1], suma[maximo], diferentes-1)\\n\\n\\tif diferentes <= 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo-1] == diferentes-1 and suma[maximo] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[maximo] == diferentes-1 and suma[1] == 1:\\n\\t\\tsol = i\\n\\n\\tif suma[1] == diferentes:\\n\\t\\tsol = i\\n\\t\\n\\t#print(\\\"SOL\\\", sol)\\n\\nprint(sol+1)\\n\", \"n = int(input())\\na = [int(x) - 1 for x in input().split()]\\ncounts = [0] * 10\\nfor ind, i in enumerate(a):\\n    counts[i] += 1\\n    k = sorted([i for i in counts if i])\\n    if len(k) == 1 or (k[0] == k[-2] and k[-1] - k[-2] == 1) or (k[0] == 1 and k[1] == k[-1]):\\n        best = ind\\nprint(best + 1)\", \"def main():\\n    from sys import stdin, stdout\\n\\n    def read():\\n        return stdin.readline().rstrip('\\\\n')\\n\\n    def read_array(sep=None, maxsplit=-1):\\n        return read().split(sep, maxsplit)\\n\\n    def read_int():\\n        return int(read())\\n\\n    def read_int_array(sep=None, maxsplit=-1):\\n        return [int(a) for a in read_array(sep, maxsplit)]\\n\\n    def write(*args, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in args) + end)\\n\\n    def write_array(array, **kwargs):\\n        sep = kwargs.get('sep', ' ')\\n        end = kwargs.get('end', '\\\\n')\\n        stdout.write(sep.join(str(a) for a in array) + end)\\n\\n    n = read_int()\\n    nums = read_int_array()\\n    counts = {}\\n    import collections\\n    inv_counts = collections.defaultdict(int)\\n    out = 0\\n    for i, x in enumerate(nums):\\n        c = inv_counts[x]\\n        if c:\\n            counts[c].remove(x)\\n            if not counts[c]:\\n                counts.pop(c)\\n        c += 1\\n        inv_counts[x] = c\\n        counts.setdefault(c, set()).add(x)\\n        if len(counts) == 2 and any(len(s) == 1 and ((k-1 in counts) or k == 1) for k, s in list(counts.items())):\\n            out = i + 1\\n        elif len(counts) == 1:\\n            k = next(iter(list(counts.keys())))\\n            if k == 1 or len(counts[k]) == 1:\\n                out = i + 1\\n    write(out)\\n\\nmain()\\n\", \"NUMS = [0 for i in range(10)]\\n\\ndef check(nums):\\n    maxi = max(nums)\\n    category = nums.count(maxi)\\n    if category == 1:\\n        oneof = 0\\n        for n in nums:\\n            if n == maxi:\\n                continue\\n            if n == 0:\\n                continue\\n            if oneof != 0 and (n != oneof or n != maxi - 1):\\n                return False\\n            oneof = n\\n    \\n        return True\\n    \\n    else:\\n        if maxi != 1:\\n            if nums.count(1) != 1:\\n                return False\\n            if nums.count(0) != len(nums) - category - 1:\\n                return False\\n            return True\\n        else:\\n            return True\\n\\nn = int(input())\\ncolors = list(map(int, input().split()))\\nres = 0\\nfor i in range(n):\\n    NUMS[colors[i] - 1] += 1\\n    if check(NUMS):\\n        res = i + 1\\n\\nprint(res)\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\n\\nC = [0] * 101010\\nma = 0\\nmacnt = 0\\nposcnt = 0\\ncntofone = 0\\nans = 0\\nfor i in range(N):\\n    C[A[i]] += 1\\n    if C[A[i]] > ma:\\n        ma = C[A[i]]\\n        macnt = 1\\n    elif ma == C[A[i]]:\\n        macnt += 1\\n    if C[A[i]] == 1:\\n        poscnt += 1\\n        cntofone += 1\\n    elif C[A[i]] == 2:\\n        cntofone -= 1\\n    if i <= 1 or (cntofone >= 1 and ((poscnt - 1) * ma == i)) or (macnt == 1 and (poscnt * (ma - 1) == i)):\\n        ans = i + 1\\n\\nprint(ans)\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nm =[0 for i in range(11)]\\nwyn = 0\\nfor i in range(n):\\n\\tm[l[i]] += 1\\n\\tb = [m[i] for i in range(11) if m[i] != 0]\\n\\tb = sorted(b)\\n\\t#print(b)\\n\\tif len(b) == 1:\\n\\t\\twyn = i + 1\\n\\tif len(b) > 1:\\n\\t\\tif b[0] == 1 and sum(b) == 1 + len(b)*b[1]-b[1]:\\n\\t\\t\\twyn = i + 1\\n\\t\\telse:\\n\\t\\t\\tif (b[0] == b[-2] and b[-1] == b[0] + 1):\\n\\t\\t\\t\\twyn = i + 1\\nprint(wyn)\", \"n = int(input())\\na = list(map(int, input().split()))\\nc = [0] * 11\\nma = 1\\nfor i in range(n):\\n    c[a[i]] += 1\\n    for k in range(1, 11):\\n        if c[k] > 0:\\n            c[k] -= 1\\n            s = {}\\n            for j in range(1, 11):\\n                if c[j] > 0:\\n                    if c[j] not in s:\\n                        s[c[j]] = 1\\n                    else:\\n                        s[c[j]] += 1\\n            c[k] += 1\\n            if len(s) == 1:\\n                ma = max(ma, i + 1)\\n                break\\n\\nprint(ma)\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\nd = [0] * 10\\nmax_ = 1\\nfor i in range(n):\\n    d[arr[i] - 1] += 1\\n    lol = sorted([x for x in d if x > 0])\\n    kek = True\\n    for j in range(len(lol) - 2):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and len(lol) == 1:\\n        max_ = max(max_, i + 1)\\n        continue\\n    elif kek and lol[-1] - 1 == lol[-2]:\\n        max_ = max(max_, i + 1)\\n        continue\\n\\n    kek = True\\n    for j in range(1, len(lol) - 1):\\n        if lol[j] != lol[j + 1]:\\n            kek = False\\n            break\\n    if kek and lol[0] - 1 == 0:\\n        max_ = max(max_, i + 1)\\nprint(max_)\\n\", \"ii = lambda:int(input())\\nkk=lambda:list(map(int,input().split()))\\nk2=lambda:[int(x)-1 for x in input().split()]\\nll=lambda:list(kk())\\nn=ii()\\nd = [0]*10\\nmaxi = 2\\nfor j,v in enumerate(k2()):\\n\\td[v]+=1\\n\\tvs = {}\\n\\tfor i in range(10):\\n\\t\\tif d[i] ==0: continue\\n\\t\\tif d[i] not in vs: vs[d[i]] = 0\\n\\t\\tvs[d[i]]+=1\\n\\tif len(vs) >2: continue\\n\\tif len(vs) == 2:\\n\\t\\tval = max(list(vs.keys()))\\n\\t\\tif (1 in vs and vs[1]==1) or(val-1 in vs and vs[val]==1): \\n\\t\\t\\tmaxi = j\\n\\telif len(vs) == 1 and (1 in vs or d.count(0) == 9):\\n\\t\\tmaxi = j\\n\\nprint(max(maxi+1, min(2, n)))\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = [0]*11\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"from random import random\\nfrom collections import defaultdict\\nimport math\\nimport re\\nimport fractions\\n\\nN = int(input())\\n# N, M = map(int, input().split(\\\" \\\"))\\nA = list(map(int, input().split(\\\" \\\")))\\narr = [0]*(10**5+1)\\nexisting = set()\\nfor a in A:\\n  arr[a] += 1\\n  existing.add(a)\\n\\naccumulate = defaultdict(int)\\nfor count in arr:\\n  accumulate[count] += 1\\n\\nfor i in range(len(A)-1, -1, -1):\\n  a = A[i]\\n  length = i+1\\n\\n  if len(existing) in [0, 1, length]:\\n    break\\n\\n  expected_1 = (i+1-1)//(len(existing)-1)\\n  if accumulate[expected_1] * expected_1 + 1 == length and accumulate[1] == 1:\\n    break\\n\\n  expected_k_1 = (i+1-1)//len(existing)\\n  if accumulate[expected_k_1] * expected_k_1 + expected_k_1 + 1 == length and accumulate[expected_k_1+1] == 1:\\n    break\\n\\n  accumulate[arr[a]] -= 1\\n  arr[a] -= 1\\n  if arr[a] == 0:\\n    existing.discard(a)\\n  accumulate[arr[a]] += 1\\n  # print(accumulate)\\nprint(length)\\n\\n\", \"n = int(input())\\na = list(map(int,input().split()))\\n\\nd = {}\\nfor i in range(n):\\n\\td[a[i]] = 0\\n\\n\\n# numOdd = 0\\n# for i in range(n):\\n# \\td[a[i]] += 1\\n\\n# \\tif(d[a[i]] % 2 != 0):\\n# \\t\\tnumOdd += 1\\n\\n# \\telse:\\n# \\t\\tnumOdd -= 1\\n\\n# \\tif(numOdd == 1):\\n# \\t\\tx = i+1\\n\\n# print(x)\\n\\nx = 1\\nfor i in range(1,n):\\n\\tif(a[i] == a[i-1]):\\n\\t\\t# print(\\\"yo\\\")\\n\\t\\tx = i+1\\n\\telse:\\n\\t\\tbreak\\n\\nfor i in range(n):\\n\\td[a[i]] += 1\\n\\n\\tl = list(d.values())\\n\\tl = list(set(l))\\n\\tll = list(d.values())\\n\\tl.sort()\\n\\t# print(l)\\n\\tif(l[0] == 0):\\n\\t\\tl.pop(l[0])\\n\\t\\n\\tif(len(l) == 2):\\n\\t\\tif(abs(l[0] - l[1]) == 1 and ll.count(l[1]) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\t\\telif(l[0] == 1 and ll.count(1) == 1):\\n\\t\\t\\tx = max(x,i+1)\\n\\tif(len(l) == 1 and l[0] == 1):\\n\\t\\tx = max(x,i+1)\\n\\nprint(x)\", \"n = int(input())\\n\\na = list(map(int,input().split()))\\nif(n == 1 or n == 2):\\n    print(n)\\n    return\\nnotpar = 0\\nocc = [0 for i in range(10**5 + 1)]\\nbase = 1\\ngotone = False\\nleader = -1\\nleadby = 0\\nbest = 0\\nocc[a[0]] += 1\\ncnt = 1\\nat1 = 1\\n\\n\\n\\nfor i in range(1, n):\\n    occ[a[i]] +=1\\n    \\n    if(occ[a[i]] == 1):\\n        notpar += 1\\n        at1 += 1\\n        cnt += 1\\n    elif(occ[a[i]] == 2):\\n        at1 -= 1\\n    if(occ[a[i]] == base):\\n        notpar -= 1\\n    elif(occ[a[i]] > base):\\n        if(gotone):\\n            if(a[i] != leader):\\n                base += 1\\n                notpar = cnt - 2\\n                leadby -= 1\\n                if(leadby == 0):\\n                    gotone = False\\n                    leader = -1\\n            else:\\n                leadby += 1\\n        else:\\n            gotone = True\\n            leader = a[i]\\n            leadby = 1\\n    if(notpar == 0 and (leadby == 1 or (leadby == 0 and base == 1)) or (notpar == 1 and leadby == 0 and at1 > 0)):\\n        best = i + 1\\n    if(cnt == 1):\\n        best = i + 1\\n    #print(i, base, leader, leadby, gotone, notpar, cnt)\\nprint(best)\\n                    \\n                    \\n\", \"\\n# -*- coding: utf-8 -*-\\n\\ndef __starting_point():\\n    n  = int(input())\\n    a = list(map(int, input().split()))\\n    b = [0 for i in range(10)]\\n    pos = 1\\n    for i in range(n):\\n        b[a[i]-1]+=1\\n        c = []\\n        for j in range(10):\\n            if (b[j]>0):\\n                c.append(b[j])\\n        c.sort()\\n        if (c[len(c)-1]==i+1) or (c[len(c)-1]==c[len(c)-2]+1 and c[len(c)-2]==c[0])\\\\\\n            or (c[len(c)-1]==c[1] and c[0]==1):\\n            pos = i+1\\n    print(pos)\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\ndic = {a[0]:1}\\n#board= ['*']*11\\nsu = 1\\nkq = 1\\nfor i in range(1, n):\\n    if dic.get(a[i], 0)==0:\\n        dic.update({a[i]:1})\\n    else:\\n        dic[a[i]]+=1\\n    su+=1\\n    cach = len(list(dic.keys()))\\n    c = 0\\n    c_=0\\n    for z in list(dic.keys()):\\n        if cach==1:\\n            continue\\n        if cach == su:\\n            kq = su\\n            continue\\n        if dic[z]== (su-1)/(cach-1):\\n            c+=1\\n        if dic[z]== (su-1)/cach:\\n            c_+=1\\n    if c==cach-1 or c_==cach-1:\\n        kq = su\\n\\nprint(kq)       \\n    \\n\", \"import sys\\n\\nn = int(input())\\nnums = list(map(int, input().split()))\\neleCount = {}\\npossibleMax = 1\\nfor i in range(n):\\n    if nums[i] in list(eleCount.keys()):\\n        eleCount[nums[i]] += 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\n    else:\\n        eleCount[nums[i]] = 1\\n        if len(list(eleCount.keys())) == 1:\\n            possibleMax = i+1\\n        else:\\n            x = list(eleCount.values())\\n            x.sort()\\n            if x[0] == 1 and x[-1] == 1:\\n                possibleMax = i + 1\\n            elif x[0] == 1 and x[1] != 1:\\n                if len(set(x[1:])) == 1:\\n                    possibleMax = i + 1\\n            else:\\n                x[-1] = x[-1] - 1\\n                if len(set(x)) == 1:\\n                    possibleMax = i + 1\\nprint(possibleMax)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nb=[]\\nfor i in range(11):\\n    b.append(0)\\nm = 0\\nb[a[0]] = 1\\nfor i in range(1,n):\\n    b[a[i]]+=1\\n    c = set(b)\\n    if len(c)==2:\\n        c = sorted(c)\\n        t = c[0] + c[1]\\n        if 1 in c:\\n            m = i\\n        elif b.count(t)==1:\\n            m = i\\n        \\n        \\n        \\n    elif len(c)==3:\\n        d = sorted(c)\\n        if d[1] == 1 and b.count(1)==1:\\n            m = i\\n        elif d[2]-d[1] == 1 and b.count(d[2])==1:\\n            m = i\\n\\n    \\nprint(m+1)\", \"def check():\\n    mn = float('inf')\\n    mx = 0\\n    k = 0\\n    for i in mas:\\n        if i != 0:\\n            k += 1\\n            mx = max(mx, i)\\n            mn = min(mn, i)\\n    if (mx - mn <= 1 and mas.count(mx) == 1) or (mn == 1 and k == 1 + mas.count(mx)) or (mn == mx == 1):\\n        return True\\n    return False\\nn = int(input())\\nl = list(map(int, input().split()))\\nmas = [0] * 10\\nans = 0\\nfor i in range(n):\\n    mas[l[i] - 1] += 1\\n    if check():\\n        #print(i)\\n        #print('check')\\n        ans = i\\nprint(ans + 1)\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/5/9 23:15\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B1. Cat Party (Easy Edition).py\\n\\nfrom collections import Counter\\n\\n\\ndef check(counter, curr_len, curr_color, curr_one):\\n    if curr_len == 1 or curr_color == 1 or curr_one == curr_len:\\n        return True\\n\\n    # if curr_len == 13:\\n    #     print(counter)\\n    if curr_one == 1:\\n        curr_color -= 1\\n    if (curr_len - 1) % curr_color != 0:\\n        return False\\n    correct_num = (curr_len - 1) // curr_color\\n    # if curr_len == 13:\\n    #     print(correct_num)\\n\\n    false_count, false_num = 0, 0\\n    for i in range(1, 11):\\n        if counter[i] != correct_num and counter[i] != 0:\\n            false_count += 1\\n            false_num = counter[i]\\n    # if curr_len == 13:\\n    #     print(false_count)\\n\\n    return false_count == 1 and (false_num - 1 == correct_num or false_count - 1 == 0)\\n\\n\\ndef main():\\n    n = int(input())\\n    u = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    max_days, curr_color, curr_one = 0, 0, 0\\n    for i in range(n):\\n        if counter[u[i]] == 0:\\n            curr_color += 1\\n            curr_one += 1\\n\\n        if counter[u[i]] == 1:\\n            curr_one -= 1\\n\\n        counter[u[i]] += 1\\n        if check(counter, i + 1, curr_color, curr_one):\\n            max_days = i + 1\\n    print(max_days)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "10\n9 2 9 10 10 10 2 5 6 6\n",
        "output": "7",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1163/B1"
    },
    {
        "id": 1930,
        "task_id": 1994,
        "test_case_id": 5,
        "question": "You have a string s = s_1s_2...s_{|}s|, where |s| is the length of string s, and s_{i} its i-th character. \n\nLet's introduce several definitions:  A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string s_{i}s_{i} + 1...s_{j}.  The prefix of string s of length l (1 ≤ l ≤ |s|) is string s[1..l].  The suffix of string s of length l (1 ≤ l ≤ |s|) is string s[|s| - l + 1..|s|]. \n\nYour task is, for any prefix of string s which matches a suffix of string s, print the number of times it occurs in string s as a substring.\n\n\n-----Input-----\n\nThe single line contains a sequence of characters s_1s_2...s_{|}s| (1 ≤ |s| ≤ 10^5) — string s. The string only consists of uppercase English letters.\n\n\n-----Output-----\n\nIn the first line, print integer k (0 ≤ k ≤ |s|) — the number of prefixes that match a suffix of string s. Next print k lines, in each line print two integers l_{i} c_{i}. Numbers l_{i} c_{i} mean that the prefix of the length l_{i} matches the suffix of length l_{i} and occurs in string s as a substring c_{i} times. Print pairs l_{i} c_{i} in the order of increasing l_{i}.\n\n\n-----Examples-----\nInput\nABACABA\n\nOutput\n3\n1 4\n3 2\n7 1\n\nInput\nAAA\n\nOutput\n3\n1 3\n2 2\n3 1",
        "solutions": "[\"s = input()\\nn = len(s)\\np = [0] * n\\nk = 0\\nfor i in range(1, n):\\n  while k != 0 and s[k] != s[i]:\\n    k = p[k - 1]\\n  if s[k] == s[i]:\\n    k += 1\\n  p[i] = k\\na = []\\nk = n\\nwhile k != 0:\\n  a += [k]\\n  k = p[k - 1]\\nc = [0] * (n + 1)\\nfor i in range(n):\\n  c[p[i]] += 1\\nfor i in range(n - 1, 1, -1):\\n  c[p[i - 1]] += c[i]\\nprint(len(a))\\nfor t in reversed(a):\\n  print(t, c[t] + 1)\", \"s = ' ' + input()\\nn = len(s)\\nr, c = [-1] * n, [1] * n\\nfor i in range(1, n):\\n    r[i] = r[i - 1] + 1\\n    while r[i] and s[r[i]]  != s[i]:\\n        r[i] = r[r[i] - 1] + 1\\nd, n = [], n - 1\\nfor i in range(n, 1, -1): c[r[i]] += c[i]\\nwhile n > 0:\\n  d.append(str(n) + ' ' + str(c[n]))\\n  n = r[n]\\nprint(len(d))\\nd.reverse()\\nprint('\\\\n'.join(d))\", \"s=input()\\nn=len(s)\\np=[0]\\nfor i in range(1,n):\\n    j=p[i-1]\\n    while j>0 and s[j]!=s[i]:\\n        j=p[j-1]\\n    if s[j]==s[i]:\\n        j+=1\\n    p.append(j)\\na = []\\nk = n\\nwhile k != 0:\\n    a += [k]\\n    k = p[k - 1]\\nc = [0] * (n + 1)\\nfor i in range(n):\\n    c[p[i]] += 1\\nfor i in range(n - 1, 1, -1):\\n    c[p[i - 1]] += c[i]\\nprint(len(a))\\nfor t in a[::-1]:\\n    print(t, c[t] + 1)\", \"def Count(s, t):\\n    res = 0\\n    for i in range(len(s) - len(t) + 1):\\n        if s[i:i+len(t)] == t:\\n            res += 1\\n    return res\\ns = input()\\nn = len(s)\\np = [0] * n\\nz = [0] * n\\nans = [0] * n \\n#Prefix \\nfor i in range(1, n):\\n    p[i] = p[i - 1]\\n    while p[i] > 0 and s[i] != s[p[i]]:\\n        p[i] = p[p[i] - 1]\\n            \\n    if s[i] == s[p[i]]:\\n        p[i] += 1\\n#Z func\\nl = r = 0\\nfor i in range(1, n):\\n    if i <= r:\\n        z[i] = min(z[i - l], r - i + 1)\\n    while i + z[i] < n and s[i + z[i]] == s[z[i]]: z[i] += 1\\n    \\n    if i + z[i] - 1 > r:\\n        l, r = i, i + z[i] - 1\\n\\n\\n#for i in range(n - 2, -1, -1):\\n#    ans[i] += ans[i + 1] + count[i + 1]\\n\\nfor i in range(n):\\n    if z[i] > 0:\\n        ans[z[i] - 1] += 1\\nfor i in range(n - 2, -1, -1):\\n    ans[i] += ans[i + 1] \\noutput = []\\nfor i in range(n):\\n    if z[n - i - 1] == i + 1:\\n        output.append((i, ans[i]))\\nprint(len(output) + 1)\\nfor i in range(len(output)):\\n    print(output[i][0] + 1, output[i][1] + 1)\\nprint(n, 1)\\n\", \"def Count(s, t):\\n    res = 0\\n    for i in range(len(s) - len(t) + 1):\\n        if s[i:i+len(t)] == t:\\n            res += 1\\n    return res\\n\\ns = input()\\nn = len(s)\\np = [0] * (n + 1)\\nz = [0] * n\\nans = [0] * (n + 1)\\n#Prefix \\nfor i in range(1, n):\\n    p[i] = p[i - 1]\\n    while p[i] > 0 and s[i] != s[p[i]]:\\n        p[i] = p[p[i] - 1]\\n            \\n    if s[i] == s[p[i]]:\\n        p[i] += 1\\n#Z func\\nl = r = 0\\nfor i in range(1, n):\\n    if i <= r:\\n        z[i] = min(z[i - l], r - i + 1)\\n    while i + z[i] < n and s[i + z[i]] == s[z[i]]: z[i] += 1\\n    \\n    if i + z[i] - 1 > r:\\n        l, r = i, i + z[i] - 1\\n\\n\\n#for i in range(n - 2, -1, -1):\\n#    ans[i] += ans[i + 1] + count[i + 1]\\n\\nfor i in range(n):\\n    ans[p[i]] += 1\\n#print(ans)\\nfor i in range(n - 1, 0, -1):\\n    ans[p[i - 1]] += ans[i]\\n   # print(i, ': ', ans) \\noutput = []\\nfor i in range(n):\\n    if z[n - i - 1] == i + 1:\\n        output.append((i, ans[i + 1]))\\nprint(len(output) + 1)\\nfor i in range(len(output)):\\n    print(output[i][0] + 1, output[i][1] + 1)\\nprint(n, 1)\\n\", \"from itertools import accumulate\\n\\ndef z_algorithm(s):\\n    n = len(s)\\n    l, d = 1, 0\\n    ans = [0] * n\\n    ans[0] = n\\n    while l < n:\\n        while l + d < n and s[d] == s[l + d]:\\n            d += 1\\n        ans[l] = d\\n        if d == 0:\\n            l += 1\\n            continue\\n        k = 1\\n        while l + k < n and k + ans[k] < d:\\n            ans[l + k] = ans[k]\\n            k += 1\\n        l += k\\n        d -= k\\n    return ans\\n\\nz = z_algorithm(input())\\nn = len(z)\\nct = [0] * (n + 1)\\nmatch = [False] * (n + 1)\\nfor i, v in enumerate(z):\\n    ct[v] += 1\\n    match[n - i] = (n - i) == v\\nfor i in range(n - 1, -1, -1):\\n    ct[i] += ct[i + 1]\\nbuf = []\\nfor i, v in enumerate(ct):\\n    if i > 0 and v > 0 and match[i]:\\n        buf.append('{} {}'.format(i, v))\\nprint(len(buf))\\nprint('\\\\n'.join(buf))\\n\", \"s = str(input())\\n\\nlps = [0]*100005\\ndp = [0]*100005\\nada = [0]*100005\\ntunda = [0]*100005\\n\\nn = len(s)\\n\\ni = 1\\nj = 0\\nlps[0] = 0\\n\\nwhile(i < n):\\n    if (s[i] == s[j]):\\n        j += 1\\n        lps[i] = j\\n        i += 1\\n    elif (j == 0):\\n        lps[i] = 0\\n        i += 1\\n    else:\\n        j = lps[j-1]\\n\\n\\nfor i in range(n-1,-1,-1):\\n    tunda[i] += 1\\n    dp[lps[i]] += tunda[i]\\n    if (lps[i]):tunda[lps[i]-1] += tunda[i]\\n\\nj = n\\n\\n\\\"\\\"\\\"\\nfor i in range(n):\\n    print(\\\"SAD\\\", i, lps[i])\\n\\\"\\\"\\\"\\n\\nvector = []\\n\\nwhile(1):\\n    vector.append((j,1+dp[j]))\\n    j = lps[j-1]\\n    if (j == 0): break\\n\\n\\nvector.reverse()\\n\\nprint(len(vector))\\nfor i in vector:\\n    print(i[0], i[1])\\n\", \"def prefixFunction(s):\\n\\tj=0\\n\\tp=[0 for x in s]\\n\\tfor i in range(1,len(s)):\\n\\t\\twhile j>0 and s[j]!=s[i]:\\n\\t\\t\\tj=p[j-1]\\n\\t\\tif (s[j]==s[i]):j+=1\\n\\t\\tp[i]=j\\n\\treturn p\\ns=input()\\np=prefixFunction(s)\\nn=len(s)\\nfreq=[0 for i in range(n)]\\n\\nfor i in range(n):\\n    freq[p[i]]+=1\\n\\nfor i in range(n-1,0,-1):\\n    freq[p[i-1]]+=freq[i]\\n\\npos =n-1\\nans=[[n,1]]\\nwhile pos>0:\\n        if p[pos]>1:\\n                ans.append([p[pos],freq[p[pos]]+1])\\n        pos=p[pos]-1\\n\\nif len(s)>1 : \\n        f= s.count(s[0])\\n        if s[0] == s[len(s)-1] : ans.append([1,f])\\nprint(len(ans))\\nfor i in sorted (ans):\\n    print(i[0],i[1])\\n\\n    \\n\", \"s=input()\\nn=len(s)\\nif n==1:\\n    print('1\\\\n1 1\\\\n')\\n    return\\np=[-1]*n\\nq=-1\\nfor i in range(1,n):\\n    while q>=0 and s[i]!=s[q+1]:\\n        q=p[q]\\n    if s[i] == s[q + 1]:\\n        q+=1\\n        p[i]=q\\n#print(p)\\nc=[1]*n\\nfor i in range(n-1,-1,-1):\\n    if p[i]>=0:\\n        c[p[i]]+=c[i]\\n#print(c)\\nans=[(n,1)]\\nq=p[n-1]\\nwhile q>=0:\\n    ans.append((q+1,c[q]))\\n    q=p[q]\\nprint(len(ans))\\nprint('\\\\n'.join([' '.join(map(str,x)) for x in reversed(ans)]))\\n\", \"dep = dict()\\n\\ndef kmp(st):\\n    tam = len(st)\\n    pi = [0]*tam\\n    for i in range(1,tam):\\n        j = pi[i-1]\\n        while j > 0 and st[j] != st[i]:\\n            j = pi[j-1]\\n        if st[j] == st[i]:\\n            pi[i] = j + 1\\n        dep[pi[i]] = pi[pi[i]-1]\\n    return pi\\n\\n\\ns = input()\\narr = kmp(s)\\npoints = [0] * len(s)\\ntoimp = list()\\nactpi = arr[-1]\\nwhile actpi != 0:\\n    toimp.append(actpi)\\n    actpi = arr[actpi-1]\\n\\ntoimp.sort()\\nfor i in range(len(arr)):\\n    points[arr[i]] += 1\\n\\nfor i in range(len(s)-1,0, -1):\\n    if i in dep:\\n        points[dep[i]] += points[i]\\n\\nprint(len(toimp)+1)\\nfor i in toimp:\\n    print(str(i) + \\\" \\\" + str(points[i]+1))\\nprint(str(len(s)) + \\\" 1\\\")\\n\", \"import heapq\\nfrom bisect import bisect_left, bisect_right, insort\\nfrom collections import Counter\\nfrom collections import OrderedDict\\nfrom collections import deque\\nfrom itertools import accumulate, product\\n\\nimport math\\n\\nR = lambda: map(int, input().split())\\ns = input()\\nl, r, z = 0, 0, [0] * len(s)\\nfor i in range(1, len(s)):\\n    if i > r - 1:\\n        l = r = i\\n        while r < len(s) and s[r] == s[r - i]:\\n            r += 1\\n        z[i] = r - l\\n    elif z[i - l] < r - i:\\n        z[i] = z[i - l]\\n    else:\\n        l = i\\n        while r < len(s) and s[r] == s[r - i]:\\n            r += 1\\n        z[i] = r - l\\nsz = sorted(z[:])\\nres = []\\nfor i in range(len(s) - 1, 0, -1):\\n    if z[i] == len(s) - i:\\n        res.append((z[i], len(sz) - bisect_left(sz, z[i])))\\nprint(len(res) + 1)\\nfor x in res:\\n    print(x[0], x[1] + 1)\\nprint(len(s), 1)\", \"\\ndef z_advanced(s):\\n    \\\"\\\"\\\"An advanced computation of Z-values of a string.\\\"\\\"\\\"\\n\\n    Z = [0] * len(s)\\n    Z[0] = len(s)\\n\\n    rt = 0\\n    lt = 0\\n\\n    for k in range(1, len(s)):\\n        if k > rt:\\n            # If k is outside the current Z-box, do naive computation.\\n            n = 0\\n            while n + k < len(s) and s[n] == s[n + k]:\\n                n += 1\\n            Z[k] = n\\n            if n > 0:\\n                lt = k\\n                rt = k + n - 1\\n        else:\\n            # If k is inside the current Z-box, consider two cases.\\n\\n            p = k - lt  # Pair index.\\n            right_part_len = rt - k + 1\\n\\n            if Z[p] < right_part_len:\\n                Z[k] = Z[p]\\n            else:\\n                i = rt + 1\\n                while i < len(s) and s[i] == s[i - k]:\\n                    i += 1\\n                Z[k] = i - k\\n\\n                lt = k\\n                rt = i - 1\\n    return Z\\n\\ndef kmptab(s):\\n    tab = [0]*len(s)\\n    i = 1\\n    j = 0\\n    while i < len(s):\\n        if s[i] == s[j]:\\n            tab[i] = j + 1\\n            i += 1\\n            j += 1\\n        else:\\n            if j != 0:\\n                j = tab[j-1]\\n            else:\\n                i += 1\\n    return tab\\n\\ndef __starting_point():\\n    s = input()\\n    tab = kmptab(s)\\n    my_set = set()\\n    i = len(s)\\n    while i != 0:\\n        my_set.add(i)\\n        i = tab[i-1]\\n    V = []\\n    dict = {}\\n    for i in my_set:\\n        V.append(i)\\n        dict[i] = 0\\n    Z = z_advanced(s)\\n\\n    v = []\\n    V.sort()\\n    my_tab = [0]*(len(s)+1)\\n    # print(Z)\\n    for i in Z:\\n        my_tab[i] += 1\\n    somme = 0\\n    # print(my_tab)\\n    for i in range(len(my_tab)-1, -1, -1):\\n\\n        my_tab[i] += somme\\n        somme = my_tab[i]\\n    # print(my_tab)\\n    for i in dict:\\n        dict[i] = my_tab[i]\\n        v.append((dict[i], i))\\n    v.sort(key=lambda tup: tup[1])\\n    print(len(v))\\n    for i in v:\\n        print(str(i[1]) + \\\" \\\" + str(i[0]))\\n\\n__starting_point()\", \"def zeta(s):\\n\\tn = len(s)\\n\\tz = [0]*n\\n\\tl,r = 0,0\\n\\tfor i in range(1,n):\\n\\t\\tif(i<=r): z[i] = min(r-i+1,z[i-l])\\n\\t\\twhile(i+z[i]<n and s[z[i]]==s[i+z[i]]):\\n\\t\\t\\tz[i]+=1\\n\\t\\tif(i+z[i]-1>r):\\n\\t\\t\\tl=i\\n\\t\\t\\tr = i+z[i]-1\\n\\treturn z\\ns = input()\\nn = len(s)\\nz = zeta(s)\\nl = [0]*n\\nfor i in z:\\n\\tl[i]+=1\\ncum = [l[-1]]\\nfor i in range(n-2,-1,-1):\\n\\tcum.append(l[i]+cum[-1])\\ncum = cum[::-1]\\nans = [(n,1)]\\nfor i in range(n-1,0,-1):\\n\\tif(i+z[i]==n):\\n\\t\\tans.append((n-i,cum[n-i]+1))\\n\\nprint(len(ans))\\nfor i in sorted(ans):\\n\\tprint(*i)\\n\\n\", \"#!/usr/bin/env python3\\n\\\"\\\"\\\"Compute z function.\\\"\\\"\\\"\\n\\n\\ndef compute_z(data):\\n    z = [0 for _ in range(len(data))]\\n    z[0] = len(data)\\n    l = 0\\n    r = 0\\n    for i in range(1, len(data)):\\n        if i <= r: # nu am explorat\\n            z[i] = min(z[i-l], r-i+1)\\n        while i + z[i] < len(data) and data[z[i]] == data[i+z[i]]:\\n            z[i] += 1\\n        if i + z[i] - 1 > r:\\n            r = i + z[i] - 1\\n            l = i\\n    return z\\n\\n\\ndata = input() # input -> eval 2.x ; input = read \\n# print(data)\\nn = len(data)\\nz = compute_z(data)\\nfeq_z = [0 for _ in range(n)]  # range(3) = 0, 1, 2\\nfor value in z:\\n    if value == 0:\\n        continue\\n    index = value - 1\\n    feq_z[index] += 1\\n\\n\\nfor i in range(n-2, -1, -1):\\n    feq_z[i] += feq_z[i+1]\\n\\n# print(z)\\n# print(feq_z)\\ncount = 0 \\nfor i in range(n-1, -1, -1):\\n    if z[i] == n - i:\\n        count += 1\\nprint(count)\\nfor i in range(n-1, -1, -1):\\n    if z[i] == n - i:\\n        print(\\\"{} {}\\\".format(z[i], feq_z[z[i]-1]))\\n\", \"def zfunc(s):\\n    n = len(s)\\n    z = [0] * n\\n    left = right = 0\\n    for i in range(1, n):\\n        if i <= right:\\n            z[i] = min(z[i - left], right - i + 1)\\n        while i + z[i] < n and s[z[i]] == s[i + z[i]]:\\n            z[i] += 1\\n        if i + z[i] - 1 > right:\\n            left, right = i, i + z[i] - 1\\n    return z\\n\\ns = input()\\nans = set()\\nz = zfunc(s)\\nz[0] = len(s)\\nres = [0] * (len(s) + 1)\\n\\nfor i in z:\\n    res[i] += 1\\n\\nfrom itertools import accumulate\\nres = [*accumulate(res[::-1])][::-1]\\n\\nfor i, j in enumerate(z[::-1]):\\n    if j > i:\\n        ans.add((j, res[j]))\\nprint(len(ans))\\nfor i in sorted([*ans]):\\n    print(*i)\", \"s=input();n=len(s)\\nif n==1:\\n    print(1)\\n    print(1,1)\\n    quit()\\npriya=[-1]*n;q=-1\\nfor i in range(1,n):\\n    while q>=0 and s[i]!=s[q+1]:\\n        q=priya[q]\\n    if s[i] == s[q + 1]:\\n        q+=1;priya[i]=q\\ncnt=[1]*n\\nfor i in range(n-1,-1,-1):\\n    if priya[i]>=0:\\n        cnt[priya[i]]+=cnt[i]\\nAns=[(n,1)];q=priya[n-1]\\nwhile q>=0:\\n    Ans.append((q+1,cnt[q]))\\n    q=priya[q]\\nAns.sort()\\nprint(len(Ans))\\nfor i in Ans:print(*i)\", \"def getLPS(s2,l):\\n  lps=[0]*l\\n  i=1\\n  j=0\\n  while i<l:\\n    if s2[i]==s2[j]:\\n       lps[i]=j+1 \\n       j+=1\\n       i+=1\\n       \\n    else:\\n      if j!=0:j=lps[j-1]\\n      else:\\n       lps[i]=0\\n       i+=1\\n  return lps\\ns=input()\\nn=len(s)\\np=getLPS(s,n)\\n#print(p)\\nans=[]\\nf=[0]*n\\nfor i in range(n):\\n  f[p[i]]+=1\\n#print(f)\\nfor i in range(n-1,0,-1):\\n  f[p[i-1]]+=f[i]\\n#print(f)\\npos=n-1\\nans=[[n,1]]\\nwhile pos>0:\\n  #print(pos)\\n  if p[pos]>1:\\n    ans.append([p[pos],f[p[pos]]+1])\\n  pos=p[pos]-1\\n \\nif len(s)>1:\\n  f=s.count(s[0])\\n  if s[0]==s[len(s)-1]:\\n    ans.append([1,f])\\nprint(len(ans))\\nfor i in sorted(ans):\\n  print(i[0],i[1])\\n\", \"'''\\nYou have a string s\\u2009=\\u2009s1s2...s|s|, where |s| is the length of string s, and si its i-th character.\\n\\nLet's introduce several definitions:\\n\\n    A substring s[i..j] (1\\u2009\\u2264\\u2009i\\u2009\\u2264\\u2009j\\u2009\\u2264\\u2009|s|) of string s is string sisi\\u2009+\\u20091...sj.\\n    The prefix of string s of length l (1\\u2009\\u2264\\u2009l\\u2009\\u2264\\u2009|s|) is string s[1..l].\\n    The suffix of string s of length l (1\\u2009\\u2264\\u2009l\\u2009\\u2264\\u2009|s|) is string s[|s|\\u2009-\\u2009l\\u2009+\\u20091..|s|]. \\n\\nYour task is, for any prefix of string s which matches a suffix of string s, print the number of times it occurs in string s as a substring.\\n'''\\n\\ndef prefix_function(s):\\n    n = len(s)\\n    pi = [0] * n\\n    for i in range(1, n):\\n        j = pi[i - 1]\\n        while j > 0 and s[j] != s[i]:\\n            j = pi[j - 1]\\n        pi[i] = j + (s[j] == s[i])\\n    return pi\\n\\ndef solve(s):\\n    n = len(s)\\n    pi = prefix_function(s)\\n    j = n\\n    prefixes = []\\n    while j:\\n        prefixes.append(j)\\n        j = pi[j - 1]\\n    print(len(prefixes))\\n    if len(prefixes) == 1:\\n        print(n, 1)\\n        return\\n    cnt = [0] * (n + 1)\\n    for i in range(n):\\n        cnt[pi[i]] += 1\\n    for i in range(n - 1, 0, -1):\\n        cnt[pi[i - 1]] += cnt[i]\\n    for i in range(n + 1):\\n        cnt[i] += 1\\n    for i in reversed(prefixes):\\n        print(i, cnt[i])\\n\\ndef main():\\n    s = input()\\n    solve(s)\\n\\nmain()\\n    \\n\\n\\n\", \"import sys\\ninput = sys.stdin.readline\\nfrom collections import deque\\n\\nS=input().strip()\\n\\n\\nLEN=len(S)\\ni=1\\nj=0\\nA=[0]*LEN\\nA[0]=LEN\\n\\nwhile i<LEN:\\n    while i+j<LEN and S[j]==S[i+j]:\\n        j+=1\\n    A[i]=j\\n    \\n    if j==0:\\n        i+=1\\n        continue\\n    \\n    k=1\\n    while i+k<LEN and k+A[k]<j:\\n        A[i+k]=A[k]\\n        k+=1\\n    i+=k\\n    j-=k\\n\\nANS=[0]*(LEN+1)\\n\\nfor a in A:\\n    ANS[a]+=1\\n\\nfor i in range(LEN-1,-1,-1):\\n    ANS[i]+=ANS[i+1]\\n\\nANS2=[]\\nfor i in range(1,LEN+1):\\n    if A[LEN-i]==i:\\n        ANS2.append((i,ANS[i]))\\n\\nprint(len(ANS2))\\nfor x,y in ANS2:\\n    print(x,y)\\n\\n\\n\\n\", \"def computeLPSArray(pat, M, lps):\\n    len = 0\\n    lps[0]\\n    i = 1\\n\\n    while i < M:\\n        if pat[i]== pat[len]:\\n            len += 1\\n            lps[i] = len\\n            i += 1\\n        else:\\n            if len != 0:\\n                len = lps[len-1]\\n            else:\\n                lps[i] = 0\\n                i += 1\\n    return lps\\n\\ndef count_subs_occ(s,m,l):\\n    occ=[0]*(m+1)\\n\\n    for i in range(m):\\n        occ[l[i]]+=1\\n\\n    for i in range(m-1,0,-1):\\n        occ[l[i-1]]+=occ[i]\\n\\n    for i in range(m+1):\\n        occ[i]+=1\\n\\n    return occ\\n\\ns=input()\\nm=len(s)\\nl=[0]*m\\n\\nx=computeLPSArray(s,m,l)\\nx=[0]+x\\ny=count_subs_occ(s,m,l)\\n\\na=x[-1]\\nif a==0:\\n    print(1)\\n    print(m,1)\\nelif a==1:\\n    print(2)\\n    print(1,y[a])\\n    print(m,1)\\nelse:\\n    u=x[-1]\\n    v=x[u]\\n    ans=[[u,y[u]]]\\n    while(1):\\n        if v==0:\\n            break\\n        u=v\\n        v=x[u]\\n        temp=[u,y[u]]\\n        ans.append(temp)\\n\\n    ans.sort()\\n    print(len(ans)+1)\\n    for i in range(len(ans)):\\n        print(ans[i][0],ans[i][1])\\n    print(m,1)\"]",
        "difficulty": "interview",
        "input": "AB\n",
        "output": "1\n2 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/432/D"
    },
    {
        "id": 1931,
        "task_id": 2057,
        "test_case_id": 1,
        "question": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number t_{i}:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. \n\nInitially, Petya was in one of the rooms at minute 0, he didn't write down number t_0.\n\nAt some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 2·10^5) — then number of notes in Petya's logbook.\n\nThe second line contains n non-negative integers t_1, t_2, ..., t_{n} (0 ≤ t_{i} < i) — notes in the logbook.\n\n\n-----Output-----\n\nIn the only line print a single integer — the minimum possible number of rooms in Paris catacombs.\n\n\n-----Examples-----\nInput\n2\n0 0\n\nOutput\n2\n\nInput\n5\n0 1 0 1 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.\n\nIn the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.",
        "solutions": "[\"n = int(input())\\n\\nmas = list(map(int, input().split()))\\n\\ndist = set([0])\\nres = 1\\nfor i, e in enumerate(mas):\\n    time = i + 1\\n    if e in dist:\\n        dist.remove(e)\\n    else:\\n        res += 1\\n    dist.add(time)\\nprint(res)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nnow_time = 1\\ncount_v = 1\\nlast_time = [0 for i in range(2 * 10**5 + 10)]\\nlast_time[0] = 1\\n\\nfor i in range(n):\\n    if last_time[a[i]] > 0:\\n        last_time[a[i]] -= 1\\n    else:\\n        count_v += 1\\n\\n    last_time[now_time] += 1\\n    now_time += 1\\n\\n\\nprint(count_v)\", \"n = int(input())\\nl = list(map(int, input().split()))\\na = [0 for i in range(200001)]\\nfor x in l:\\n  a[x] = 1\\n\\nfor i in range(1, 200001):\\n  n -= a[i]\\n  \\nprint(n)\", \"n = int(input())\\nl = list(map(int, input().split()))\\nd = {}\\ns = set()\\ns.add(0)\\nd[0] = 1\\nans = 1\\nfor i in range(n):\\n    if l[i] in s:\\n        d[i + 1] = d[l[i]]\\n        s.remove(l[i])\\n        s.add(i + 1)\\n    else:\\n        s.add(i + 1)\\n        ans += 1\\n        d[i + 1] = ans\\nprint(ans)\\n\", \"n = int(input())\\nminutesUsed = [0 for _ in range(n)]\\n\\ncount = 1\\nfor v in [int(k) for k in input().split(' ') if k]:\\n    if minutesUsed[v]:\\n        count += 1\\n    else:\\n        minutesUsed[v] = 1\\nprint(count)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nvis = [False] * n\\nans = 0\\nfor i in range(n):\\n    if a[i] == 0:\\n        ans += 1\\n        vis[0] = True\\n    elif vis[a[i]]:\\n        ans += 1\\n    else:\\n        vis[a[i]] = True\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    times = list(map(int, input().split()))\\n    mntm = set()\\n    mntm.add(0)\\n    ans = 1\\n    for t in range(n):\\n        if times[t] in mntm:\\n            mntm.discard(times[t])\\n            mntm.add(t + 1)\\n        else:\\n            ans += 1\\n            mntm.add(t + 1)\\n    print(ans)\\n\\n\\nmain()\\n\", \"import sys\\ninput()\\nk=list(map(int,input().split()))\\nl=[]\\ns=[0 for i in range(200001)]\\nt=1\\nfor i in k:\\n    if s[i]==1:\\n        s[i]=0\\n    s[t]=1\\n    t+=1\\nprint(sum(s))\\n        \\n\", \"n, data = int(input()), list(map(int, input().split()))\\ntime = [0] + [-100] * (3 * (10 ** 5))\\nrooms = [0]\\nfor i in range(1, n + 1):\\n    if(time[data[i - 1]] != -100 and rooms[time[data[i - 1]]] == data[i - 1]):\\n        rooms[time[data[i - 1]]] = i\\n        time[i] = time[data[i - 1]]\\n    else:\\n        rooms.append(i)\\n        time[i] = len(rooms) - 1\\nprint(len(rooms))\", \"import sys;\\n\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\");\\n#sys.stdout = open(\\\"output.txt\\\", \\\"w\\\");\\n\\ndef ria():\\n    return [int(x) for x in input().split()];\\n\\n\\nn = int(input());\\na = ria();\\na = [0] + a;\\ntime = [-1] * (n+1);\\ntime[0] = 0;\\ntf = 0;\\n\\n\\nfor i in range(1,n+1,1):\\n    if time[a[i]] != -1:\\n        time[i] = time[a[i]];\\n        time[a[i]] = -1;\\n    else:\\n        tf += 1;\\n        time[i] = tf;\\n\\ntf += 1;\\n\\nprint(tf);\\n    \\n    \\n\\n\\n#sys.stdout.close();\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ntime = [-1] * (n + 1)\\ntime[0] = 1\\ncount = 1\\nfor i in range(n):\\n    cur_time = i + 1\\n    if time[a[i]] != -1:\\n        time[a[i]], time[cur_time] = -1, time[a[i]]\\n    else:\\n        count += 1\\n        time[cur_time] = count\\nprint(count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndi = {0 : 0}\\nk = 1\\nq = 1\\nfor i in a:\\n    if i in di:\\n        del di[i]\\n    else:\\n        q += 1\\n    di[k] = i\\n    k += 1\\nprint(q)\", \"n = int(input())\\nlist1 = list(map(int, input().split()))\\ntime = [0] * (n + 1)\\ntime[0] = 1\\nans = 1\\nfor i in range(n):\\n    if time[list1[i]] == 1:\\n        time[i + 1] = 1\\n        time[list1[i]] = 0\\n    else:\\n        ans += 1\\n        time[i + 1] = 1\\nprint(ans)\", \"n = int(input())\\nnotes = [int(x) for x in input().split()]\\ngreatest_cave = 1\\nvisits = {0: 1}\\nfor time, curr in enumerate(notes, start=1):\\n    if curr in visits and visits[curr] != -1:\\n        visits[time] = visits[curr]\\n        visits[curr] = -1\\n    else:\\n        greatest_cave += 1\\n        visits[time] = greatest_cave\\nprint(greatest_cave)\\n\", \"N = int(input())\\ntexts = [0] * N\\ntexts = input().split()\\n\\nends=set()\\n#print(ends)\\n\\nends.add(0)\\n#print(ends)\\n\\nfor i in range(N):\\n    if int(texts[i]) in ends:\\n        ends.remove(int(texts[i]))\\n        #print('-'+texts[i],end=' ')\\n    ends.add(i+1)\\n    #print(ends)\\n\\nprint(len(ends))\\n\\n\", \"def main():\\n\\n    n = int(input())\\n\\n    a = [0]\\n    a += list(map(int, input().split()))\\n\\n    p = [0] * 200001\\n    p[1] = 0\\n    k = [-1] * 200001\\n    k[0] = 1\\n\\n    ans = 1\\n\\n    cnt = 1\\n\\n    for i in range(1, n + 1):\\n        if (i == 1):\\n            if (a[i] == 1):\\n                cnt += 1\\n                k[i] = cnt\\n                p[cnt] = i\\n                ans += 1\\n            else:\\n                k[i] = k[a[a[i]]]\\n                p[k[i]] = i\\n\\n        elif (p[k[a[i]]] != a[i]):\\n            cnt += 1\\n            k[i] = cnt\\n            p[cnt] = i\\n            ans += 1\\n        else:\\n            k[i] = k[a[i]]\\n            p[k[i]] = i\\n\\n    print(ans)\\n\\nmain()\\n        \\n\", \"n = int(input())\\ndata = list(map(int, input().split()))\\nd = [False] * (n + 4)\\nd[0] = True\\nres = 1\\nfor i in range(n):\\n    #print(d)\\n    if d[data[i]]:\\n        d[data[i]] = False\\n        d[i + 1] = True\\n    else:\\n        d[i + 1] = True\\n        res += 1\\n#print(d)\\nprint(res)\", \"n = int(input())\\nt = list(map(int, input().split()))\\ntcopy = t[::-1]\\ntbool = [False] * len(t)\\nans = 0\\nfor i in range(len(t)):\\n    if not tbool[len(t) - i - 1]:\\n        \\n        ans += 1\\n        j = len(t) - i - 1\\n        while not tbool[j]:\\n            tbool[j] = True\\n            j = t[j] - 1\\n            if j < 0:\\n                break\\n            \\n        \\n        tbool[len(t) - i - 1] = True\\nprint(ans)\\n\", \"n=int(input())\\nm=list(map(int,input().split(' ')))\\ns=set()\\ns.add(1)\\nfor i in range(1,len(m)):\\n    try:\\n        s.remove(m[i])\\n        s.add(i+1)\\n    except:\\n        s.add(i+1)\\nprint(len(s))\\n\", \"import fractions\\nimport math\\nn=int(input())\\n#a,b=map(int,input().split(' ')) \\n#n=list(map(int,input().split(' ')))\\nt=list(map(int,input().split(' ')))\\na=set(t)\\nprint(n+1-len(a))\\n\", \"i = int(input())\\nctc = [0] + list(map(int, input().split()))\\nnm = 1\\nptor = {0:1}\\nfor i in range(1, len(ctc)):\\n    if  ctc[i] in list(ptor.keys()):\\n        ptor[i] = ptor[ctc[i]]\\n        del(ptor[ctc[i]])\\n    else:\\n        nm+=1\\n        ptor[i] = nm\\nprint(nm)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmn=set()\\nmn.add(0)\\nk=1\\nfor i in range(n):\\n    if a[i] in mn:\\n        mn-={a[i]}\\n        mn.add(i+1)\\n    else:\\n        k+=1\\n        mn.add(i+1)\\nprint(k)\\n\"]",
        "difficulty": "interview",
        "input": "2\n0 0\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/886/C"
    },
    {
        "id": 1932,
        "task_id": 2057,
        "test_case_id": 2,
        "question": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number t_{i}:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. \n\nInitially, Petya was in one of the rooms at minute 0, he didn't write down number t_0.\n\nAt some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 2·10^5) — then number of notes in Petya's logbook.\n\nThe second line contains n non-negative integers t_1, t_2, ..., t_{n} (0 ≤ t_{i} < i) — notes in the logbook.\n\n\n-----Output-----\n\nIn the only line print a single integer — the minimum possible number of rooms in Paris catacombs.\n\n\n-----Examples-----\nInput\n2\n0 0\n\nOutput\n2\n\nInput\n5\n0 1 0 1 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.\n\nIn the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.",
        "solutions": "[\"n = int(input())\\n\\nmas = list(map(int, input().split()))\\n\\ndist = set([0])\\nres = 1\\nfor i, e in enumerate(mas):\\n    time = i + 1\\n    if e in dist:\\n        dist.remove(e)\\n    else:\\n        res += 1\\n    dist.add(time)\\nprint(res)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nnow_time = 1\\ncount_v = 1\\nlast_time = [0 for i in range(2 * 10**5 + 10)]\\nlast_time[0] = 1\\n\\nfor i in range(n):\\n    if last_time[a[i]] > 0:\\n        last_time[a[i]] -= 1\\n    else:\\n        count_v += 1\\n\\n    last_time[now_time] += 1\\n    now_time += 1\\n\\n\\nprint(count_v)\", \"n = int(input())\\nl = list(map(int, input().split()))\\na = [0 for i in range(200001)]\\nfor x in l:\\n  a[x] = 1\\n\\nfor i in range(1, 200001):\\n  n -= a[i]\\n  \\nprint(n)\", \"n = int(input())\\nl = list(map(int, input().split()))\\nd = {}\\ns = set()\\ns.add(0)\\nd[0] = 1\\nans = 1\\nfor i in range(n):\\n    if l[i] in s:\\n        d[i + 1] = d[l[i]]\\n        s.remove(l[i])\\n        s.add(i + 1)\\n    else:\\n        s.add(i + 1)\\n        ans += 1\\n        d[i + 1] = ans\\nprint(ans)\\n\", \"n = int(input())\\nminutesUsed = [0 for _ in range(n)]\\n\\ncount = 1\\nfor v in [int(k) for k in input().split(' ') if k]:\\n    if minutesUsed[v]:\\n        count += 1\\n    else:\\n        minutesUsed[v] = 1\\nprint(count)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nvis = [False] * n\\nans = 0\\nfor i in range(n):\\n    if a[i] == 0:\\n        ans += 1\\n        vis[0] = True\\n    elif vis[a[i]]:\\n        ans += 1\\n    else:\\n        vis[a[i]] = True\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    times = list(map(int, input().split()))\\n    mntm = set()\\n    mntm.add(0)\\n    ans = 1\\n    for t in range(n):\\n        if times[t] in mntm:\\n            mntm.discard(times[t])\\n            mntm.add(t + 1)\\n        else:\\n            ans += 1\\n            mntm.add(t + 1)\\n    print(ans)\\n\\n\\nmain()\\n\", \"import sys\\ninput()\\nk=list(map(int,input().split()))\\nl=[]\\ns=[0 for i in range(200001)]\\nt=1\\nfor i in k:\\n    if s[i]==1:\\n        s[i]=0\\n    s[t]=1\\n    t+=1\\nprint(sum(s))\\n        \\n\", \"n, data = int(input()), list(map(int, input().split()))\\ntime = [0] + [-100] * (3 * (10 ** 5))\\nrooms = [0]\\nfor i in range(1, n + 1):\\n    if(time[data[i - 1]] != -100 and rooms[time[data[i - 1]]] == data[i - 1]):\\n        rooms[time[data[i - 1]]] = i\\n        time[i] = time[data[i - 1]]\\n    else:\\n        rooms.append(i)\\n        time[i] = len(rooms) - 1\\nprint(len(rooms))\", \"import sys;\\n\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\");\\n#sys.stdout = open(\\\"output.txt\\\", \\\"w\\\");\\n\\ndef ria():\\n    return [int(x) for x in input().split()];\\n\\n\\nn = int(input());\\na = ria();\\na = [0] + a;\\ntime = [-1] * (n+1);\\ntime[0] = 0;\\ntf = 0;\\n\\n\\nfor i in range(1,n+1,1):\\n    if time[a[i]] != -1:\\n        time[i] = time[a[i]];\\n        time[a[i]] = -1;\\n    else:\\n        tf += 1;\\n        time[i] = tf;\\n\\ntf += 1;\\n\\nprint(tf);\\n    \\n    \\n\\n\\n#sys.stdout.close();\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ntime = [-1] * (n + 1)\\ntime[0] = 1\\ncount = 1\\nfor i in range(n):\\n    cur_time = i + 1\\n    if time[a[i]] != -1:\\n        time[a[i]], time[cur_time] = -1, time[a[i]]\\n    else:\\n        count += 1\\n        time[cur_time] = count\\nprint(count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndi = {0 : 0}\\nk = 1\\nq = 1\\nfor i in a:\\n    if i in di:\\n        del di[i]\\n    else:\\n        q += 1\\n    di[k] = i\\n    k += 1\\nprint(q)\", \"n = int(input())\\nlist1 = list(map(int, input().split()))\\ntime = [0] * (n + 1)\\ntime[0] = 1\\nans = 1\\nfor i in range(n):\\n    if time[list1[i]] == 1:\\n        time[i + 1] = 1\\n        time[list1[i]] = 0\\n    else:\\n        ans += 1\\n        time[i + 1] = 1\\nprint(ans)\", \"n = int(input())\\nnotes = [int(x) for x in input().split()]\\ngreatest_cave = 1\\nvisits = {0: 1}\\nfor time, curr in enumerate(notes, start=1):\\n    if curr in visits and visits[curr] != -1:\\n        visits[time] = visits[curr]\\n        visits[curr] = -1\\n    else:\\n        greatest_cave += 1\\n        visits[time] = greatest_cave\\nprint(greatest_cave)\\n\", \"N = int(input())\\ntexts = [0] * N\\ntexts = input().split()\\n\\nends=set()\\n#print(ends)\\n\\nends.add(0)\\n#print(ends)\\n\\nfor i in range(N):\\n    if int(texts[i]) in ends:\\n        ends.remove(int(texts[i]))\\n        #print('-'+texts[i],end=' ')\\n    ends.add(i+1)\\n    #print(ends)\\n\\nprint(len(ends))\\n\\n\", \"def main():\\n\\n    n = int(input())\\n\\n    a = [0]\\n    a += list(map(int, input().split()))\\n\\n    p = [0] * 200001\\n    p[1] = 0\\n    k = [-1] * 200001\\n    k[0] = 1\\n\\n    ans = 1\\n\\n    cnt = 1\\n\\n    for i in range(1, n + 1):\\n        if (i == 1):\\n            if (a[i] == 1):\\n                cnt += 1\\n                k[i] = cnt\\n                p[cnt] = i\\n                ans += 1\\n            else:\\n                k[i] = k[a[a[i]]]\\n                p[k[i]] = i\\n\\n        elif (p[k[a[i]]] != a[i]):\\n            cnt += 1\\n            k[i] = cnt\\n            p[cnt] = i\\n            ans += 1\\n        else:\\n            k[i] = k[a[i]]\\n            p[k[i]] = i\\n\\n    print(ans)\\n\\nmain()\\n        \\n\", \"n = int(input())\\ndata = list(map(int, input().split()))\\nd = [False] * (n + 4)\\nd[0] = True\\nres = 1\\nfor i in range(n):\\n    #print(d)\\n    if d[data[i]]:\\n        d[data[i]] = False\\n        d[i + 1] = True\\n    else:\\n        d[i + 1] = True\\n        res += 1\\n#print(d)\\nprint(res)\", \"n = int(input())\\nt = list(map(int, input().split()))\\ntcopy = t[::-1]\\ntbool = [False] * len(t)\\nans = 0\\nfor i in range(len(t)):\\n    if not tbool[len(t) - i - 1]:\\n        \\n        ans += 1\\n        j = len(t) - i - 1\\n        while not tbool[j]:\\n            tbool[j] = True\\n            j = t[j] - 1\\n            if j < 0:\\n                break\\n            \\n        \\n        tbool[len(t) - i - 1] = True\\nprint(ans)\\n\", \"n=int(input())\\nm=list(map(int,input().split(' ')))\\ns=set()\\ns.add(1)\\nfor i in range(1,len(m)):\\n    try:\\n        s.remove(m[i])\\n        s.add(i+1)\\n    except:\\n        s.add(i+1)\\nprint(len(s))\\n\", \"import fractions\\nimport math\\nn=int(input())\\n#a,b=map(int,input().split(' ')) \\n#n=list(map(int,input().split(' ')))\\nt=list(map(int,input().split(' ')))\\na=set(t)\\nprint(n+1-len(a))\\n\", \"i = int(input())\\nctc = [0] + list(map(int, input().split()))\\nnm = 1\\nptor = {0:1}\\nfor i in range(1, len(ctc)):\\n    if  ctc[i] in list(ptor.keys()):\\n        ptor[i] = ptor[ctc[i]]\\n        del(ptor[ctc[i]])\\n    else:\\n        nm+=1\\n        ptor[i] = nm\\nprint(nm)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmn=set()\\nmn.add(0)\\nk=1\\nfor i in range(n):\\n    if a[i] in mn:\\n        mn-={a[i]}\\n        mn.add(i+1)\\n    else:\\n        k+=1\\n        mn.add(i+1)\\nprint(k)\\n\"]",
        "difficulty": "interview",
        "input": "5\n0 1 0 1 3\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/886/C"
    },
    {
        "id": 1933,
        "task_id": 2057,
        "test_case_id": 3,
        "question": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number t_{i}:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. \n\nInitially, Petya was in one of the rooms at minute 0, he didn't write down number t_0.\n\nAt some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 2·10^5) — then number of notes in Petya's logbook.\n\nThe second line contains n non-negative integers t_1, t_2, ..., t_{n} (0 ≤ t_{i} < i) — notes in the logbook.\n\n\n-----Output-----\n\nIn the only line print a single integer — the minimum possible number of rooms in Paris catacombs.\n\n\n-----Examples-----\nInput\n2\n0 0\n\nOutput\n2\n\nInput\n5\n0 1 0 1 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.\n\nIn the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.",
        "solutions": "[\"n = int(input())\\n\\nmas = list(map(int, input().split()))\\n\\ndist = set([0])\\nres = 1\\nfor i, e in enumerate(mas):\\n    time = i + 1\\n    if e in dist:\\n        dist.remove(e)\\n    else:\\n        res += 1\\n    dist.add(time)\\nprint(res)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nnow_time = 1\\ncount_v = 1\\nlast_time = [0 for i in range(2 * 10**5 + 10)]\\nlast_time[0] = 1\\n\\nfor i in range(n):\\n    if last_time[a[i]] > 0:\\n        last_time[a[i]] -= 1\\n    else:\\n        count_v += 1\\n\\n    last_time[now_time] += 1\\n    now_time += 1\\n\\n\\nprint(count_v)\", \"n = int(input())\\nl = list(map(int, input().split()))\\na = [0 for i in range(200001)]\\nfor x in l:\\n  a[x] = 1\\n\\nfor i in range(1, 200001):\\n  n -= a[i]\\n  \\nprint(n)\", \"n = int(input())\\nl = list(map(int, input().split()))\\nd = {}\\ns = set()\\ns.add(0)\\nd[0] = 1\\nans = 1\\nfor i in range(n):\\n    if l[i] in s:\\n        d[i + 1] = d[l[i]]\\n        s.remove(l[i])\\n        s.add(i + 1)\\n    else:\\n        s.add(i + 1)\\n        ans += 1\\n        d[i + 1] = ans\\nprint(ans)\\n\", \"n = int(input())\\nminutesUsed = [0 for _ in range(n)]\\n\\ncount = 1\\nfor v in [int(k) for k in input().split(' ') if k]:\\n    if minutesUsed[v]:\\n        count += 1\\n    else:\\n        minutesUsed[v] = 1\\nprint(count)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nvis = [False] * n\\nans = 0\\nfor i in range(n):\\n    if a[i] == 0:\\n        ans += 1\\n        vis[0] = True\\n    elif vis[a[i]]:\\n        ans += 1\\n    else:\\n        vis[a[i]] = True\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    times = list(map(int, input().split()))\\n    mntm = set()\\n    mntm.add(0)\\n    ans = 1\\n    for t in range(n):\\n        if times[t] in mntm:\\n            mntm.discard(times[t])\\n            mntm.add(t + 1)\\n        else:\\n            ans += 1\\n            mntm.add(t + 1)\\n    print(ans)\\n\\n\\nmain()\\n\", \"import sys\\ninput()\\nk=list(map(int,input().split()))\\nl=[]\\ns=[0 for i in range(200001)]\\nt=1\\nfor i in k:\\n    if s[i]==1:\\n        s[i]=0\\n    s[t]=1\\n    t+=1\\nprint(sum(s))\\n        \\n\", \"n, data = int(input()), list(map(int, input().split()))\\ntime = [0] + [-100] * (3 * (10 ** 5))\\nrooms = [0]\\nfor i in range(1, n + 1):\\n    if(time[data[i - 1]] != -100 and rooms[time[data[i - 1]]] == data[i - 1]):\\n        rooms[time[data[i - 1]]] = i\\n        time[i] = time[data[i - 1]]\\n    else:\\n        rooms.append(i)\\n        time[i] = len(rooms) - 1\\nprint(len(rooms))\", \"import sys;\\n\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\");\\n#sys.stdout = open(\\\"output.txt\\\", \\\"w\\\");\\n\\ndef ria():\\n    return [int(x) for x in input().split()];\\n\\n\\nn = int(input());\\na = ria();\\na = [0] + a;\\ntime = [-1] * (n+1);\\ntime[0] = 0;\\ntf = 0;\\n\\n\\nfor i in range(1,n+1,1):\\n    if time[a[i]] != -1:\\n        time[i] = time[a[i]];\\n        time[a[i]] = -1;\\n    else:\\n        tf += 1;\\n        time[i] = tf;\\n\\ntf += 1;\\n\\nprint(tf);\\n    \\n    \\n\\n\\n#sys.stdout.close();\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ntime = [-1] * (n + 1)\\ntime[0] = 1\\ncount = 1\\nfor i in range(n):\\n    cur_time = i + 1\\n    if time[a[i]] != -1:\\n        time[a[i]], time[cur_time] = -1, time[a[i]]\\n    else:\\n        count += 1\\n        time[cur_time] = count\\nprint(count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndi = {0 : 0}\\nk = 1\\nq = 1\\nfor i in a:\\n    if i in di:\\n        del di[i]\\n    else:\\n        q += 1\\n    di[k] = i\\n    k += 1\\nprint(q)\", \"n = int(input())\\nlist1 = list(map(int, input().split()))\\ntime = [0] * (n + 1)\\ntime[0] = 1\\nans = 1\\nfor i in range(n):\\n    if time[list1[i]] == 1:\\n        time[i + 1] = 1\\n        time[list1[i]] = 0\\n    else:\\n        ans += 1\\n        time[i + 1] = 1\\nprint(ans)\", \"n = int(input())\\nnotes = [int(x) for x in input().split()]\\ngreatest_cave = 1\\nvisits = {0: 1}\\nfor time, curr in enumerate(notes, start=1):\\n    if curr in visits and visits[curr] != -1:\\n        visits[time] = visits[curr]\\n        visits[curr] = -1\\n    else:\\n        greatest_cave += 1\\n        visits[time] = greatest_cave\\nprint(greatest_cave)\\n\", \"N = int(input())\\ntexts = [0] * N\\ntexts = input().split()\\n\\nends=set()\\n#print(ends)\\n\\nends.add(0)\\n#print(ends)\\n\\nfor i in range(N):\\n    if int(texts[i]) in ends:\\n        ends.remove(int(texts[i]))\\n        #print('-'+texts[i],end=' ')\\n    ends.add(i+1)\\n    #print(ends)\\n\\nprint(len(ends))\\n\\n\", \"def main():\\n\\n    n = int(input())\\n\\n    a = [0]\\n    a += list(map(int, input().split()))\\n\\n    p = [0] * 200001\\n    p[1] = 0\\n    k = [-1] * 200001\\n    k[0] = 1\\n\\n    ans = 1\\n\\n    cnt = 1\\n\\n    for i in range(1, n + 1):\\n        if (i == 1):\\n            if (a[i] == 1):\\n                cnt += 1\\n                k[i] = cnt\\n                p[cnt] = i\\n                ans += 1\\n            else:\\n                k[i] = k[a[a[i]]]\\n                p[k[i]] = i\\n\\n        elif (p[k[a[i]]] != a[i]):\\n            cnt += 1\\n            k[i] = cnt\\n            p[cnt] = i\\n            ans += 1\\n        else:\\n            k[i] = k[a[i]]\\n            p[k[i]] = i\\n\\n    print(ans)\\n\\nmain()\\n        \\n\", \"n = int(input())\\ndata = list(map(int, input().split()))\\nd = [False] * (n + 4)\\nd[0] = True\\nres = 1\\nfor i in range(n):\\n    #print(d)\\n    if d[data[i]]:\\n        d[data[i]] = False\\n        d[i + 1] = True\\n    else:\\n        d[i + 1] = True\\n        res += 1\\n#print(d)\\nprint(res)\", \"n = int(input())\\nt = list(map(int, input().split()))\\ntcopy = t[::-1]\\ntbool = [False] * len(t)\\nans = 0\\nfor i in range(len(t)):\\n    if not tbool[len(t) - i - 1]:\\n        \\n        ans += 1\\n        j = len(t) - i - 1\\n        while not tbool[j]:\\n            tbool[j] = True\\n            j = t[j] - 1\\n            if j < 0:\\n                break\\n            \\n        \\n        tbool[len(t) - i - 1] = True\\nprint(ans)\\n\", \"n=int(input())\\nm=list(map(int,input().split(' ')))\\ns=set()\\ns.add(1)\\nfor i in range(1,len(m)):\\n    try:\\n        s.remove(m[i])\\n        s.add(i+1)\\n    except:\\n        s.add(i+1)\\nprint(len(s))\\n\", \"import fractions\\nimport math\\nn=int(input())\\n#a,b=map(int,input().split(' ')) \\n#n=list(map(int,input().split(' ')))\\nt=list(map(int,input().split(' ')))\\na=set(t)\\nprint(n+1-len(a))\\n\", \"i = int(input())\\nctc = [0] + list(map(int, input().split()))\\nnm = 1\\nptor = {0:1}\\nfor i in range(1, len(ctc)):\\n    if  ctc[i] in list(ptor.keys()):\\n        ptor[i] = ptor[ctc[i]]\\n        del(ptor[ctc[i]])\\n    else:\\n        nm+=1\\n        ptor[i] = nm\\nprint(nm)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmn=set()\\nmn.add(0)\\nk=1\\nfor i in range(n):\\n    if a[i] in mn:\\n        mn-={a[i]}\\n        mn.add(i+1)\\n    else:\\n        k+=1\\n        mn.add(i+1)\\nprint(k)\\n\"]",
        "difficulty": "interview",
        "input": "7\n0 1 0 0 0 0 0\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/886/C"
    },
    {
        "id": 1934,
        "task_id": 2057,
        "test_case_id": 4,
        "question": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number t_{i}:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. \n\nInitially, Petya was in one of the rooms at minute 0, he didn't write down number t_0.\n\nAt some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 2·10^5) — then number of notes in Petya's logbook.\n\nThe second line contains n non-negative integers t_1, t_2, ..., t_{n} (0 ≤ t_{i} < i) — notes in the logbook.\n\n\n-----Output-----\n\nIn the only line print a single integer — the minimum possible number of rooms in Paris catacombs.\n\n\n-----Examples-----\nInput\n2\n0 0\n\nOutput\n2\n\nInput\n5\n0 1 0 1 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.\n\nIn the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.",
        "solutions": "[\"n = int(input())\\n\\nmas = list(map(int, input().split()))\\n\\ndist = set([0])\\nres = 1\\nfor i, e in enumerate(mas):\\n    time = i + 1\\n    if e in dist:\\n        dist.remove(e)\\n    else:\\n        res += 1\\n    dist.add(time)\\nprint(res)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nnow_time = 1\\ncount_v = 1\\nlast_time = [0 for i in range(2 * 10**5 + 10)]\\nlast_time[0] = 1\\n\\nfor i in range(n):\\n    if last_time[a[i]] > 0:\\n        last_time[a[i]] -= 1\\n    else:\\n        count_v += 1\\n\\n    last_time[now_time] += 1\\n    now_time += 1\\n\\n\\nprint(count_v)\", \"n = int(input())\\nl = list(map(int, input().split()))\\na = [0 for i in range(200001)]\\nfor x in l:\\n  a[x] = 1\\n\\nfor i in range(1, 200001):\\n  n -= a[i]\\n  \\nprint(n)\", \"n = int(input())\\nl = list(map(int, input().split()))\\nd = {}\\ns = set()\\ns.add(0)\\nd[0] = 1\\nans = 1\\nfor i in range(n):\\n    if l[i] in s:\\n        d[i + 1] = d[l[i]]\\n        s.remove(l[i])\\n        s.add(i + 1)\\n    else:\\n        s.add(i + 1)\\n        ans += 1\\n        d[i + 1] = ans\\nprint(ans)\\n\", \"n = int(input())\\nminutesUsed = [0 for _ in range(n)]\\n\\ncount = 1\\nfor v in [int(k) for k in input().split(' ') if k]:\\n    if minutesUsed[v]:\\n        count += 1\\n    else:\\n        minutesUsed[v] = 1\\nprint(count)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nvis = [False] * n\\nans = 0\\nfor i in range(n):\\n    if a[i] == 0:\\n        ans += 1\\n        vis[0] = True\\n    elif vis[a[i]]:\\n        ans += 1\\n    else:\\n        vis[a[i]] = True\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    times = list(map(int, input().split()))\\n    mntm = set()\\n    mntm.add(0)\\n    ans = 1\\n    for t in range(n):\\n        if times[t] in mntm:\\n            mntm.discard(times[t])\\n            mntm.add(t + 1)\\n        else:\\n            ans += 1\\n            mntm.add(t + 1)\\n    print(ans)\\n\\n\\nmain()\\n\", \"import sys\\ninput()\\nk=list(map(int,input().split()))\\nl=[]\\ns=[0 for i in range(200001)]\\nt=1\\nfor i in k:\\n    if s[i]==1:\\n        s[i]=0\\n    s[t]=1\\n    t+=1\\nprint(sum(s))\\n        \\n\", \"n, data = int(input()), list(map(int, input().split()))\\ntime = [0] + [-100] * (3 * (10 ** 5))\\nrooms = [0]\\nfor i in range(1, n + 1):\\n    if(time[data[i - 1]] != -100 and rooms[time[data[i - 1]]] == data[i - 1]):\\n        rooms[time[data[i - 1]]] = i\\n        time[i] = time[data[i - 1]]\\n    else:\\n        rooms.append(i)\\n        time[i] = len(rooms) - 1\\nprint(len(rooms))\", \"import sys;\\n\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\");\\n#sys.stdout = open(\\\"output.txt\\\", \\\"w\\\");\\n\\ndef ria():\\n    return [int(x) for x in input().split()];\\n\\n\\nn = int(input());\\na = ria();\\na = [0] + a;\\ntime = [-1] * (n+1);\\ntime[0] = 0;\\ntf = 0;\\n\\n\\nfor i in range(1,n+1,1):\\n    if time[a[i]] != -1:\\n        time[i] = time[a[i]];\\n        time[a[i]] = -1;\\n    else:\\n        tf += 1;\\n        time[i] = tf;\\n\\ntf += 1;\\n\\nprint(tf);\\n    \\n    \\n\\n\\n#sys.stdout.close();\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ntime = [-1] * (n + 1)\\ntime[0] = 1\\ncount = 1\\nfor i in range(n):\\n    cur_time = i + 1\\n    if time[a[i]] != -1:\\n        time[a[i]], time[cur_time] = -1, time[a[i]]\\n    else:\\n        count += 1\\n        time[cur_time] = count\\nprint(count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndi = {0 : 0}\\nk = 1\\nq = 1\\nfor i in a:\\n    if i in di:\\n        del di[i]\\n    else:\\n        q += 1\\n    di[k] = i\\n    k += 1\\nprint(q)\", \"n = int(input())\\nlist1 = list(map(int, input().split()))\\ntime = [0] * (n + 1)\\ntime[0] = 1\\nans = 1\\nfor i in range(n):\\n    if time[list1[i]] == 1:\\n        time[i + 1] = 1\\n        time[list1[i]] = 0\\n    else:\\n        ans += 1\\n        time[i + 1] = 1\\nprint(ans)\", \"n = int(input())\\nnotes = [int(x) for x in input().split()]\\ngreatest_cave = 1\\nvisits = {0: 1}\\nfor time, curr in enumerate(notes, start=1):\\n    if curr in visits and visits[curr] != -1:\\n        visits[time] = visits[curr]\\n        visits[curr] = -1\\n    else:\\n        greatest_cave += 1\\n        visits[time] = greatest_cave\\nprint(greatest_cave)\\n\", \"N = int(input())\\ntexts = [0] * N\\ntexts = input().split()\\n\\nends=set()\\n#print(ends)\\n\\nends.add(0)\\n#print(ends)\\n\\nfor i in range(N):\\n    if int(texts[i]) in ends:\\n        ends.remove(int(texts[i]))\\n        #print('-'+texts[i],end=' ')\\n    ends.add(i+1)\\n    #print(ends)\\n\\nprint(len(ends))\\n\\n\", \"def main():\\n\\n    n = int(input())\\n\\n    a = [0]\\n    a += list(map(int, input().split()))\\n\\n    p = [0] * 200001\\n    p[1] = 0\\n    k = [-1] * 200001\\n    k[0] = 1\\n\\n    ans = 1\\n\\n    cnt = 1\\n\\n    for i in range(1, n + 1):\\n        if (i == 1):\\n            if (a[i] == 1):\\n                cnt += 1\\n                k[i] = cnt\\n                p[cnt] = i\\n                ans += 1\\n            else:\\n                k[i] = k[a[a[i]]]\\n                p[k[i]] = i\\n\\n        elif (p[k[a[i]]] != a[i]):\\n            cnt += 1\\n            k[i] = cnt\\n            p[cnt] = i\\n            ans += 1\\n        else:\\n            k[i] = k[a[i]]\\n            p[k[i]] = i\\n\\n    print(ans)\\n\\nmain()\\n        \\n\", \"n = int(input())\\ndata = list(map(int, input().split()))\\nd = [False] * (n + 4)\\nd[0] = True\\nres = 1\\nfor i in range(n):\\n    #print(d)\\n    if d[data[i]]:\\n        d[data[i]] = False\\n        d[i + 1] = True\\n    else:\\n        d[i + 1] = True\\n        res += 1\\n#print(d)\\nprint(res)\", \"n = int(input())\\nt = list(map(int, input().split()))\\ntcopy = t[::-1]\\ntbool = [False] * len(t)\\nans = 0\\nfor i in range(len(t)):\\n    if not tbool[len(t) - i - 1]:\\n        \\n        ans += 1\\n        j = len(t) - i - 1\\n        while not tbool[j]:\\n            tbool[j] = True\\n            j = t[j] - 1\\n            if j < 0:\\n                break\\n            \\n        \\n        tbool[len(t) - i - 1] = True\\nprint(ans)\\n\", \"n=int(input())\\nm=list(map(int,input().split(' ')))\\ns=set()\\ns.add(1)\\nfor i in range(1,len(m)):\\n    try:\\n        s.remove(m[i])\\n        s.add(i+1)\\n    except:\\n        s.add(i+1)\\nprint(len(s))\\n\", \"import fractions\\nimport math\\nn=int(input())\\n#a,b=map(int,input().split(' ')) \\n#n=list(map(int,input().split(' ')))\\nt=list(map(int,input().split(' ')))\\na=set(t)\\nprint(n+1-len(a))\\n\", \"i = int(input())\\nctc = [0] + list(map(int, input().split()))\\nnm = 1\\nptor = {0:1}\\nfor i in range(1, len(ctc)):\\n    if  ctc[i] in list(ptor.keys()):\\n        ptor[i] = ptor[ctc[i]]\\n        del(ptor[ctc[i]])\\n    else:\\n        nm+=1\\n        ptor[i] = nm\\nprint(nm)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmn=set()\\nmn.add(0)\\nk=1\\nfor i in range(n):\\n    if a[i] in mn:\\n        mn-={a[i]}\\n        mn.add(i+1)\\n    else:\\n        k+=1\\n        mn.add(i+1)\\nprint(k)\\n\"]",
        "difficulty": "interview",
        "input": "100\n0 0 0 0 0 0 1 4 4 0 2 2 4 1 7 1 11 0 8 4 12 12 3 0 3 2 2 4 3 9 1 5 4 6 9 14 6 2 4 18 7 7 19 11 20 13 17 16 0 34 2 6 12 27 9 4 29 22 4 20 20 17 17 20 37 53 17 3 3 15 1 46 11 24 31 6 12 6 11 18 13 1 5 0 19 10 24 41 16 41 18 52 46 39 16 30 18 23 53 13\n",
        "output": "66\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/886/C"
    },
    {
        "id": 1935,
        "task_id": 2057,
        "test_case_id": 5,
        "question": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number t_{i}:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. \n\nInitially, Petya was in one of the rooms at minute 0, he didn't write down number t_0.\n\nAt some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 2·10^5) — then number of notes in Petya's logbook.\n\nThe second line contains n non-negative integers t_1, t_2, ..., t_{n} (0 ≤ t_{i} < i) — notes in the logbook.\n\n\n-----Output-----\n\nIn the only line print a single integer — the minimum possible number of rooms in Paris catacombs.\n\n\n-----Examples-----\nInput\n2\n0 0\n\nOutput\n2\n\nInput\n5\n0 1 0 1 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.\n\nIn the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.",
        "solutions": "[\"n = int(input())\\n\\nmas = list(map(int, input().split()))\\n\\ndist = set([0])\\nres = 1\\nfor i, e in enumerate(mas):\\n    time = i + 1\\n    if e in dist:\\n        dist.remove(e)\\n    else:\\n        res += 1\\n    dist.add(time)\\nprint(res)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nnow_time = 1\\ncount_v = 1\\nlast_time = [0 for i in range(2 * 10**5 + 10)]\\nlast_time[0] = 1\\n\\nfor i in range(n):\\n    if last_time[a[i]] > 0:\\n        last_time[a[i]] -= 1\\n    else:\\n        count_v += 1\\n\\n    last_time[now_time] += 1\\n    now_time += 1\\n\\n\\nprint(count_v)\", \"n = int(input())\\nl = list(map(int, input().split()))\\na = [0 for i in range(200001)]\\nfor x in l:\\n  a[x] = 1\\n\\nfor i in range(1, 200001):\\n  n -= a[i]\\n  \\nprint(n)\", \"n = int(input())\\nl = list(map(int, input().split()))\\nd = {}\\ns = set()\\ns.add(0)\\nd[0] = 1\\nans = 1\\nfor i in range(n):\\n    if l[i] in s:\\n        d[i + 1] = d[l[i]]\\n        s.remove(l[i])\\n        s.add(i + 1)\\n    else:\\n        s.add(i + 1)\\n        ans += 1\\n        d[i + 1] = ans\\nprint(ans)\\n\", \"n = int(input())\\nminutesUsed = [0 for _ in range(n)]\\n\\ncount = 1\\nfor v in [int(k) for k in input().split(' ') if k]:\\n    if minutesUsed[v]:\\n        count += 1\\n    else:\\n        minutesUsed[v] = 1\\nprint(count)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nvis = [False] * n\\nans = 0\\nfor i in range(n):\\n    if a[i] == 0:\\n        ans += 1\\n        vis[0] = True\\n    elif vis[a[i]]:\\n        ans += 1\\n    else:\\n        vis[a[i]] = True\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    times = list(map(int, input().split()))\\n    mntm = set()\\n    mntm.add(0)\\n    ans = 1\\n    for t in range(n):\\n        if times[t] in mntm:\\n            mntm.discard(times[t])\\n            mntm.add(t + 1)\\n        else:\\n            ans += 1\\n            mntm.add(t + 1)\\n    print(ans)\\n\\n\\nmain()\\n\", \"import sys\\ninput()\\nk=list(map(int,input().split()))\\nl=[]\\ns=[0 for i in range(200001)]\\nt=1\\nfor i in k:\\n    if s[i]==1:\\n        s[i]=0\\n    s[t]=1\\n    t+=1\\nprint(sum(s))\\n        \\n\", \"n, data = int(input()), list(map(int, input().split()))\\ntime = [0] + [-100] * (3 * (10 ** 5))\\nrooms = [0]\\nfor i in range(1, n + 1):\\n    if(time[data[i - 1]] != -100 and rooms[time[data[i - 1]]] == data[i - 1]):\\n        rooms[time[data[i - 1]]] = i\\n        time[i] = time[data[i - 1]]\\n    else:\\n        rooms.append(i)\\n        time[i] = len(rooms) - 1\\nprint(len(rooms))\", \"import sys;\\n\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\");\\n#sys.stdout = open(\\\"output.txt\\\", \\\"w\\\");\\n\\ndef ria():\\n    return [int(x) for x in input().split()];\\n\\n\\nn = int(input());\\na = ria();\\na = [0] + a;\\ntime = [-1] * (n+1);\\ntime[0] = 0;\\ntf = 0;\\n\\n\\nfor i in range(1,n+1,1):\\n    if time[a[i]] != -1:\\n        time[i] = time[a[i]];\\n        time[a[i]] = -1;\\n    else:\\n        tf += 1;\\n        time[i] = tf;\\n\\ntf += 1;\\n\\nprint(tf);\\n    \\n    \\n\\n\\n#sys.stdout.close();\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ntime = [-1] * (n + 1)\\ntime[0] = 1\\ncount = 1\\nfor i in range(n):\\n    cur_time = i + 1\\n    if time[a[i]] != -1:\\n        time[a[i]], time[cur_time] = -1, time[a[i]]\\n    else:\\n        count += 1\\n        time[cur_time] = count\\nprint(count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndi = {0 : 0}\\nk = 1\\nq = 1\\nfor i in a:\\n    if i in di:\\n        del di[i]\\n    else:\\n        q += 1\\n    di[k] = i\\n    k += 1\\nprint(q)\", \"n = int(input())\\nlist1 = list(map(int, input().split()))\\ntime = [0] * (n + 1)\\ntime[0] = 1\\nans = 1\\nfor i in range(n):\\n    if time[list1[i]] == 1:\\n        time[i + 1] = 1\\n        time[list1[i]] = 0\\n    else:\\n        ans += 1\\n        time[i + 1] = 1\\nprint(ans)\", \"n = int(input())\\nnotes = [int(x) for x in input().split()]\\ngreatest_cave = 1\\nvisits = {0: 1}\\nfor time, curr in enumerate(notes, start=1):\\n    if curr in visits and visits[curr] != -1:\\n        visits[time] = visits[curr]\\n        visits[curr] = -1\\n    else:\\n        greatest_cave += 1\\n        visits[time] = greatest_cave\\nprint(greatest_cave)\\n\", \"N = int(input())\\ntexts = [0] * N\\ntexts = input().split()\\n\\nends=set()\\n#print(ends)\\n\\nends.add(0)\\n#print(ends)\\n\\nfor i in range(N):\\n    if int(texts[i]) in ends:\\n        ends.remove(int(texts[i]))\\n        #print('-'+texts[i],end=' ')\\n    ends.add(i+1)\\n    #print(ends)\\n\\nprint(len(ends))\\n\\n\", \"def main():\\n\\n    n = int(input())\\n\\n    a = [0]\\n    a += list(map(int, input().split()))\\n\\n    p = [0] * 200001\\n    p[1] = 0\\n    k = [-1] * 200001\\n    k[0] = 1\\n\\n    ans = 1\\n\\n    cnt = 1\\n\\n    for i in range(1, n + 1):\\n        if (i == 1):\\n            if (a[i] == 1):\\n                cnt += 1\\n                k[i] = cnt\\n                p[cnt] = i\\n                ans += 1\\n            else:\\n                k[i] = k[a[a[i]]]\\n                p[k[i]] = i\\n\\n        elif (p[k[a[i]]] != a[i]):\\n            cnt += 1\\n            k[i] = cnt\\n            p[cnt] = i\\n            ans += 1\\n        else:\\n            k[i] = k[a[i]]\\n            p[k[i]] = i\\n\\n    print(ans)\\n\\nmain()\\n        \\n\", \"n = int(input())\\ndata = list(map(int, input().split()))\\nd = [False] * (n + 4)\\nd[0] = True\\nres = 1\\nfor i in range(n):\\n    #print(d)\\n    if d[data[i]]:\\n        d[data[i]] = False\\n        d[i + 1] = True\\n    else:\\n        d[i + 1] = True\\n        res += 1\\n#print(d)\\nprint(res)\", \"n = int(input())\\nt = list(map(int, input().split()))\\ntcopy = t[::-1]\\ntbool = [False] * len(t)\\nans = 0\\nfor i in range(len(t)):\\n    if not tbool[len(t) - i - 1]:\\n        \\n        ans += 1\\n        j = len(t) - i - 1\\n        while not tbool[j]:\\n            tbool[j] = True\\n            j = t[j] - 1\\n            if j < 0:\\n                break\\n            \\n        \\n        tbool[len(t) - i - 1] = True\\nprint(ans)\\n\", \"n=int(input())\\nm=list(map(int,input().split(' ')))\\ns=set()\\ns.add(1)\\nfor i in range(1,len(m)):\\n    try:\\n        s.remove(m[i])\\n        s.add(i+1)\\n    except:\\n        s.add(i+1)\\nprint(len(s))\\n\", \"import fractions\\nimport math\\nn=int(input())\\n#a,b=map(int,input().split(' ')) \\n#n=list(map(int,input().split(' ')))\\nt=list(map(int,input().split(' ')))\\na=set(t)\\nprint(n+1-len(a))\\n\", \"i = int(input())\\nctc = [0] + list(map(int, input().split()))\\nnm = 1\\nptor = {0:1}\\nfor i in range(1, len(ctc)):\\n    if  ctc[i] in list(ptor.keys()):\\n        ptor[i] = ptor[ctc[i]]\\n        del(ptor[ctc[i]])\\n    else:\\n        nm+=1\\n        ptor[i] = nm\\nprint(nm)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmn=set()\\nmn.add(0)\\nk=1\\nfor i in range(n):\\n    if a[i] in mn:\\n        mn-={a[i]}\\n        mn.add(i+1)\\n    else:\\n        k+=1\\n        mn.add(i+1)\\nprint(k)\\n\"]",
        "difficulty": "interview",
        "input": "100\n0 0 0 0 1 2 0 0 3 3 2 2 6 4 1 6 2 9 8 0 2 0 2 2 0 0 10 0 4 20 4 11 3 9 0 3 8 2 6 3 13 2 1 23 20 20 16 7 1 37 6 1 25 25 14 30 6 23 18 3 2 16 0 4 37 9 4 6 2 14 15 11 16 35 36 7 32 26 8 1 0 37 35 38 27 3 16 8 3 7 7 25 13 13 30 11 5 28 0 12\n",
        "output": "71\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/886/C"
    },
    {
        "id": 1936,
        "task_id": 2057,
        "test_case_id": 6,
        "question": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number t_{i}:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. \n\nInitially, Petya was in one of the rooms at minute 0, he didn't write down number t_0.\n\nAt some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 2·10^5) — then number of notes in Petya's logbook.\n\nThe second line contains n non-negative integers t_1, t_2, ..., t_{n} (0 ≤ t_{i} < i) — notes in the logbook.\n\n\n-----Output-----\n\nIn the only line print a single integer — the minimum possible number of rooms in Paris catacombs.\n\n\n-----Examples-----\nInput\n2\n0 0\n\nOutput\n2\n\nInput\n5\n0 1 0 1 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.\n\nIn the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.",
        "solutions": "[\"n = int(input())\\n\\nmas = list(map(int, input().split()))\\n\\ndist = set([0])\\nres = 1\\nfor i, e in enumerate(mas):\\n    time = i + 1\\n    if e in dist:\\n        dist.remove(e)\\n    else:\\n        res += 1\\n    dist.add(time)\\nprint(res)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nnow_time = 1\\ncount_v = 1\\nlast_time = [0 for i in range(2 * 10**5 + 10)]\\nlast_time[0] = 1\\n\\nfor i in range(n):\\n    if last_time[a[i]] > 0:\\n        last_time[a[i]] -= 1\\n    else:\\n        count_v += 1\\n\\n    last_time[now_time] += 1\\n    now_time += 1\\n\\n\\nprint(count_v)\", \"n = int(input())\\nl = list(map(int, input().split()))\\na = [0 for i in range(200001)]\\nfor x in l:\\n  a[x] = 1\\n\\nfor i in range(1, 200001):\\n  n -= a[i]\\n  \\nprint(n)\", \"n = int(input())\\nl = list(map(int, input().split()))\\nd = {}\\ns = set()\\ns.add(0)\\nd[0] = 1\\nans = 1\\nfor i in range(n):\\n    if l[i] in s:\\n        d[i + 1] = d[l[i]]\\n        s.remove(l[i])\\n        s.add(i + 1)\\n    else:\\n        s.add(i + 1)\\n        ans += 1\\n        d[i + 1] = ans\\nprint(ans)\\n\", \"n = int(input())\\nminutesUsed = [0 for _ in range(n)]\\n\\ncount = 1\\nfor v in [int(k) for k in input().split(' ') if k]:\\n    if minutesUsed[v]:\\n        count += 1\\n    else:\\n        minutesUsed[v] = 1\\nprint(count)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nvis = [False] * n\\nans = 0\\nfor i in range(n):\\n    if a[i] == 0:\\n        ans += 1\\n        vis[0] = True\\n    elif vis[a[i]]:\\n        ans += 1\\n    else:\\n        vis[a[i]] = True\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    times = list(map(int, input().split()))\\n    mntm = set()\\n    mntm.add(0)\\n    ans = 1\\n    for t in range(n):\\n        if times[t] in mntm:\\n            mntm.discard(times[t])\\n            mntm.add(t + 1)\\n        else:\\n            ans += 1\\n            mntm.add(t + 1)\\n    print(ans)\\n\\n\\nmain()\\n\", \"import sys\\ninput()\\nk=list(map(int,input().split()))\\nl=[]\\ns=[0 for i in range(200001)]\\nt=1\\nfor i in k:\\n    if s[i]==1:\\n        s[i]=0\\n    s[t]=1\\n    t+=1\\nprint(sum(s))\\n        \\n\", \"n, data = int(input()), list(map(int, input().split()))\\ntime = [0] + [-100] * (3 * (10 ** 5))\\nrooms = [0]\\nfor i in range(1, n + 1):\\n    if(time[data[i - 1]] != -100 and rooms[time[data[i - 1]]] == data[i - 1]):\\n        rooms[time[data[i - 1]]] = i\\n        time[i] = time[data[i - 1]]\\n    else:\\n        rooms.append(i)\\n        time[i] = len(rooms) - 1\\nprint(len(rooms))\", \"import sys;\\n\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\");\\n#sys.stdout = open(\\\"output.txt\\\", \\\"w\\\");\\n\\ndef ria():\\n    return [int(x) for x in input().split()];\\n\\n\\nn = int(input());\\na = ria();\\na = [0] + a;\\ntime = [-1] * (n+1);\\ntime[0] = 0;\\ntf = 0;\\n\\n\\nfor i in range(1,n+1,1):\\n    if time[a[i]] != -1:\\n        time[i] = time[a[i]];\\n        time[a[i]] = -1;\\n    else:\\n        tf += 1;\\n        time[i] = tf;\\n\\ntf += 1;\\n\\nprint(tf);\\n    \\n    \\n\\n\\n#sys.stdout.close();\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ntime = [-1] * (n + 1)\\ntime[0] = 1\\ncount = 1\\nfor i in range(n):\\n    cur_time = i + 1\\n    if time[a[i]] != -1:\\n        time[a[i]], time[cur_time] = -1, time[a[i]]\\n    else:\\n        count += 1\\n        time[cur_time] = count\\nprint(count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndi = {0 : 0}\\nk = 1\\nq = 1\\nfor i in a:\\n    if i in di:\\n        del di[i]\\n    else:\\n        q += 1\\n    di[k] = i\\n    k += 1\\nprint(q)\", \"n = int(input())\\nlist1 = list(map(int, input().split()))\\ntime = [0] * (n + 1)\\ntime[0] = 1\\nans = 1\\nfor i in range(n):\\n    if time[list1[i]] == 1:\\n        time[i + 1] = 1\\n        time[list1[i]] = 0\\n    else:\\n        ans += 1\\n        time[i + 1] = 1\\nprint(ans)\", \"n = int(input())\\nnotes = [int(x) for x in input().split()]\\ngreatest_cave = 1\\nvisits = {0: 1}\\nfor time, curr in enumerate(notes, start=1):\\n    if curr in visits and visits[curr] != -1:\\n        visits[time] = visits[curr]\\n        visits[curr] = -1\\n    else:\\n        greatest_cave += 1\\n        visits[time] = greatest_cave\\nprint(greatest_cave)\\n\", \"N = int(input())\\ntexts = [0] * N\\ntexts = input().split()\\n\\nends=set()\\n#print(ends)\\n\\nends.add(0)\\n#print(ends)\\n\\nfor i in range(N):\\n    if int(texts[i]) in ends:\\n        ends.remove(int(texts[i]))\\n        #print('-'+texts[i],end=' ')\\n    ends.add(i+1)\\n    #print(ends)\\n\\nprint(len(ends))\\n\\n\", \"def main():\\n\\n    n = int(input())\\n\\n    a = [0]\\n    a += list(map(int, input().split()))\\n\\n    p = [0] * 200001\\n    p[1] = 0\\n    k = [-1] * 200001\\n    k[0] = 1\\n\\n    ans = 1\\n\\n    cnt = 1\\n\\n    for i in range(1, n + 1):\\n        if (i == 1):\\n            if (a[i] == 1):\\n                cnt += 1\\n                k[i] = cnt\\n                p[cnt] = i\\n                ans += 1\\n            else:\\n                k[i] = k[a[a[i]]]\\n                p[k[i]] = i\\n\\n        elif (p[k[a[i]]] != a[i]):\\n            cnt += 1\\n            k[i] = cnt\\n            p[cnt] = i\\n            ans += 1\\n        else:\\n            k[i] = k[a[i]]\\n            p[k[i]] = i\\n\\n    print(ans)\\n\\nmain()\\n        \\n\", \"n = int(input())\\ndata = list(map(int, input().split()))\\nd = [False] * (n + 4)\\nd[0] = True\\nres = 1\\nfor i in range(n):\\n    #print(d)\\n    if d[data[i]]:\\n        d[data[i]] = False\\n        d[i + 1] = True\\n    else:\\n        d[i + 1] = True\\n        res += 1\\n#print(d)\\nprint(res)\", \"n = int(input())\\nt = list(map(int, input().split()))\\ntcopy = t[::-1]\\ntbool = [False] * len(t)\\nans = 0\\nfor i in range(len(t)):\\n    if not tbool[len(t) - i - 1]:\\n        \\n        ans += 1\\n        j = len(t) - i - 1\\n        while not tbool[j]:\\n            tbool[j] = True\\n            j = t[j] - 1\\n            if j < 0:\\n                break\\n            \\n        \\n        tbool[len(t) - i - 1] = True\\nprint(ans)\\n\", \"n=int(input())\\nm=list(map(int,input().split(' ')))\\ns=set()\\ns.add(1)\\nfor i in range(1,len(m)):\\n    try:\\n        s.remove(m[i])\\n        s.add(i+1)\\n    except:\\n        s.add(i+1)\\nprint(len(s))\\n\", \"import fractions\\nimport math\\nn=int(input())\\n#a,b=map(int,input().split(' ')) \\n#n=list(map(int,input().split(' ')))\\nt=list(map(int,input().split(' ')))\\na=set(t)\\nprint(n+1-len(a))\\n\", \"i = int(input())\\nctc = [0] + list(map(int, input().split()))\\nnm = 1\\nptor = {0:1}\\nfor i in range(1, len(ctc)):\\n    if  ctc[i] in list(ptor.keys()):\\n        ptor[i] = ptor[ctc[i]]\\n        del(ptor[ctc[i]])\\n    else:\\n        nm+=1\\n        ptor[i] = nm\\nprint(nm)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmn=set()\\nmn.add(0)\\nk=1\\nfor i in range(n):\\n    if a[i] in mn:\\n        mn-={a[i]}\\n        mn.add(i+1)\\n    else:\\n        k+=1\\n        mn.add(i+1)\\nprint(k)\\n\"]",
        "difficulty": "interview",
        "input": "1\n0\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/886/C"
    },
    {
        "id": 1937,
        "task_id": 2057,
        "test_case_id": 7,
        "question": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number t_{i}:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. \n\nInitially, Petya was in one of the rooms at minute 0, he didn't write down number t_0.\n\nAt some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 2·10^5) — then number of notes in Petya's logbook.\n\nThe second line contains n non-negative integers t_1, t_2, ..., t_{n} (0 ≤ t_{i} < i) — notes in the logbook.\n\n\n-----Output-----\n\nIn the only line print a single integer — the minimum possible number of rooms in Paris catacombs.\n\n\n-----Examples-----\nInput\n2\n0 0\n\nOutput\n2\n\nInput\n5\n0 1 0 1 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.\n\nIn the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.",
        "solutions": "[\"n = int(input())\\n\\nmas = list(map(int, input().split()))\\n\\ndist = set([0])\\nres = 1\\nfor i, e in enumerate(mas):\\n    time = i + 1\\n    if e in dist:\\n        dist.remove(e)\\n    else:\\n        res += 1\\n    dist.add(time)\\nprint(res)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nnow_time = 1\\ncount_v = 1\\nlast_time = [0 for i in range(2 * 10**5 + 10)]\\nlast_time[0] = 1\\n\\nfor i in range(n):\\n    if last_time[a[i]] > 0:\\n        last_time[a[i]] -= 1\\n    else:\\n        count_v += 1\\n\\n    last_time[now_time] += 1\\n    now_time += 1\\n\\n\\nprint(count_v)\", \"n = int(input())\\nl = list(map(int, input().split()))\\na = [0 for i in range(200001)]\\nfor x in l:\\n  a[x] = 1\\n\\nfor i in range(1, 200001):\\n  n -= a[i]\\n  \\nprint(n)\", \"n = int(input())\\nl = list(map(int, input().split()))\\nd = {}\\ns = set()\\ns.add(0)\\nd[0] = 1\\nans = 1\\nfor i in range(n):\\n    if l[i] in s:\\n        d[i + 1] = d[l[i]]\\n        s.remove(l[i])\\n        s.add(i + 1)\\n    else:\\n        s.add(i + 1)\\n        ans += 1\\n        d[i + 1] = ans\\nprint(ans)\\n\", \"n = int(input())\\nminutesUsed = [0 for _ in range(n)]\\n\\ncount = 1\\nfor v in [int(k) for k in input().split(' ') if k]:\\n    if minutesUsed[v]:\\n        count += 1\\n    else:\\n        minutesUsed[v] = 1\\nprint(count)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nvis = [False] * n\\nans = 0\\nfor i in range(n):\\n    if a[i] == 0:\\n        ans += 1\\n        vis[0] = True\\n    elif vis[a[i]]:\\n        ans += 1\\n    else:\\n        vis[a[i]] = True\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    times = list(map(int, input().split()))\\n    mntm = set()\\n    mntm.add(0)\\n    ans = 1\\n    for t in range(n):\\n        if times[t] in mntm:\\n            mntm.discard(times[t])\\n            mntm.add(t + 1)\\n        else:\\n            ans += 1\\n            mntm.add(t + 1)\\n    print(ans)\\n\\n\\nmain()\\n\", \"import sys\\ninput()\\nk=list(map(int,input().split()))\\nl=[]\\ns=[0 for i in range(200001)]\\nt=1\\nfor i in k:\\n    if s[i]==1:\\n        s[i]=0\\n    s[t]=1\\n    t+=1\\nprint(sum(s))\\n        \\n\", \"n, data = int(input()), list(map(int, input().split()))\\ntime = [0] + [-100] * (3 * (10 ** 5))\\nrooms = [0]\\nfor i in range(1, n + 1):\\n    if(time[data[i - 1]] != -100 and rooms[time[data[i - 1]]] == data[i - 1]):\\n        rooms[time[data[i - 1]]] = i\\n        time[i] = time[data[i - 1]]\\n    else:\\n        rooms.append(i)\\n        time[i] = len(rooms) - 1\\nprint(len(rooms))\", \"import sys;\\n\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\");\\n#sys.stdout = open(\\\"output.txt\\\", \\\"w\\\");\\n\\ndef ria():\\n    return [int(x) for x in input().split()];\\n\\n\\nn = int(input());\\na = ria();\\na = [0] + a;\\ntime = [-1] * (n+1);\\ntime[0] = 0;\\ntf = 0;\\n\\n\\nfor i in range(1,n+1,1):\\n    if time[a[i]] != -1:\\n        time[i] = time[a[i]];\\n        time[a[i]] = -1;\\n    else:\\n        tf += 1;\\n        time[i] = tf;\\n\\ntf += 1;\\n\\nprint(tf);\\n    \\n    \\n\\n\\n#sys.stdout.close();\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ntime = [-1] * (n + 1)\\ntime[0] = 1\\ncount = 1\\nfor i in range(n):\\n    cur_time = i + 1\\n    if time[a[i]] != -1:\\n        time[a[i]], time[cur_time] = -1, time[a[i]]\\n    else:\\n        count += 1\\n        time[cur_time] = count\\nprint(count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndi = {0 : 0}\\nk = 1\\nq = 1\\nfor i in a:\\n    if i in di:\\n        del di[i]\\n    else:\\n        q += 1\\n    di[k] = i\\n    k += 1\\nprint(q)\", \"n = int(input())\\nlist1 = list(map(int, input().split()))\\ntime = [0] * (n + 1)\\ntime[0] = 1\\nans = 1\\nfor i in range(n):\\n    if time[list1[i]] == 1:\\n        time[i + 1] = 1\\n        time[list1[i]] = 0\\n    else:\\n        ans += 1\\n        time[i + 1] = 1\\nprint(ans)\", \"n = int(input())\\nnotes = [int(x) for x in input().split()]\\ngreatest_cave = 1\\nvisits = {0: 1}\\nfor time, curr in enumerate(notes, start=1):\\n    if curr in visits and visits[curr] != -1:\\n        visits[time] = visits[curr]\\n        visits[curr] = -1\\n    else:\\n        greatest_cave += 1\\n        visits[time] = greatest_cave\\nprint(greatest_cave)\\n\", \"N = int(input())\\ntexts = [0] * N\\ntexts = input().split()\\n\\nends=set()\\n#print(ends)\\n\\nends.add(0)\\n#print(ends)\\n\\nfor i in range(N):\\n    if int(texts[i]) in ends:\\n        ends.remove(int(texts[i]))\\n        #print('-'+texts[i],end=' ')\\n    ends.add(i+1)\\n    #print(ends)\\n\\nprint(len(ends))\\n\\n\", \"def main():\\n\\n    n = int(input())\\n\\n    a = [0]\\n    a += list(map(int, input().split()))\\n\\n    p = [0] * 200001\\n    p[1] = 0\\n    k = [-1] * 200001\\n    k[0] = 1\\n\\n    ans = 1\\n\\n    cnt = 1\\n\\n    for i in range(1, n + 1):\\n        if (i == 1):\\n            if (a[i] == 1):\\n                cnt += 1\\n                k[i] = cnt\\n                p[cnt] = i\\n                ans += 1\\n            else:\\n                k[i] = k[a[a[i]]]\\n                p[k[i]] = i\\n\\n        elif (p[k[a[i]]] != a[i]):\\n            cnt += 1\\n            k[i] = cnt\\n            p[cnt] = i\\n            ans += 1\\n        else:\\n            k[i] = k[a[i]]\\n            p[k[i]] = i\\n\\n    print(ans)\\n\\nmain()\\n        \\n\", \"n = int(input())\\ndata = list(map(int, input().split()))\\nd = [False] * (n + 4)\\nd[0] = True\\nres = 1\\nfor i in range(n):\\n    #print(d)\\n    if d[data[i]]:\\n        d[data[i]] = False\\n        d[i + 1] = True\\n    else:\\n        d[i + 1] = True\\n        res += 1\\n#print(d)\\nprint(res)\", \"n = int(input())\\nt = list(map(int, input().split()))\\ntcopy = t[::-1]\\ntbool = [False] * len(t)\\nans = 0\\nfor i in range(len(t)):\\n    if not tbool[len(t) - i - 1]:\\n        \\n        ans += 1\\n        j = len(t) - i - 1\\n        while not tbool[j]:\\n            tbool[j] = True\\n            j = t[j] - 1\\n            if j < 0:\\n                break\\n            \\n        \\n        tbool[len(t) - i - 1] = True\\nprint(ans)\\n\", \"n=int(input())\\nm=list(map(int,input().split(' ')))\\ns=set()\\ns.add(1)\\nfor i in range(1,len(m)):\\n    try:\\n        s.remove(m[i])\\n        s.add(i+1)\\n    except:\\n        s.add(i+1)\\nprint(len(s))\\n\", \"import fractions\\nimport math\\nn=int(input())\\n#a,b=map(int,input().split(' ')) \\n#n=list(map(int,input().split(' ')))\\nt=list(map(int,input().split(' ')))\\na=set(t)\\nprint(n+1-len(a))\\n\", \"i = int(input())\\nctc = [0] + list(map(int, input().split()))\\nnm = 1\\nptor = {0:1}\\nfor i in range(1, len(ctc)):\\n    if  ctc[i] in list(ptor.keys()):\\n        ptor[i] = ptor[ctc[i]]\\n        del(ptor[ctc[i]])\\n    else:\\n        nm+=1\\n        ptor[i] = nm\\nprint(nm)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmn=set()\\nmn.add(0)\\nk=1\\nfor i in range(n):\\n    if a[i] in mn:\\n        mn-={a[i]}\\n        mn.add(i+1)\\n    else:\\n        k+=1\\n        mn.add(i+1)\\nprint(k)\\n\"]",
        "difficulty": "interview",
        "input": "14\n0 0 1 1 2 2 3 3 4 4 5 5 6 6\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/886/C"
    },
    {
        "id": 1938,
        "task_id": 2057,
        "test_case_id": 8,
        "question": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number t_{i}:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. \n\nInitially, Petya was in one of the rooms at minute 0, he didn't write down number t_0.\n\nAt some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 2·10^5) — then number of notes in Petya's logbook.\n\nThe second line contains n non-negative integers t_1, t_2, ..., t_{n} (0 ≤ t_{i} < i) — notes in the logbook.\n\n\n-----Output-----\n\nIn the only line print a single integer — the minimum possible number of rooms in Paris catacombs.\n\n\n-----Examples-----\nInput\n2\n0 0\n\nOutput\n2\n\nInput\n5\n0 1 0 1 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.\n\nIn the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.",
        "solutions": "[\"n = int(input())\\n\\nmas = list(map(int, input().split()))\\n\\ndist = set([0])\\nres = 1\\nfor i, e in enumerate(mas):\\n    time = i + 1\\n    if e in dist:\\n        dist.remove(e)\\n    else:\\n        res += 1\\n    dist.add(time)\\nprint(res)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nnow_time = 1\\ncount_v = 1\\nlast_time = [0 for i in range(2 * 10**5 + 10)]\\nlast_time[0] = 1\\n\\nfor i in range(n):\\n    if last_time[a[i]] > 0:\\n        last_time[a[i]] -= 1\\n    else:\\n        count_v += 1\\n\\n    last_time[now_time] += 1\\n    now_time += 1\\n\\n\\nprint(count_v)\", \"n = int(input())\\nl = list(map(int, input().split()))\\na = [0 for i in range(200001)]\\nfor x in l:\\n  a[x] = 1\\n\\nfor i in range(1, 200001):\\n  n -= a[i]\\n  \\nprint(n)\", \"n = int(input())\\nl = list(map(int, input().split()))\\nd = {}\\ns = set()\\ns.add(0)\\nd[0] = 1\\nans = 1\\nfor i in range(n):\\n    if l[i] in s:\\n        d[i + 1] = d[l[i]]\\n        s.remove(l[i])\\n        s.add(i + 1)\\n    else:\\n        s.add(i + 1)\\n        ans += 1\\n        d[i + 1] = ans\\nprint(ans)\\n\", \"n = int(input())\\nminutesUsed = [0 for _ in range(n)]\\n\\ncount = 1\\nfor v in [int(k) for k in input().split(' ') if k]:\\n    if minutesUsed[v]:\\n        count += 1\\n    else:\\n        minutesUsed[v] = 1\\nprint(count)\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\nvis = [False] * n\\nans = 0\\nfor i in range(n):\\n    if a[i] == 0:\\n        ans += 1\\n        vis[0] = True\\n    elif vis[a[i]]:\\n        ans += 1\\n    else:\\n        vis[a[i]] = True\\nprint(ans)\", \"def main():\\n    n = int(input())\\n    times = list(map(int, input().split()))\\n    mntm = set()\\n    mntm.add(0)\\n    ans = 1\\n    for t in range(n):\\n        if times[t] in mntm:\\n            mntm.discard(times[t])\\n            mntm.add(t + 1)\\n        else:\\n            ans += 1\\n            mntm.add(t + 1)\\n    print(ans)\\n\\n\\nmain()\\n\", \"import sys\\ninput()\\nk=list(map(int,input().split()))\\nl=[]\\ns=[0 for i in range(200001)]\\nt=1\\nfor i in k:\\n    if s[i]==1:\\n        s[i]=0\\n    s[t]=1\\n    t+=1\\nprint(sum(s))\\n        \\n\", \"n, data = int(input()), list(map(int, input().split()))\\ntime = [0] + [-100] * (3 * (10 ** 5))\\nrooms = [0]\\nfor i in range(1, n + 1):\\n    if(time[data[i - 1]] != -100 and rooms[time[data[i - 1]]] == data[i - 1]):\\n        rooms[time[data[i - 1]]] = i\\n        time[i] = time[data[i - 1]]\\n    else:\\n        rooms.append(i)\\n        time[i] = len(rooms) - 1\\nprint(len(rooms))\", \"import sys;\\n\\n#sys.stdin = open(\\\"input.txt\\\", \\\"r\\\");\\n#sys.stdout = open(\\\"output.txt\\\", \\\"w\\\");\\n\\ndef ria():\\n    return [int(x) for x in input().split()];\\n\\n\\nn = int(input());\\na = ria();\\na = [0] + a;\\ntime = [-1] * (n+1);\\ntime[0] = 0;\\ntf = 0;\\n\\n\\nfor i in range(1,n+1,1):\\n    if time[a[i]] != -1:\\n        time[i] = time[a[i]];\\n        time[a[i]] = -1;\\n    else:\\n        tf += 1;\\n        time[i] = tf;\\n\\ntf += 1;\\n\\nprint(tf);\\n    \\n    \\n\\n\\n#sys.stdout.close();\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ntime = [-1] * (n + 1)\\ntime[0] = 1\\ncount = 1\\nfor i in range(n):\\n    cur_time = i + 1\\n    if time[a[i]] != -1:\\n        time[a[i]], time[cur_time] = -1, time[a[i]]\\n    else:\\n        count += 1\\n        time[cur_time] = count\\nprint(count)\", \"n = int(input())\\na = list(map(int, input().split()))\\ndi = {0 : 0}\\nk = 1\\nq = 1\\nfor i in a:\\n    if i in di:\\n        del di[i]\\n    else:\\n        q += 1\\n    di[k] = i\\n    k += 1\\nprint(q)\", \"n = int(input())\\nlist1 = list(map(int, input().split()))\\ntime = [0] * (n + 1)\\ntime[0] = 1\\nans = 1\\nfor i in range(n):\\n    if time[list1[i]] == 1:\\n        time[i + 1] = 1\\n        time[list1[i]] = 0\\n    else:\\n        ans += 1\\n        time[i + 1] = 1\\nprint(ans)\", \"n = int(input())\\nnotes = [int(x) for x in input().split()]\\ngreatest_cave = 1\\nvisits = {0: 1}\\nfor time, curr in enumerate(notes, start=1):\\n    if curr in visits and visits[curr] != -1:\\n        visits[time] = visits[curr]\\n        visits[curr] = -1\\n    else:\\n        greatest_cave += 1\\n        visits[time] = greatest_cave\\nprint(greatest_cave)\\n\", \"N = int(input())\\ntexts = [0] * N\\ntexts = input().split()\\n\\nends=set()\\n#print(ends)\\n\\nends.add(0)\\n#print(ends)\\n\\nfor i in range(N):\\n    if int(texts[i]) in ends:\\n        ends.remove(int(texts[i]))\\n        #print('-'+texts[i],end=' ')\\n    ends.add(i+1)\\n    #print(ends)\\n\\nprint(len(ends))\\n\\n\", \"def main():\\n\\n    n = int(input())\\n\\n    a = [0]\\n    a += list(map(int, input().split()))\\n\\n    p = [0] * 200001\\n    p[1] = 0\\n    k = [-1] * 200001\\n    k[0] = 1\\n\\n    ans = 1\\n\\n    cnt = 1\\n\\n    for i in range(1, n + 1):\\n        if (i == 1):\\n            if (a[i] == 1):\\n                cnt += 1\\n                k[i] = cnt\\n                p[cnt] = i\\n                ans += 1\\n            else:\\n                k[i] = k[a[a[i]]]\\n                p[k[i]] = i\\n\\n        elif (p[k[a[i]]] != a[i]):\\n            cnt += 1\\n            k[i] = cnt\\n            p[cnt] = i\\n            ans += 1\\n        else:\\n            k[i] = k[a[i]]\\n            p[k[i]] = i\\n\\n    print(ans)\\n\\nmain()\\n        \\n\", \"n = int(input())\\ndata = list(map(int, input().split()))\\nd = [False] * (n + 4)\\nd[0] = True\\nres = 1\\nfor i in range(n):\\n    #print(d)\\n    if d[data[i]]:\\n        d[data[i]] = False\\n        d[i + 1] = True\\n    else:\\n        d[i + 1] = True\\n        res += 1\\n#print(d)\\nprint(res)\", \"n = int(input())\\nt = list(map(int, input().split()))\\ntcopy = t[::-1]\\ntbool = [False] * len(t)\\nans = 0\\nfor i in range(len(t)):\\n    if not tbool[len(t) - i - 1]:\\n        \\n        ans += 1\\n        j = len(t) - i - 1\\n        while not tbool[j]:\\n            tbool[j] = True\\n            j = t[j] - 1\\n            if j < 0:\\n                break\\n            \\n        \\n        tbool[len(t) - i - 1] = True\\nprint(ans)\\n\", \"n=int(input())\\nm=list(map(int,input().split(' ')))\\ns=set()\\ns.add(1)\\nfor i in range(1,len(m)):\\n    try:\\n        s.remove(m[i])\\n        s.add(i+1)\\n    except:\\n        s.add(i+1)\\nprint(len(s))\\n\", \"import fractions\\nimport math\\nn=int(input())\\n#a,b=map(int,input().split(' ')) \\n#n=list(map(int,input().split(' ')))\\nt=list(map(int,input().split(' ')))\\na=set(t)\\nprint(n+1-len(a))\\n\", \"i = int(input())\\nctc = [0] + list(map(int, input().split()))\\nnm = 1\\nptor = {0:1}\\nfor i in range(1, len(ctc)):\\n    if  ctc[i] in list(ptor.keys()):\\n        ptor[i] = ptor[ctc[i]]\\n        del(ptor[ctc[i]])\\n    else:\\n        nm+=1\\n        ptor[i] = nm\\nprint(nm)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nmn=set()\\nmn.add(0)\\nk=1\\nfor i in range(n):\\n    if a[i] in mn:\\n        mn-={a[i]}\\n        mn.add(i+1)\\n    else:\\n        k+=1\\n        mn.add(i+1)\\nprint(k)\\n\"]",
        "difficulty": "interview",
        "input": "2\n0 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/886/C"
    },
    {
        "id": 1939,
        "task_id": 2086,
        "test_case_id": 1,
        "question": "In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time \"0 hours\", instead of it \"n hours\" is used. When local time in the 1-st timezone is 1 hour, local time in the i-th timezone is i hours.\n\nSome online programming contests platform wants to conduct a contest that lasts for an hour in such a way that its beginning coincides with beginning of some hour (in all time zones). The platform knows, that there are a_{i} people from i-th timezone who want to participate in the contest. Each person will participate if and only if the contest starts no earlier than s hours 00 minutes local time and ends not later than f hours 00 minutes local time. Values s and f are equal for all time zones. If the contest starts at f hours 00 minutes local time, the person won't participate in it.\n\nHelp platform select such an hour, that the number of people who will participate in the contest is maximum. \n\n\n-----Input-----\n\nThe first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of hours in day.\n\nThe second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10 000), where a_{i} is the number of people in the i-th timezone who want to participate in the contest.\n\nThe third line contains two space-separated integers s and f (1 ≤ s < f ≤ n).\n\n\n-----Output-----\n\nOutput a single integer — the time of the beginning of the contest (in the first timezone local time), such that the number of participants will be maximum possible. If there are many answers, output the smallest among them.\n\n\n-----Examples-----\nInput\n3\n1 2 3\n1 3\n\nOutput\n3\n\nInput\n5\n1 2 3 4 1\n1 3\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example, it's optimal to start competition at 3 hours (in first timezone). In this case, it will be 1 hour in the second timezone and 2 hours in the third timezone. Only one person from the first timezone won't participate.\n\nIn second example only people from the third and the fourth timezones will participate.",
        "solutions": "[\"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = [int(i) for i in input().split()]\\na = a + a\\nln = f - s\\nans = sum(a[:ln])\\nmx = ans\\nh = s\\nfor i in range(n - 1):\\n    ans = ans - a[i] + a[i + ln]\\n    if ans > mx:\\n        ans = mx\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n  \\n        h = k\\n    elif ans == mx:\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n    \\n        h = min(h, k)\\nprint(h)\\n\", \"import sys, math\\n\\n#f = open('input/input_1', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\na = list(map(int, f.readline().split()))\\nstart, end = list(map(int, f.readline().split()))\\n\\ntime_len = end-start\\nsum_p = 0\\nmax_sum = -1\\nmax_sum_end = 10000000\\nfor i in range(N*2):\\n  if i >= time_len:\\n    sum_p -= a[(i-time_len)%N]\\n  sum_p += a[i % N]\\n  ans = (2*N + end - i - 1) % N\\n  if ans == 0:\\n    ans = N\\n  if i >= time_len-1 and \\\\\\n    (max_sum < sum_p or (max_sum == sum_p and max_sum_end > ans)):\\n    max_sum = sum_p\\n    max_sum_end = ans\\n\\nprint(max_sum_end)\\n\\n'''\\n5\\n10 2 3 4 10\\n1 5\\n\\n1 2 3 4 5\\n4 5 1 2 3\\n'''\\n\", \"n = int(input())\\nL = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\ncount = 0\\ncount_max = 0\\nans = 0\\nfor i in range(s - 1, f - 1):\\n    count += L[i]\\nfor i in range(n):\\n    count -= L[f - 1]\\n    s -= 1\\n    f -= 1\\n    if s == -1:\\n        s = n - 1\\n    if f == -1:\\n        f = n - 1\\n    count += L[s]\\n    if count > count_max:\\n        count_max = count\\n        ans = i\\nprint(ans + 1) \\n\", \"R = lambda : map(int, input().split())\\n\\nn = int(input())\\na = list(R())\\ns,f = R()\\n\\nd = f-s\\n\\ndef solve(a,d,n,s):\\n    if (n < d + 1):\\n        return s\\n\\n    t = 0\\n    for i in range(0, d):\\n        t += a[i]\\n\\n    m = t\\n    res = s\\n    for i in range(1, n):\\n        t += a[(i + d - 1) % n] - a[i - 1]\\n        if t > m:\\n            m = t\\n            res = gr(i,s,n)\\n        elif t == m:\\n            res = min(res, gr(i,s,n))\\n    \\n    return res\\n    \\n\\ndef gr(i,s,n):\\n    res = (s-i) % n\\n    if (res <= 0):\\n        return n-res\\n    return res\\n\\nprint(solve(a,d,n,s))\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\ndef ps(l, i, j):\\n    if i > j:\\n        return l[-1]-l[i-1] + l[j]\\n    if i==0:\\n        return l[j]\\n    else:\\n        return l[j]-l[i-1]\\n\\nn =  int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\n\\nl = [a[0]]\\nfor i in a[1:]:\\n    l.append(l[-1]+i)\\nx = s-1\\ny = f-2\\nans = 0\\ntm = 0\\nfor i in range(n):\\n    temp = ps(l, x, y)\\n    if temp > ans:\\n        tm = i+1\\n        ans = temp \\n    x -= 1\\n    y -= 1\\n    if x < 0:\\n        x = n-1\\n    if y < 0:\\n        y = n-1\\nprint(tm)\", \"n = int(input())\\narr = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nnum = 0\\nfor i in range(s - 1, f - 1):\\n\\tnum += arr[i]\\n\\nt = 0\\ncurrent = num\\nfor time in range(n):\\n\\tcurrent = current - arr[(s - 1 + time) % n] + arr[(f - 1 + time) % n]\\n\\tif (current >= num):\\n\\t\\tnum = current\\n\\t\\tt = time\\n\\nprint(n - t)\\n\", \"# C\\n\\nimport copy\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nB = copy.deepcopy(A)\\nC = A + B  # A\\u3092\\u4e8c\\u3064\\u9023\\u7d50\\u3057\\u305f\\u30ea\\u30b9\\u30c8\\n\\nl = f - s\\nmax_list = []\\nmax_number = 0\\n\\nsumC = [0 for i in range(N)]\\n\\nsumC[0] = sum(C[0:l])\\nfor i in range(1, N):\\n    sumC[i] = sumC[i-1] + C[i+l-1] - C[i-1]\\n\\nfor i in range(N):\\n    if sumC[i] > max_number:\\n        max_list = [i]\\n        max_number = sumC[i]\\n    elif sumC[i] == max_number:\\n        max_list.append(i)\\n\\nans_list = []\\nfor j in max_list:\\n    for i in range(N):\\n        if j + i < N:\\n            if s + i <= N:\\n                A[j + i] = s + i\\n            else:\\n                A[j + i] = s + i - N\\n        else:\\n            if s + i <= N:\\n                A[j + i - N] = s + i\\n            else:\\n                A[j + i - N] = s + i - N\\n    ans_list.append(A[0])\\n\\nprint(min(ans_list))\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 2\\npref = [0] * n\\npref[0] = a[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + a[i]\\nmx = -1\\nans = 0\\nfor hour in range(n):\\n\\tleft = s - hour\\n\\tright = f - hour\\n\\tif left < 0:\\n\\t\\tleft += n\\n\\tif right < 0:\\n\\t\\tright += n\\n\\tres = -1\\n\\tif left <= right:\\n\\t\\tres = pref[right] - (pref[left - 1] if left > 0 else 0)\\n\\telse:\\n\\t\\tres = pref[n - 1] - (pref[left - 1] if left > 0 else 0) + pref[right]\\n\\tif res > mx:\\n\\t\\tmx = res\\n\\t\\tans = hour + 1\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nd = f-s\\nmsum = 0\\nminx = 10**6\\ntemp = a+a[:d+1]\\nsumt=0\\n\\nfor x in range(n + d + 1):\\n    sumt+=temp[x]\\n    if (x >= d):\\n        sumt-= temp[x-d]\\n    #print(sumt, (n - x + s + d- 2)%n + 1, x)\\n    if (sumt > msum):\\n        minx = 10**6\\n        msum = sumt\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\n    elif (sumt == msum):\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\nprint(minx)\\n\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\ns, f = list(map(int, input().split()))\\n\\ns -= 1\\nf -= 1\\n\\nm = int(1e+9)\\n\\nbest_sum = sum(A[s: f + 1])\\ncur_sum = best_sum\\nbest_i = 0\\n\\nfor i in range(1, n):\\n    cur_sum += A[(s - i + n) % n]\\n    cur_sum -= A[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\n\\nprint(best_i + 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f + 1])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\na = [0]\\nb =input().split()\\na = a+b\\nans  = 0\\nm = 0\\nfor i in range(1,n+1):\\n    a[i] = int(a[i])\\ns,f = input().split()\\ns = int(s)\\nf = int(f)\\nfor i in range(s,f):\\n    m+=a[i]\\nma = m\\nans = 1\\nstart = s-1\\ncount = f-1\\nif count<1:\\n    count = n\\nif start<1:\\n    start = n\\nfor i in range(2,n+1):\\n    m = m-a[count] + a[start]\\n    count = count-1\\n    start = start - 1\\n    if count==0:\\n        count = n\\n    if start==0:\\n        start = start=n\\n    if m>ma:\\n        ma = m\\n        ans = i\\nprint(ans) \", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\nA = [int(x) for x in input().split()]\\nA = A+A\\ns,f = list(map(int,input().split()))\\n\\nl = f-s\\nS = sum(A[:l])\\nmi = 0\\nmS = S\\nans = (s-1-mi)%n + 1\\nfor i in range(n-1):\\n    S = S + A[i+l] - A[i] \\n    if mS == S:\\n        mi = i+1\\n        ans = min(ans, (s-1-mi)%n + 1) # Update min\\n    if mS < S:\\n        mS = S\\n        mi = i+1\\n        ans = (s-1-mi)%n + 1 # Set min\\nprint(ans)\\n\", \"#import sys\\n#sys.stdin = open ('464-C.in', 'r')\\n\\nn = int(input())\\nn = n*2\\na = list(map(int,input().split()))\\na = a+a\\ns, f = list(map(int, input().split()))\\nsum = [0 for i in range(n+1)]\\nfor i in range(1,n+1):\\n    sum[i] = sum[i-1]+a[i-1]\\nran = f-s\\nmsum, idx = 0, 0\\nbb = int(1e18)\\nfor i in range(ran,n+1):\\n   # print (i, \\\" = \\\", sum[i]-sum[i-ran])\\n    if sum[i]-sum[i-ran] > msum:\\n        msum = sum[i] - sum[i - ran]\\n        idx = i-ran+1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        bb = idx\\n    elif sum[i]-sum[i-ran] == msum:\\n        idx = i - ran + 1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        if idx < bb:\\n            bb = idx\\n            msum = sum[i] - sum[i - ran]\\n\\n\\n#print (msum, \\\" \\\", idx)\\n\\nprint (bb)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns,f = [int(x) for x in input().split()]\\nzones = f-s\\ncurrans = 1\\ncurrmax = sum(a[s-1 : f-2])\\nans=1\\nmaxppl = currmax\\nfst = s-1\\nlst = f-2\\nfor currans in range(2, n+1):\\n    currmax += a[fst-1 if fst > 0 else n-1]\\n    currmax -= a[lst]\\n    fst = fst-1 if fst > 0 else n-1\\n    lst = lst - 1 if lst > 0 else n - 1\\n    if currmax > maxppl:\\n        maxppl = currmax\\n        ans = currans\\nprint(ans)\\n\", \"n=int(input())\\na=[int(i) for i in input().split()]\\ns,f=(int(i) for i in input().split())\\npref=[a[0]]\\nfor i in range(1,n):\\n\\tpref.append(a[i]+pref[i-1])\\n\\t\\ndef nb_people(strt, end):\\n\\tif strt<=end:\\n\\t\\tif strt==0:\\n\\t\\t\\treturn pref[end]\\n\\t\\telse:\\n\\t\\t\\treturn pref[end]-pref[strt-1]\\n\\telse:\\n\\t\\tret = pref[end]+pref[n-1]\\n\\t\\tif strt>0:\\n\\t\\t\\tret-=pref[strt-1]\\n\\t\\treturn ret\\n\\t\\nmax_people=0\\nopt_h=0\\nfor h in range(1,n+1):\\n\\tstrt=s-h+1#\\u00e0 h heures ds le 1er fuseau o\\u00f9 est - il s heures ?\\n\\tif strt<=0:\\n\\t\\tstrt+=n\\n\\tend =f-h#pareil avec f-1\\n\\tif end<=0:\\n\\t\\tend+=n\\n\\ttmp_people = nb_people(strt-1, end-1)\\n\\t#print(\\\"h\\\",h,\\\"strt\\\", strt, \\\"end\\\", end,\\\"tmp_people\\\",tmp_people)\\n\\tif tmp_people>max_people:\\n\\t\\tmax_people=tmp_people\\n\\t\\topt_h = h\\nprint(opt_h)\\n\", \"from sys import stdin as si\\nfrom collections import Counter as c\\n\\n\\nclass Solution:\\n\\n    def bazinga(self, n,m, k):\\n        mnp = sum(m[k[0]-1:k[1]-1])    # min number of participants\\n        diff = k[1]-k[0]\\n        mxp,ans = mnp, 0              # maximizing participants\\n        for i in range(1,n):\\n            # print (i,diff, mxp,mnp, sum(m[i: diff+i]))\\n            mxp +=  m[(k[0]-i-1 + n) % n]\\n            mxp -= m[(k[1]-i-1 + n) % n]\\n            if mxp > mnp:\\n                mnp,ans = mxp, i\\n        return ans +1\\n\\n\\ndef __starting_point():\\n    #for i in range(int(si.readline().strip())):\\n    n = int(si.readline().strip())\\n    m = list(map(int, si.readline().strip().split()))\\n    k = tuple(map(int, si.readline().strip().split()))\\n    S = Solution()\\n    print(S.bazinga(n, m, k))\\n\\n\\n\\n'''\\nhttp://codeforces.com/contest/939/problem/C\\n'''\\n__starting_point()\", \"n = int(input())\\na = [0] + list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nw = f - s\\nmax_s = cur_s = sum(a[s:f])\\nmax_h = cur_h = s\\n\\nfor i in range(2, n+1):\\n\\tcur_h -= 1\\n\\tif cur_h == 0: \\n\\t\\tcur_h = n\\n\\tj = i + w - 1\\n\\tif j > n:\\n\\t\\tj -= n\\n\\tcur_s = cur_s - a[i-1] + a[j]\\n\\tif (cur_s > max_s) or (cur_s == max_s and cur_h < max_h):\\n\\t\\tmax_s = cur_s\\n\\t\\tmax_h = cur_h\\n\\t\\t\\nprint(max_h)\\n\\t\\n\\t\\n\", \"def main():\\n    n = int(input())\\n\\n    a = [int(x) for x in input().split()]\\n    a += a\\n\\n    s, f = [int(x) for x in input().split()]\\n\\n    dp = [0 for _ in range(2 * n + 1)]\\n    for i in range(2 * n):\\n        dp[i + 1] = dp[i] + a[i]\\n\\n    ans, sum = 0, 0\\n\\n    for i in range(n):\\n        cur_sum = dp[f + n - i - 1] - dp[s + n - i - 1]\\n\\n        if cur_sum > sum:\\n            ans = i\\n            sum = cur_sum\\n\\n    ans += 1\\n    print(ans)        \\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nps = [ int(a) for a in input().split() ]\\ns,f = [ int(a) for a in input().split() ]\\n\\nwindow = f-s\\nps += ps[:window]\\n\\ndef f(x):\\n    return (s-1-x)%n + 1\\n\\nanswers = []\\nc = m = sum(ps[:window])\\nfor i in range(n):\\n    if c > m:\\n        answers = [f(i)]\\n        m = c\\n    elif c == m:\\n        answers += [f(i)]\\n    c += ps[i+window]-ps[i]\\n\\nprint(min(answers))\", \"h = int(input())\\nppl = [int(x) for x in input().split()]\\nsl = [int(x) for x in input().split()]\\nn = sl[1] - sl[0] if sl[1] > sl[0] else sl[1] - sl[0] + h\\nm = 0\\nindex = 0\\ntemp = sum(ppl[0:n])\\nans = []\\nfor i in range(h):\\n    if m < temp:\\n        m = temp \\n        ans.clear()\\n        ans.append(i)\\n    elif m == temp:\\n        ans.append(i)\\n    temp -= ppl[i]\\n    temp += ppl[(i+n) % h]\\nres = [(sl[0] + h - index - 1) % h + 1  for index in ans]\\n# print(n)\\n# print(m)\\nprint(min(res))\\n\\n    \\n\", \"# Q.C\\nn = int(input())\\na = input().split(\\\" \\\")\\na = list(map(int,a))\\ns,f = list(map(int, input().split(\\\" \\\")))\\na.insert(0,0)\\n\\nx = 1\\nxm = x\\nli = s-x+1\\nri = f-x\\ntotalm = sum(a[i] for i in range(li,ri+1))\\ntotal = totalm\\n\\nfor x in range(2, n+1):\\n    li -= 1\\n    if li == 0:\\n        li = n\\n    total += a[li]\\n    total -= a[ri]\\n    ri -= 1\\n    if ri == 0:\\n        ri = n\\n    if total > totalm:\\n        totalm = total\\n        xm = x\\nprint(xm)\", \"n = int(input())\\n\\ninp = input().split(\\\" \\\")\\n\\npeople = []\\nfor i in range(n):\\n\\tpeople.append(int(inp[i]))\\n\\ninp = input().split(\\\" \\\")\\nstart = int(inp[0])\\nend = int(inp[1])\\ndiff = end - start\\n\\noptimal = 1\\npeople = people + people\\nm = sum(people[0: diff])\\nprev_sum = m\\n\\nfor i in range(1, n):\\n\\toffset = min(diff, n - i)\\n\\tprev_sum -= people[i - 1]\\n\\tprev_sum += people[i + diff - 1]\\n\\n\\tif prev_sum > m:\\n\\t\\tm = prev_sum\\n\\t\\toptimal = i + diff\\n\\t\\toptimal = (end - optimal) % n\\n\\t\\tif optimal == 0:\\n\\t\\t\\toptimal = n\\n\\t\\t\\t\\n\\tif prev_sum == m:\\n\\t\\toptimal2 = i + diff\\n\\t\\toptimal2 = (end - optimal2) % n\\n\\t\\tif optimal2 == 0:\\n\\t\\t\\toptimal2 = n\\n\\n\\t\\tif optimal2 < optimal:\\n\\t\\t\\toptimal = optimal2\\n\\nif m == 0:\\n\\toptimal = 1\\n\\nprint(optimal)\\n\"]",
        "difficulty": "interview",
        "input": "3\n1 2 3\n1 3\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/939/C"
    },
    {
        "id": 1940,
        "task_id": 2086,
        "test_case_id": 2,
        "question": "In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time \"0 hours\", instead of it \"n hours\" is used. When local time in the 1-st timezone is 1 hour, local time in the i-th timezone is i hours.\n\nSome online programming contests platform wants to conduct a contest that lasts for an hour in such a way that its beginning coincides with beginning of some hour (in all time zones). The platform knows, that there are a_{i} people from i-th timezone who want to participate in the contest. Each person will participate if and only if the contest starts no earlier than s hours 00 minutes local time and ends not later than f hours 00 minutes local time. Values s and f are equal for all time zones. If the contest starts at f hours 00 minutes local time, the person won't participate in it.\n\nHelp platform select such an hour, that the number of people who will participate in the contest is maximum. \n\n\n-----Input-----\n\nThe first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of hours in day.\n\nThe second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10 000), where a_{i} is the number of people in the i-th timezone who want to participate in the contest.\n\nThe third line contains two space-separated integers s and f (1 ≤ s < f ≤ n).\n\n\n-----Output-----\n\nOutput a single integer — the time of the beginning of the contest (in the first timezone local time), such that the number of participants will be maximum possible. If there are many answers, output the smallest among them.\n\n\n-----Examples-----\nInput\n3\n1 2 3\n1 3\n\nOutput\n3\n\nInput\n5\n1 2 3 4 1\n1 3\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example, it's optimal to start competition at 3 hours (in first timezone). In this case, it will be 1 hour in the second timezone and 2 hours in the third timezone. Only one person from the first timezone won't participate.\n\nIn second example only people from the third and the fourth timezones will participate.",
        "solutions": "[\"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = [int(i) for i in input().split()]\\na = a + a\\nln = f - s\\nans = sum(a[:ln])\\nmx = ans\\nh = s\\nfor i in range(n - 1):\\n    ans = ans - a[i] + a[i + ln]\\n    if ans > mx:\\n        ans = mx\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n  \\n        h = k\\n    elif ans == mx:\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n    \\n        h = min(h, k)\\nprint(h)\\n\", \"import sys, math\\n\\n#f = open('input/input_1', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\na = list(map(int, f.readline().split()))\\nstart, end = list(map(int, f.readline().split()))\\n\\ntime_len = end-start\\nsum_p = 0\\nmax_sum = -1\\nmax_sum_end = 10000000\\nfor i in range(N*2):\\n  if i >= time_len:\\n    sum_p -= a[(i-time_len)%N]\\n  sum_p += a[i % N]\\n  ans = (2*N + end - i - 1) % N\\n  if ans == 0:\\n    ans = N\\n  if i >= time_len-1 and \\\\\\n    (max_sum < sum_p or (max_sum == sum_p and max_sum_end > ans)):\\n    max_sum = sum_p\\n    max_sum_end = ans\\n\\nprint(max_sum_end)\\n\\n'''\\n5\\n10 2 3 4 10\\n1 5\\n\\n1 2 3 4 5\\n4 5 1 2 3\\n'''\\n\", \"n = int(input())\\nL = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\ncount = 0\\ncount_max = 0\\nans = 0\\nfor i in range(s - 1, f - 1):\\n    count += L[i]\\nfor i in range(n):\\n    count -= L[f - 1]\\n    s -= 1\\n    f -= 1\\n    if s == -1:\\n        s = n - 1\\n    if f == -1:\\n        f = n - 1\\n    count += L[s]\\n    if count > count_max:\\n        count_max = count\\n        ans = i\\nprint(ans + 1) \\n\", \"R = lambda : map(int, input().split())\\n\\nn = int(input())\\na = list(R())\\ns,f = R()\\n\\nd = f-s\\n\\ndef solve(a,d,n,s):\\n    if (n < d + 1):\\n        return s\\n\\n    t = 0\\n    for i in range(0, d):\\n        t += a[i]\\n\\n    m = t\\n    res = s\\n    for i in range(1, n):\\n        t += a[(i + d - 1) % n] - a[i - 1]\\n        if t > m:\\n            m = t\\n            res = gr(i,s,n)\\n        elif t == m:\\n            res = min(res, gr(i,s,n))\\n    \\n    return res\\n    \\n\\ndef gr(i,s,n):\\n    res = (s-i) % n\\n    if (res <= 0):\\n        return n-res\\n    return res\\n\\nprint(solve(a,d,n,s))\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\ndef ps(l, i, j):\\n    if i > j:\\n        return l[-1]-l[i-1] + l[j]\\n    if i==0:\\n        return l[j]\\n    else:\\n        return l[j]-l[i-1]\\n\\nn =  int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\n\\nl = [a[0]]\\nfor i in a[1:]:\\n    l.append(l[-1]+i)\\nx = s-1\\ny = f-2\\nans = 0\\ntm = 0\\nfor i in range(n):\\n    temp = ps(l, x, y)\\n    if temp > ans:\\n        tm = i+1\\n        ans = temp \\n    x -= 1\\n    y -= 1\\n    if x < 0:\\n        x = n-1\\n    if y < 0:\\n        y = n-1\\nprint(tm)\", \"n = int(input())\\narr = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nnum = 0\\nfor i in range(s - 1, f - 1):\\n\\tnum += arr[i]\\n\\nt = 0\\ncurrent = num\\nfor time in range(n):\\n\\tcurrent = current - arr[(s - 1 + time) % n] + arr[(f - 1 + time) % n]\\n\\tif (current >= num):\\n\\t\\tnum = current\\n\\t\\tt = time\\n\\nprint(n - t)\\n\", \"# C\\n\\nimport copy\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nB = copy.deepcopy(A)\\nC = A + B  # A\\u3092\\u4e8c\\u3064\\u9023\\u7d50\\u3057\\u305f\\u30ea\\u30b9\\u30c8\\n\\nl = f - s\\nmax_list = []\\nmax_number = 0\\n\\nsumC = [0 for i in range(N)]\\n\\nsumC[0] = sum(C[0:l])\\nfor i in range(1, N):\\n    sumC[i] = sumC[i-1] + C[i+l-1] - C[i-1]\\n\\nfor i in range(N):\\n    if sumC[i] > max_number:\\n        max_list = [i]\\n        max_number = sumC[i]\\n    elif sumC[i] == max_number:\\n        max_list.append(i)\\n\\nans_list = []\\nfor j in max_list:\\n    for i in range(N):\\n        if j + i < N:\\n            if s + i <= N:\\n                A[j + i] = s + i\\n            else:\\n                A[j + i] = s + i - N\\n        else:\\n            if s + i <= N:\\n                A[j + i - N] = s + i\\n            else:\\n                A[j + i - N] = s + i - N\\n    ans_list.append(A[0])\\n\\nprint(min(ans_list))\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 2\\npref = [0] * n\\npref[0] = a[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + a[i]\\nmx = -1\\nans = 0\\nfor hour in range(n):\\n\\tleft = s - hour\\n\\tright = f - hour\\n\\tif left < 0:\\n\\t\\tleft += n\\n\\tif right < 0:\\n\\t\\tright += n\\n\\tres = -1\\n\\tif left <= right:\\n\\t\\tres = pref[right] - (pref[left - 1] if left > 0 else 0)\\n\\telse:\\n\\t\\tres = pref[n - 1] - (pref[left - 1] if left > 0 else 0) + pref[right]\\n\\tif res > mx:\\n\\t\\tmx = res\\n\\t\\tans = hour + 1\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nd = f-s\\nmsum = 0\\nminx = 10**6\\ntemp = a+a[:d+1]\\nsumt=0\\n\\nfor x in range(n + d + 1):\\n    sumt+=temp[x]\\n    if (x >= d):\\n        sumt-= temp[x-d]\\n    #print(sumt, (n - x + s + d- 2)%n + 1, x)\\n    if (sumt > msum):\\n        minx = 10**6\\n        msum = sumt\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\n    elif (sumt == msum):\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\nprint(minx)\\n\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\ns, f = list(map(int, input().split()))\\n\\ns -= 1\\nf -= 1\\n\\nm = int(1e+9)\\n\\nbest_sum = sum(A[s: f + 1])\\ncur_sum = best_sum\\nbest_i = 0\\n\\nfor i in range(1, n):\\n    cur_sum += A[(s - i + n) % n]\\n    cur_sum -= A[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\n\\nprint(best_i + 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f + 1])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\na = [0]\\nb =input().split()\\na = a+b\\nans  = 0\\nm = 0\\nfor i in range(1,n+1):\\n    a[i] = int(a[i])\\ns,f = input().split()\\ns = int(s)\\nf = int(f)\\nfor i in range(s,f):\\n    m+=a[i]\\nma = m\\nans = 1\\nstart = s-1\\ncount = f-1\\nif count<1:\\n    count = n\\nif start<1:\\n    start = n\\nfor i in range(2,n+1):\\n    m = m-a[count] + a[start]\\n    count = count-1\\n    start = start - 1\\n    if count==0:\\n        count = n\\n    if start==0:\\n        start = start=n\\n    if m>ma:\\n        ma = m\\n        ans = i\\nprint(ans) \", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\nA = [int(x) for x in input().split()]\\nA = A+A\\ns,f = list(map(int,input().split()))\\n\\nl = f-s\\nS = sum(A[:l])\\nmi = 0\\nmS = S\\nans = (s-1-mi)%n + 1\\nfor i in range(n-1):\\n    S = S + A[i+l] - A[i] \\n    if mS == S:\\n        mi = i+1\\n        ans = min(ans, (s-1-mi)%n + 1) # Update min\\n    if mS < S:\\n        mS = S\\n        mi = i+1\\n        ans = (s-1-mi)%n + 1 # Set min\\nprint(ans)\\n\", \"#import sys\\n#sys.stdin = open ('464-C.in', 'r')\\n\\nn = int(input())\\nn = n*2\\na = list(map(int,input().split()))\\na = a+a\\ns, f = list(map(int, input().split()))\\nsum = [0 for i in range(n+1)]\\nfor i in range(1,n+1):\\n    sum[i] = sum[i-1]+a[i-1]\\nran = f-s\\nmsum, idx = 0, 0\\nbb = int(1e18)\\nfor i in range(ran,n+1):\\n   # print (i, \\\" = \\\", sum[i]-sum[i-ran])\\n    if sum[i]-sum[i-ran] > msum:\\n        msum = sum[i] - sum[i - ran]\\n        idx = i-ran+1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        bb = idx\\n    elif sum[i]-sum[i-ran] == msum:\\n        idx = i - ran + 1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        if idx < bb:\\n            bb = idx\\n            msum = sum[i] - sum[i - ran]\\n\\n\\n#print (msum, \\\" \\\", idx)\\n\\nprint (bb)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns,f = [int(x) for x in input().split()]\\nzones = f-s\\ncurrans = 1\\ncurrmax = sum(a[s-1 : f-2])\\nans=1\\nmaxppl = currmax\\nfst = s-1\\nlst = f-2\\nfor currans in range(2, n+1):\\n    currmax += a[fst-1 if fst > 0 else n-1]\\n    currmax -= a[lst]\\n    fst = fst-1 if fst > 0 else n-1\\n    lst = lst - 1 if lst > 0 else n - 1\\n    if currmax > maxppl:\\n        maxppl = currmax\\n        ans = currans\\nprint(ans)\\n\", \"n=int(input())\\na=[int(i) for i in input().split()]\\ns,f=(int(i) for i in input().split())\\npref=[a[0]]\\nfor i in range(1,n):\\n\\tpref.append(a[i]+pref[i-1])\\n\\t\\ndef nb_people(strt, end):\\n\\tif strt<=end:\\n\\t\\tif strt==0:\\n\\t\\t\\treturn pref[end]\\n\\t\\telse:\\n\\t\\t\\treturn pref[end]-pref[strt-1]\\n\\telse:\\n\\t\\tret = pref[end]+pref[n-1]\\n\\t\\tif strt>0:\\n\\t\\t\\tret-=pref[strt-1]\\n\\t\\treturn ret\\n\\t\\nmax_people=0\\nopt_h=0\\nfor h in range(1,n+1):\\n\\tstrt=s-h+1#\\u00e0 h heures ds le 1er fuseau o\\u00f9 est - il s heures ?\\n\\tif strt<=0:\\n\\t\\tstrt+=n\\n\\tend =f-h#pareil avec f-1\\n\\tif end<=0:\\n\\t\\tend+=n\\n\\ttmp_people = nb_people(strt-1, end-1)\\n\\t#print(\\\"h\\\",h,\\\"strt\\\", strt, \\\"end\\\", end,\\\"tmp_people\\\",tmp_people)\\n\\tif tmp_people>max_people:\\n\\t\\tmax_people=tmp_people\\n\\t\\topt_h = h\\nprint(opt_h)\\n\", \"from sys import stdin as si\\nfrom collections import Counter as c\\n\\n\\nclass Solution:\\n\\n    def bazinga(self, n,m, k):\\n        mnp = sum(m[k[0]-1:k[1]-1])    # min number of participants\\n        diff = k[1]-k[0]\\n        mxp,ans = mnp, 0              # maximizing participants\\n        for i in range(1,n):\\n            # print (i,diff, mxp,mnp, sum(m[i: diff+i]))\\n            mxp +=  m[(k[0]-i-1 + n) % n]\\n            mxp -= m[(k[1]-i-1 + n) % n]\\n            if mxp > mnp:\\n                mnp,ans = mxp, i\\n        return ans +1\\n\\n\\ndef __starting_point():\\n    #for i in range(int(si.readline().strip())):\\n    n = int(si.readline().strip())\\n    m = list(map(int, si.readline().strip().split()))\\n    k = tuple(map(int, si.readline().strip().split()))\\n    S = Solution()\\n    print(S.bazinga(n, m, k))\\n\\n\\n\\n'''\\nhttp://codeforces.com/contest/939/problem/C\\n'''\\n__starting_point()\", \"n = int(input())\\na = [0] + list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nw = f - s\\nmax_s = cur_s = sum(a[s:f])\\nmax_h = cur_h = s\\n\\nfor i in range(2, n+1):\\n\\tcur_h -= 1\\n\\tif cur_h == 0: \\n\\t\\tcur_h = n\\n\\tj = i + w - 1\\n\\tif j > n:\\n\\t\\tj -= n\\n\\tcur_s = cur_s - a[i-1] + a[j]\\n\\tif (cur_s > max_s) or (cur_s == max_s and cur_h < max_h):\\n\\t\\tmax_s = cur_s\\n\\t\\tmax_h = cur_h\\n\\t\\t\\nprint(max_h)\\n\\t\\n\\t\\n\", \"def main():\\n    n = int(input())\\n\\n    a = [int(x) for x in input().split()]\\n    a += a\\n\\n    s, f = [int(x) for x in input().split()]\\n\\n    dp = [0 for _ in range(2 * n + 1)]\\n    for i in range(2 * n):\\n        dp[i + 1] = dp[i] + a[i]\\n\\n    ans, sum = 0, 0\\n\\n    for i in range(n):\\n        cur_sum = dp[f + n - i - 1] - dp[s + n - i - 1]\\n\\n        if cur_sum > sum:\\n            ans = i\\n            sum = cur_sum\\n\\n    ans += 1\\n    print(ans)        \\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nps = [ int(a) for a in input().split() ]\\ns,f = [ int(a) for a in input().split() ]\\n\\nwindow = f-s\\nps += ps[:window]\\n\\ndef f(x):\\n    return (s-1-x)%n + 1\\n\\nanswers = []\\nc = m = sum(ps[:window])\\nfor i in range(n):\\n    if c > m:\\n        answers = [f(i)]\\n        m = c\\n    elif c == m:\\n        answers += [f(i)]\\n    c += ps[i+window]-ps[i]\\n\\nprint(min(answers))\", \"h = int(input())\\nppl = [int(x) for x in input().split()]\\nsl = [int(x) for x in input().split()]\\nn = sl[1] - sl[0] if sl[1] > sl[0] else sl[1] - sl[0] + h\\nm = 0\\nindex = 0\\ntemp = sum(ppl[0:n])\\nans = []\\nfor i in range(h):\\n    if m < temp:\\n        m = temp \\n        ans.clear()\\n        ans.append(i)\\n    elif m == temp:\\n        ans.append(i)\\n    temp -= ppl[i]\\n    temp += ppl[(i+n) % h]\\nres = [(sl[0] + h - index - 1) % h + 1  for index in ans]\\n# print(n)\\n# print(m)\\nprint(min(res))\\n\\n    \\n\", \"# Q.C\\nn = int(input())\\na = input().split(\\\" \\\")\\na = list(map(int,a))\\ns,f = list(map(int, input().split(\\\" \\\")))\\na.insert(0,0)\\n\\nx = 1\\nxm = x\\nli = s-x+1\\nri = f-x\\ntotalm = sum(a[i] for i in range(li,ri+1))\\ntotal = totalm\\n\\nfor x in range(2, n+1):\\n    li -= 1\\n    if li == 0:\\n        li = n\\n    total += a[li]\\n    total -= a[ri]\\n    ri -= 1\\n    if ri == 0:\\n        ri = n\\n    if total > totalm:\\n        totalm = total\\n        xm = x\\nprint(xm)\", \"n = int(input())\\n\\ninp = input().split(\\\" \\\")\\n\\npeople = []\\nfor i in range(n):\\n\\tpeople.append(int(inp[i]))\\n\\ninp = input().split(\\\" \\\")\\nstart = int(inp[0])\\nend = int(inp[1])\\ndiff = end - start\\n\\noptimal = 1\\npeople = people + people\\nm = sum(people[0: diff])\\nprev_sum = m\\n\\nfor i in range(1, n):\\n\\toffset = min(diff, n - i)\\n\\tprev_sum -= people[i - 1]\\n\\tprev_sum += people[i + diff - 1]\\n\\n\\tif prev_sum > m:\\n\\t\\tm = prev_sum\\n\\t\\toptimal = i + diff\\n\\t\\toptimal = (end - optimal) % n\\n\\t\\tif optimal == 0:\\n\\t\\t\\toptimal = n\\n\\t\\t\\t\\n\\tif prev_sum == m:\\n\\t\\toptimal2 = i + diff\\n\\t\\toptimal2 = (end - optimal2) % n\\n\\t\\tif optimal2 == 0:\\n\\t\\t\\toptimal2 = n\\n\\n\\t\\tif optimal2 < optimal:\\n\\t\\t\\toptimal = optimal2\\n\\nif m == 0:\\n\\toptimal = 1\\n\\nprint(optimal)\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 2 3 4 1\n1 3\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/939/C"
    },
    {
        "id": 1941,
        "task_id": 2086,
        "test_case_id": 3,
        "question": "In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time \"0 hours\", instead of it \"n hours\" is used. When local time in the 1-st timezone is 1 hour, local time in the i-th timezone is i hours.\n\nSome online programming contests platform wants to conduct a contest that lasts for an hour in such a way that its beginning coincides with beginning of some hour (in all time zones). The platform knows, that there are a_{i} people from i-th timezone who want to participate in the contest. Each person will participate if and only if the contest starts no earlier than s hours 00 minutes local time and ends not later than f hours 00 minutes local time. Values s and f are equal for all time zones. If the contest starts at f hours 00 minutes local time, the person won't participate in it.\n\nHelp platform select such an hour, that the number of people who will participate in the contest is maximum. \n\n\n-----Input-----\n\nThe first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of hours in day.\n\nThe second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10 000), where a_{i} is the number of people in the i-th timezone who want to participate in the contest.\n\nThe third line contains two space-separated integers s and f (1 ≤ s < f ≤ n).\n\n\n-----Output-----\n\nOutput a single integer — the time of the beginning of the contest (in the first timezone local time), such that the number of participants will be maximum possible. If there are many answers, output the smallest among them.\n\n\n-----Examples-----\nInput\n3\n1 2 3\n1 3\n\nOutput\n3\n\nInput\n5\n1 2 3 4 1\n1 3\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example, it's optimal to start competition at 3 hours (in first timezone). In this case, it will be 1 hour in the second timezone and 2 hours in the third timezone. Only one person from the first timezone won't participate.\n\nIn second example only people from the third and the fourth timezones will participate.",
        "solutions": "[\"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = [int(i) for i in input().split()]\\na = a + a\\nln = f - s\\nans = sum(a[:ln])\\nmx = ans\\nh = s\\nfor i in range(n - 1):\\n    ans = ans - a[i] + a[i + ln]\\n    if ans > mx:\\n        ans = mx\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n  \\n        h = k\\n    elif ans == mx:\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n    \\n        h = min(h, k)\\nprint(h)\\n\", \"import sys, math\\n\\n#f = open('input/input_1', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\na = list(map(int, f.readline().split()))\\nstart, end = list(map(int, f.readline().split()))\\n\\ntime_len = end-start\\nsum_p = 0\\nmax_sum = -1\\nmax_sum_end = 10000000\\nfor i in range(N*2):\\n  if i >= time_len:\\n    sum_p -= a[(i-time_len)%N]\\n  sum_p += a[i % N]\\n  ans = (2*N + end - i - 1) % N\\n  if ans == 0:\\n    ans = N\\n  if i >= time_len-1 and \\\\\\n    (max_sum < sum_p or (max_sum == sum_p and max_sum_end > ans)):\\n    max_sum = sum_p\\n    max_sum_end = ans\\n\\nprint(max_sum_end)\\n\\n'''\\n5\\n10 2 3 4 10\\n1 5\\n\\n1 2 3 4 5\\n4 5 1 2 3\\n'''\\n\", \"n = int(input())\\nL = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\ncount = 0\\ncount_max = 0\\nans = 0\\nfor i in range(s - 1, f - 1):\\n    count += L[i]\\nfor i in range(n):\\n    count -= L[f - 1]\\n    s -= 1\\n    f -= 1\\n    if s == -1:\\n        s = n - 1\\n    if f == -1:\\n        f = n - 1\\n    count += L[s]\\n    if count > count_max:\\n        count_max = count\\n        ans = i\\nprint(ans + 1) \\n\", \"R = lambda : map(int, input().split())\\n\\nn = int(input())\\na = list(R())\\ns,f = R()\\n\\nd = f-s\\n\\ndef solve(a,d,n,s):\\n    if (n < d + 1):\\n        return s\\n\\n    t = 0\\n    for i in range(0, d):\\n        t += a[i]\\n\\n    m = t\\n    res = s\\n    for i in range(1, n):\\n        t += a[(i + d - 1) % n] - a[i - 1]\\n        if t > m:\\n            m = t\\n            res = gr(i,s,n)\\n        elif t == m:\\n            res = min(res, gr(i,s,n))\\n    \\n    return res\\n    \\n\\ndef gr(i,s,n):\\n    res = (s-i) % n\\n    if (res <= 0):\\n        return n-res\\n    return res\\n\\nprint(solve(a,d,n,s))\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\ndef ps(l, i, j):\\n    if i > j:\\n        return l[-1]-l[i-1] + l[j]\\n    if i==0:\\n        return l[j]\\n    else:\\n        return l[j]-l[i-1]\\n\\nn =  int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\n\\nl = [a[0]]\\nfor i in a[1:]:\\n    l.append(l[-1]+i)\\nx = s-1\\ny = f-2\\nans = 0\\ntm = 0\\nfor i in range(n):\\n    temp = ps(l, x, y)\\n    if temp > ans:\\n        tm = i+1\\n        ans = temp \\n    x -= 1\\n    y -= 1\\n    if x < 0:\\n        x = n-1\\n    if y < 0:\\n        y = n-1\\nprint(tm)\", \"n = int(input())\\narr = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nnum = 0\\nfor i in range(s - 1, f - 1):\\n\\tnum += arr[i]\\n\\nt = 0\\ncurrent = num\\nfor time in range(n):\\n\\tcurrent = current - arr[(s - 1 + time) % n] + arr[(f - 1 + time) % n]\\n\\tif (current >= num):\\n\\t\\tnum = current\\n\\t\\tt = time\\n\\nprint(n - t)\\n\", \"# C\\n\\nimport copy\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nB = copy.deepcopy(A)\\nC = A + B  # A\\u3092\\u4e8c\\u3064\\u9023\\u7d50\\u3057\\u305f\\u30ea\\u30b9\\u30c8\\n\\nl = f - s\\nmax_list = []\\nmax_number = 0\\n\\nsumC = [0 for i in range(N)]\\n\\nsumC[0] = sum(C[0:l])\\nfor i in range(1, N):\\n    sumC[i] = sumC[i-1] + C[i+l-1] - C[i-1]\\n\\nfor i in range(N):\\n    if sumC[i] > max_number:\\n        max_list = [i]\\n        max_number = sumC[i]\\n    elif sumC[i] == max_number:\\n        max_list.append(i)\\n\\nans_list = []\\nfor j in max_list:\\n    for i in range(N):\\n        if j + i < N:\\n            if s + i <= N:\\n                A[j + i] = s + i\\n            else:\\n                A[j + i] = s + i - N\\n        else:\\n            if s + i <= N:\\n                A[j + i - N] = s + i\\n            else:\\n                A[j + i - N] = s + i - N\\n    ans_list.append(A[0])\\n\\nprint(min(ans_list))\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 2\\npref = [0] * n\\npref[0] = a[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + a[i]\\nmx = -1\\nans = 0\\nfor hour in range(n):\\n\\tleft = s - hour\\n\\tright = f - hour\\n\\tif left < 0:\\n\\t\\tleft += n\\n\\tif right < 0:\\n\\t\\tright += n\\n\\tres = -1\\n\\tif left <= right:\\n\\t\\tres = pref[right] - (pref[left - 1] if left > 0 else 0)\\n\\telse:\\n\\t\\tres = pref[n - 1] - (pref[left - 1] if left > 0 else 0) + pref[right]\\n\\tif res > mx:\\n\\t\\tmx = res\\n\\t\\tans = hour + 1\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nd = f-s\\nmsum = 0\\nminx = 10**6\\ntemp = a+a[:d+1]\\nsumt=0\\n\\nfor x in range(n + d + 1):\\n    sumt+=temp[x]\\n    if (x >= d):\\n        sumt-= temp[x-d]\\n    #print(sumt, (n - x + s + d- 2)%n + 1, x)\\n    if (sumt > msum):\\n        minx = 10**6\\n        msum = sumt\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\n    elif (sumt == msum):\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\nprint(minx)\\n\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\ns, f = list(map(int, input().split()))\\n\\ns -= 1\\nf -= 1\\n\\nm = int(1e+9)\\n\\nbest_sum = sum(A[s: f + 1])\\ncur_sum = best_sum\\nbest_i = 0\\n\\nfor i in range(1, n):\\n    cur_sum += A[(s - i + n) % n]\\n    cur_sum -= A[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\n\\nprint(best_i + 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f + 1])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\na = [0]\\nb =input().split()\\na = a+b\\nans  = 0\\nm = 0\\nfor i in range(1,n+1):\\n    a[i] = int(a[i])\\ns,f = input().split()\\ns = int(s)\\nf = int(f)\\nfor i in range(s,f):\\n    m+=a[i]\\nma = m\\nans = 1\\nstart = s-1\\ncount = f-1\\nif count<1:\\n    count = n\\nif start<1:\\n    start = n\\nfor i in range(2,n+1):\\n    m = m-a[count] + a[start]\\n    count = count-1\\n    start = start - 1\\n    if count==0:\\n        count = n\\n    if start==0:\\n        start = start=n\\n    if m>ma:\\n        ma = m\\n        ans = i\\nprint(ans) \", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\nA = [int(x) for x in input().split()]\\nA = A+A\\ns,f = list(map(int,input().split()))\\n\\nl = f-s\\nS = sum(A[:l])\\nmi = 0\\nmS = S\\nans = (s-1-mi)%n + 1\\nfor i in range(n-1):\\n    S = S + A[i+l] - A[i] \\n    if mS == S:\\n        mi = i+1\\n        ans = min(ans, (s-1-mi)%n + 1) # Update min\\n    if mS < S:\\n        mS = S\\n        mi = i+1\\n        ans = (s-1-mi)%n + 1 # Set min\\nprint(ans)\\n\", \"#import sys\\n#sys.stdin = open ('464-C.in', 'r')\\n\\nn = int(input())\\nn = n*2\\na = list(map(int,input().split()))\\na = a+a\\ns, f = list(map(int, input().split()))\\nsum = [0 for i in range(n+1)]\\nfor i in range(1,n+1):\\n    sum[i] = sum[i-1]+a[i-1]\\nran = f-s\\nmsum, idx = 0, 0\\nbb = int(1e18)\\nfor i in range(ran,n+1):\\n   # print (i, \\\" = \\\", sum[i]-sum[i-ran])\\n    if sum[i]-sum[i-ran] > msum:\\n        msum = sum[i] - sum[i - ran]\\n        idx = i-ran+1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        bb = idx\\n    elif sum[i]-sum[i-ran] == msum:\\n        idx = i - ran + 1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        if idx < bb:\\n            bb = idx\\n            msum = sum[i] - sum[i - ran]\\n\\n\\n#print (msum, \\\" \\\", idx)\\n\\nprint (bb)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns,f = [int(x) for x in input().split()]\\nzones = f-s\\ncurrans = 1\\ncurrmax = sum(a[s-1 : f-2])\\nans=1\\nmaxppl = currmax\\nfst = s-1\\nlst = f-2\\nfor currans in range(2, n+1):\\n    currmax += a[fst-1 if fst > 0 else n-1]\\n    currmax -= a[lst]\\n    fst = fst-1 if fst > 0 else n-1\\n    lst = lst - 1 if lst > 0 else n - 1\\n    if currmax > maxppl:\\n        maxppl = currmax\\n        ans = currans\\nprint(ans)\\n\", \"n=int(input())\\na=[int(i) for i in input().split()]\\ns,f=(int(i) for i in input().split())\\npref=[a[0]]\\nfor i in range(1,n):\\n\\tpref.append(a[i]+pref[i-1])\\n\\t\\ndef nb_people(strt, end):\\n\\tif strt<=end:\\n\\t\\tif strt==0:\\n\\t\\t\\treturn pref[end]\\n\\t\\telse:\\n\\t\\t\\treturn pref[end]-pref[strt-1]\\n\\telse:\\n\\t\\tret = pref[end]+pref[n-1]\\n\\t\\tif strt>0:\\n\\t\\t\\tret-=pref[strt-1]\\n\\t\\treturn ret\\n\\t\\nmax_people=0\\nopt_h=0\\nfor h in range(1,n+1):\\n\\tstrt=s-h+1#\\u00e0 h heures ds le 1er fuseau o\\u00f9 est - il s heures ?\\n\\tif strt<=0:\\n\\t\\tstrt+=n\\n\\tend =f-h#pareil avec f-1\\n\\tif end<=0:\\n\\t\\tend+=n\\n\\ttmp_people = nb_people(strt-1, end-1)\\n\\t#print(\\\"h\\\",h,\\\"strt\\\", strt, \\\"end\\\", end,\\\"tmp_people\\\",tmp_people)\\n\\tif tmp_people>max_people:\\n\\t\\tmax_people=tmp_people\\n\\t\\topt_h = h\\nprint(opt_h)\\n\", \"from sys import stdin as si\\nfrom collections import Counter as c\\n\\n\\nclass Solution:\\n\\n    def bazinga(self, n,m, k):\\n        mnp = sum(m[k[0]-1:k[1]-1])    # min number of participants\\n        diff = k[1]-k[0]\\n        mxp,ans = mnp, 0              # maximizing participants\\n        for i in range(1,n):\\n            # print (i,diff, mxp,mnp, sum(m[i: diff+i]))\\n            mxp +=  m[(k[0]-i-1 + n) % n]\\n            mxp -= m[(k[1]-i-1 + n) % n]\\n            if mxp > mnp:\\n                mnp,ans = mxp, i\\n        return ans +1\\n\\n\\ndef __starting_point():\\n    #for i in range(int(si.readline().strip())):\\n    n = int(si.readline().strip())\\n    m = list(map(int, si.readline().strip().split()))\\n    k = tuple(map(int, si.readline().strip().split()))\\n    S = Solution()\\n    print(S.bazinga(n, m, k))\\n\\n\\n\\n'''\\nhttp://codeforces.com/contest/939/problem/C\\n'''\\n__starting_point()\", \"n = int(input())\\na = [0] + list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nw = f - s\\nmax_s = cur_s = sum(a[s:f])\\nmax_h = cur_h = s\\n\\nfor i in range(2, n+1):\\n\\tcur_h -= 1\\n\\tif cur_h == 0: \\n\\t\\tcur_h = n\\n\\tj = i + w - 1\\n\\tif j > n:\\n\\t\\tj -= n\\n\\tcur_s = cur_s - a[i-1] + a[j]\\n\\tif (cur_s > max_s) or (cur_s == max_s and cur_h < max_h):\\n\\t\\tmax_s = cur_s\\n\\t\\tmax_h = cur_h\\n\\t\\t\\nprint(max_h)\\n\\t\\n\\t\\n\", \"def main():\\n    n = int(input())\\n\\n    a = [int(x) for x in input().split()]\\n    a += a\\n\\n    s, f = [int(x) for x in input().split()]\\n\\n    dp = [0 for _ in range(2 * n + 1)]\\n    for i in range(2 * n):\\n        dp[i + 1] = dp[i] + a[i]\\n\\n    ans, sum = 0, 0\\n\\n    for i in range(n):\\n        cur_sum = dp[f + n - i - 1] - dp[s + n - i - 1]\\n\\n        if cur_sum > sum:\\n            ans = i\\n            sum = cur_sum\\n\\n    ans += 1\\n    print(ans)        \\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nps = [ int(a) for a in input().split() ]\\ns,f = [ int(a) for a in input().split() ]\\n\\nwindow = f-s\\nps += ps[:window]\\n\\ndef f(x):\\n    return (s-1-x)%n + 1\\n\\nanswers = []\\nc = m = sum(ps[:window])\\nfor i in range(n):\\n    if c > m:\\n        answers = [f(i)]\\n        m = c\\n    elif c == m:\\n        answers += [f(i)]\\n    c += ps[i+window]-ps[i]\\n\\nprint(min(answers))\", \"h = int(input())\\nppl = [int(x) for x in input().split()]\\nsl = [int(x) for x in input().split()]\\nn = sl[1] - sl[0] if sl[1] > sl[0] else sl[1] - sl[0] + h\\nm = 0\\nindex = 0\\ntemp = sum(ppl[0:n])\\nans = []\\nfor i in range(h):\\n    if m < temp:\\n        m = temp \\n        ans.clear()\\n        ans.append(i)\\n    elif m == temp:\\n        ans.append(i)\\n    temp -= ppl[i]\\n    temp += ppl[(i+n) % h]\\nres = [(sl[0] + h - index - 1) % h + 1  for index in ans]\\n# print(n)\\n# print(m)\\nprint(min(res))\\n\\n    \\n\", \"# Q.C\\nn = int(input())\\na = input().split(\\\" \\\")\\na = list(map(int,a))\\ns,f = list(map(int, input().split(\\\" \\\")))\\na.insert(0,0)\\n\\nx = 1\\nxm = x\\nli = s-x+1\\nri = f-x\\ntotalm = sum(a[i] for i in range(li,ri+1))\\ntotal = totalm\\n\\nfor x in range(2, n+1):\\n    li -= 1\\n    if li == 0:\\n        li = n\\n    total += a[li]\\n    total -= a[ri]\\n    ri -= 1\\n    if ri == 0:\\n        ri = n\\n    if total > totalm:\\n        totalm = total\\n        xm = x\\nprint(xm)\", \"n = int(input())\\n\\ninp = input().split(\\\" \\\")\\n\\npeople = []\\nfor i in range(n):\\n\\tpeople.append(int(inp[i]))\\n\\ninp = input().split(\\\" \\\")\\nstart = int(inp[0])\\nend = int(inp[1])\\ndiff = end - start\\n\\noptimal = 1\\npeople = people + people\\nm = sum(people[0: diff])\\nprev_sum = m\\n\\nfor i in range(1, n):\\n\\toffset = min(diff, n - i)\\n\\tprev_sum -= people[i - 1]\\n\\tprev_sum += people[i + diff - 1]\\n\\n\\tif prev_sum > m:\\n\\t\\tm = prev_sum\\n\\t\\toptimal = i + diff\\n\\t\\toptimal = (end - optimal) % n\\n\\t\\tif optimal == 0:\\n\\t\\t\\toptimal = n\\n\\t\\t\\t\\n\\tif prev_sum == m:\\n\\t\\toptimal2 = i + diff\\n\\t\\toptimal2 = (end - optimal2) % n\\n\\t\\tif optimal2 == 0:\\n\\t\\t\\toptimal2 = n\\n\\n\\t\\tif optimal2 < optimal:\\n\\t\\t\\toptimal = optimal2\\n\\nif m == 0:\\n\\toptimal = 1\\n\\nprint(optimal)\\n\"]",
        "difficulty": "interview",
        "input": "2\n5072 8422\n1 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/939/C"
    },
    {
        "id": 1942,
        "task_id": 2086,
        "test_case_id": 4,
        "question": "In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time \"0 hours\", instead of it \"n hours\" is used. When local time in the 1-st timezone is 1 hour, local time in the i-th timezone is i hours.\n\nSome online programming contests platform wants to conduct a contest that lasts for an hour in such a way that its beginning coincides with beginning of some hour (in all time zones). The platform knows, that there are a_{i} people from i-th timezone who want to participate in the contest. Each person will participate if and only if the contest starts no earlier than s hours 00 minutes local time and ends not later than f hours 00 minutes local time. Values s and f are equal for all time zones. If the contest starts at f hours 00 minutes local time, the person won't participate in it.\n\nHelp platform select such an hour, that the number of people who will participate in the contest is maximum. \n\n\n-----Input-----\n\nThe first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of hours in day.\n\nThe second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10 000), where a_{i} is the number of people in the i-th timezone who want to participate in the contest.\n\nThe third line contains two space-separated integers s and f (1 ≤ s < f ≤ n).\n\n\n-----Output-----\n\nOutput a single integer — the time of the beginning of the contest (in the first timezone local time), such that the number of participants will be maximum possible. If there are many answers, output the smallest among them.\n\n\n-----Examples-----\nInput\n3\n1 2 3\n1 3\n\nOutput\n3\n\nInput\n5\n1 2 3 4 1\n1 3\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example, it's optimal to start competition at 3 hours (in first timezone). In this case, it will be 1 hour in the second timezone and 2 hours in the third timezone. Only one person from the first timezone won't participate.\n\nIn second example only people from the third and the fourth timezones will participate.",
        "solutions": "[\"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = [int(i) for i in input().split()]\\na = a + a\\nln = f - s\\nans = sum(a[:ln])\\nmx = ans\\nh = s\\nfor i in range(n - 1):\\n    ans = ans - a[i] + a[i + ln]\\n    if ans > mx:\\n        ans = mx\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n  \\n        h = k\\n    elif ans == mx:\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n    \\n        h = min(h, k)\\nprint(h)\\n\", \"import sys, math\\n\\n#f = open('input/input_1', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\na = list(map(int, f.readline().split()))\\nstart, end = list(map(int, f.readline().split()))\\n\\ntime_len = end-start\\nsum_p = 0\\nmax_sum = -1\\nmax_sum_end = 10000000\\nfor i in range(N*2):\\n  if i >= time_len:\\n    sum_p -= a[(i-time_len)%N]\\n  sum_p += a[i % N]\\n  ans = (2*N + end - i - 1) % N\\n  if ans == 0:\\n    ans = N\\n  if i >= time_len-1 and \\\\\\n    (max_sum < sum_p or (max_sum == sum_p and max_sum_end > ans)):\\n    max_sum = sum_p\\n    max_sum_end = ans\\n\\nprint(max_sum_end)\\n\\n'''\\n5\\n10 2 3 4 10\\n1 5\\n\\n1 2 3 4 5\\n4 5 1 2 3\\n'''\\n\", \"n = int(input())\\nL = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\ncount = 0\\ncount_max = 0\\nans = 0\\nfor i in range(s - 1, f - 1):\\n    count += L[i]\\nfor i in range(n):\\n    count -= L[f - 1]\\n    s -= 1\\n    f -= 1\\n    if s == -1:\\n        s = n - 1\\n    if f == -1:\\n        f = n - 1\\n    count += L[s]\\n    if count > count_max:\\n        count_max = count\\n        ans = i\\nprint(ans + 1) \\n\", \"R = lambda : map(int, input().split())\\n\\nn = int(input())\\na = list(R())\\ns,f = R()\\n\\nd = f-s\\n\\ndef solve(a,d,n,s):\\n    if (n < d + 1):\\n        return s\\n\\n    t = 0\\n    for i in range(0, d):\\n        t += a[i]\\n\\n    m = t\\n    res = s\\n    for i in range(1, n):\\n        t += a[(i + d - 1) % n] - a[i - 1]\\n        if t > m:\\n            m = t\\n            res = gr(i,s,n)\\n        elif t == m:\\n            res = min(res, gr(i,s,n))\\n    \\n    return res\\n    \\n\\ndef gr(i,s,n):\\n    res = (s-i) % n\\n    if (res <= 0):\\n        return n-res\\n    return res\\n\\nprint(solve(a,d,n,s))\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\ndef ps(l, i, j):\\n    if i > j:\\n        return l[-1]-l[i-1] + l[j]\\n    if i==0:\\n        return l[j]\\n    else:\\n        return l[j]-l[i-1]\\n\\nn =  int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\n\\nl = [a[0]]\\nfor i in a[1:]:\\n    l.append(l[-1]+i)\\nx = s-1\\ny = f-2\\nans = 0\\ntm = 0\\nfor i in range(n):\\n    temp = ps(l, x, y)\\n    if temp > ans:\\n        tm = i+1\\n        ans = temp \\n    x -= 1\\n    y -= 1\\n    if x < 0:\\n        x = n-1\\n    if y < 0:\\n        y = n-1\\nprint(tm)\", \"n = int(input())\\narr = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nnum = 0\\nfor i in range(s - 1, f - 1):\\n\\tnum += arr[i]\\n\\nt = 0\\ncurrent = num\\nfor time in range(n):\\n\\tcurrent = current - arr[(s - 1 + time) % n] + arr[(f - 1 + time) % n]\\n\\tif (current >= num):\\n\\t\\tnum = current\\n\\t\\tt = time\\n\\nprint(n - t)\\n\", \"# C\\n\\nimport copy\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nB = copy.deepcopy(A)\\nC = A + B  # A\\u3092\\u4e8c\\u3064\\u9023\\u7d50\\u3057\\u305f\\u30ea\\u30b9\\u30c8\\n\\nl = f - s\\nmax_list = []\\nmax_number = 0\\n\\nsumC = [0 for i in range(N)]\\n\\nsumC[0] = sum(C[0:l])\\nfor i in range(1, N):\\n    sumC[i] = sumC[i-1] + C[i+l-1] - C[i-1]\\n\\nfor i in range(N):\\n    if sumC[i] > max_number:\\n        max_list = [i]\\n        max_number = sumC[i]\\n    elif sumC[i] == max_number:\\n        max_list.append(i)\\n\\nans_list = []\\nfor j in max_list:\\n    for i in range(N):\\n        if j + i < N:\\n            if s + i <= N:\\n                A[j + i] = s + i\\n            else:\\n                A[j + i] = s + i - N\\n        else:\\n            if s + i <= N:\\n                A[j + i - N] = s + i\\n            else:\\n                A[j + i - N] = s + i - N\\n    ans_list.append(A[0])\\n\\nprint(min(ans_list))\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 2\\npref = [0] * n\\npref[0] = a[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + a[i]\\nmx = -1\\nans = 0\\nfor hour in range(n):\\n\\tleft = s - hour\\n\\tright = f - hour\\n\\tif left < 0:\\n\\t\\tleft += n\\n\\tif right < 0:\\n\\t\\tright += n\\n\\tres = -1\\n\\tif left <= right:\\n\\t\\tres = pref[right] - (pref[left - 1] if left > 0 else 0)\\n\\telse:\\n\\t\\tres = pref[n - 1] - (pref[left - 1] if left > 0 else 0) + pref[right]\\n\\tif res > mx:\\n\\t\\tmx = res\\n\\t\\tans = hour + 1\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nd = f-s\\nmsum = 0\\nminx = 10**6\\ntemp = a+a[:d+1]\\nsumt=0\\n\\nfor x in range(n + d + 1):\\n    sumt+=temp[x]\\n    if (x >= d):\\n        sumt-= temp[x-d]\\n    #print(sumt, (n - x + s + d- 2)%n + 1, x)\\n    if (sumt > msum):\\n        minx = 10**6\\n        msum = sumt\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\n    elif (sumt == msum):\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\nprint(minx)\\n\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\ns, f = list(map(int, input().split()))\\n\\ns -= 1\\nf -= 1\\n\\nm = int(1e+9)\\n\\nbest_sum = sum(A[s: f + 1])\\ncur_sum = best_sum\\nbest_i = 0\\n\\nfor i in range(1, n):\\n    cur_sum += A[(s - i + n) % n]\\n    cur_sum -= A[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\n\\nprint(best_i + 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f + 1])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\na = [0]\\nb =input().split()\\na = a+b\\nans  = 0\\nm = 0\\nfor i in range(1,n+1):\\n    a[i] = int(a[i])\\ns,f = input().split()\\ns = int(s)\\nf = int(f)\\nfor i in range(s,f):\\n    m+=a[i]\\nma = m\\nans = 1\\nstart = s-1\\ncount = f-1\\nif count<1:\\n    count = n\\nif start<1:\\n    start = n\\nfor i in range(2,n+1):\\n    m = m-a[count] + a[start]\\n    count = count-1\\n    start = start - 1\\n    if count==0:\\n        count = n\\n    if start==0:\\n        start = start=n\\n    if m>ma:\\n        ma = m\\n        ans = i\\nprint(ans) \", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\nA = [int(x) for x in input().split()]\\nA = A+A\\ns,f = list(map(int,input().split()))\\n\\nl = f-s\\nS = sum(A[:l])\\nmi = 0\\nmS = S\\nans = (s-1-mi)%n + 1\\nfor i in range(n-1):\\n    S = S + A[i+l] - A[i] \\n    if mS == S:\\n        mi = i+1\\n        ans = min(ans, (s-1-mi)%n + 1) # Update min\\n    if mS < S:\\n        mS = S\\n        mi = i+1\\n        ans = (s-1-mi)%n + 1 # Set min\\nprint(ans)\\n\", \"#import sys\\n#sys.stdin = open ('464-C.in', 'r')\\n\\nn = int(input())\\nn = n*2\\na = list(map(int,input().split()))\\na = a+a\\ns, f = list(map(int, input().split()))\\nsum = [0 for i in range(n+1)]\\nfor i in range(1,n+1):\\n    sum[i] = sum[i-1]+a[i-1]\\nran = f-s\\nmsum, idx = 0, 0\\nbb = int(1e18)\\nfor i in range(ran,n+1):\\n   # print (i, \\\" = \\\", sum[i]-sum[i-ran])\\n    if sum[i]-sum[i-ran] > msum:\\n        msum = sum[i] - sum[i - ran]\\n        idx = i-ran+1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        bb = idx\\n    elif sum[i]-sum[i-ran] == msum:\\n        idx = i - ran + 1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        if idx < bb:\\n            bb = idx\\n            msum = sum[i] - sum[i - ran]\\n\\n\\n#print (msum, \\\" \\\", idx)\\n\\nprint (bb)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns,f = [int(x) for x in input().split()]\\nzones = f-s\\ncurrans = 1\\ncurrmax = sum(a[s-1 : f-2])\\nans=1\\nmaxppl = currmax\\nfst = s-1\\nlst = f-2\\nfor currans in range(2, n+1):\\n    currmax += a[fst-1 if fst > 0 else n-1]\\n    currmax -= a[lst]\\n    fst = fst-1 if fst > 0 else n-1\\n    lst = lst - 1 if lst > 0 else n - 1\\n    if currmax > maxppl:\\n        maxppl = currmax\\n        ans = currans\\nprint(ans)\\n\", \"n=int(input())\\na=[int(i) for i in input().split()]\\ns,f=(int(i) for i in input().split())\\npref=[a[0]]\\nfor i in range(1,n):\\n\\tpref.append(a[i]+pref[i-1])\\n\\t\\ndef nb_people(strt, end):\\n\\tif strt<=end:\\n\\t\\tif strt==0:\\n\\t\\t\\treturn pref[end]\\n\\t\\telse:\\n\\t\\t\\treturn pref[end]-pref[strt-1]\\n\\telse:\\n\\t\\tret = pref[end]+pref[n-1]\\n\\t\\tif strt>0:\\n\\t\\t\\tret-=pref[strt-1]\\n\\t\\treturn ret\\n\\t\\nmax_people=0\\nopt_h=0\\nfor h in range(1,n+1):\\n\\tstrt=s-h+1#\\u00e0 h heures ds le 1er fuseau o\\u00f9 est - il s heures ?\\n\\tif strt<=0:\\n\\t\\tstrt+=n\\n\\tend =f-h#pareil avec f-1\\n\\tif end<=0:\\n\\t\\tend+=n\\n\\ttmp_people = nb_people(strt-1, end-1)\\n\\t#print(\\\"h\\\",h,\\\"strt\\\", strt, \\\"end\\\", end,\\\"tmp_people\\\",tmp_people)\\n\\tif tmp_people>max_people:\\n\\t\\tmax_people=tmp_people\\n\\t\\topt_h = h\\nprint(opt_h)\\n\", \"from sys import stdin as si\\nfrom collections import Counter as c\\n\\n\\nclass Solution:\\n\\n    def bazinga(self, n,m, k):\\n        mnp = sum(m[k[0]-1:k[1]-1])    # min number of participants\\n        diff = k[1]-k[0]\\n        mxp,ans = mnp, 0              # maximizing participants\\n        for i in range(1,n):\\n            # print (i,diff, mxp,mnp, sum(m[i: diff+i]))\\n            mxp +=  m[(k[0]-i-1 + n) % n]\\n            mxp -= m[(k[1]-i-1 + n) % n]\\n            if mxp > mnp:\\n                mnp,ans = mxp, i\\n        return ans +1\\n\\n\\ndef __starting_point():\\n    #for i in range(int(si.readline().strip())):\\n    n = int(si.readline().strip())\\n    m = list(map(int, si.readline().strip().split()))\\n    k = tuple(map(int, si.readline().strip().split()))\\n    S = Solution()\\n    print(S.bazinga(n, m, k))\\n\\n\\n\\n'''\\nhttp://codeforces.com/contest/939/problem/C\\n'''\\n__starting_point()\", \"n = int(input())\\na = [0] + list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nw = f - s\\nmax_s = cur_s = sum(a[s:f])\\nmax_h = cur_h = s\\n\\nfor i in range(2, n+1):\\n\\tcur_h -= 1\\n\\tif cur_h == 0: \\n\\t\\tcur_h = n\\n\\tj = i + w - 1\\n\\tif j > n:\\n\\t\\tj -= n\\n\\tcur_s = cur_s - a[i-1] + a[j]\\n\\tif (cur_s > max_s) or (cur_s == max_s and cur_h < max_h):\\n\\t\\tmax_s = cur_s\\n\\t\\tmax_h = cur_h\\n\\t\\t\\nprint(max_h)\\n\\t\\n\\t\\n\", \"def main():\\n    n = int(input())\\n\\n    a = [int(x) for x in input().split()]\\n    a += a\\n\\n    s, f = [int(x) for x in input().split()]\\n\\n    dp = [0 for _ in range(2 * n + 1)]\\n    for i in range(2 * n):\\n        dp[i + 1] = dp[i] + a[i]\\n\\n    ans, sum = 0, 0\\n\\n    for i in range(n):\\n        cur_sum = dp[f + n - i - 1] - dp[s + n - i - 1]\\n\\n        if cur_sum > sum:\\n            ans = i\\n            sum = cur_sum\\n\\n    ans += 1\\n    print(ans)        \\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nps = [ int(a) for a in input().split() ]\\ns,f = [ int(a) for a in input().split() ]\\n\\nwindow = f-s\\nps += ps[:window]\\n\\ndef f(x):\\n    return (s-1-x)%n + 1\\n\\nanswers = []\\nc = m = sum(ps[:window])\\nfor i in range(n):\\n    if c > m:\\n        answers = [f(i)]\\n        m = c\\n    elif c == m:\\n        answers += [f(i)]\\n    c += ps[i+window]-ps[i]\\n\\nprint(min(answers))\", \"h = int(input())\\nppl = [int(x) for x in input().split()]\\nsl = [int(x) for x in input().split()]\\nn = sl[1] - sl[0] if sl[1] > sl[0] else sl[1] - sl[0] + h\\nm = 0\\nindex = 0\\ntemp = sum(ppl[0:n])\\nans = []\\nfor i in range(h):\\n    if m < temp:\\n        m = temp \\n        ans.clear()\\n        ans.append(i)\\n    elif m == temp:\\n        ans.append(i)\\n    temp -= ppl[i]\\n    temp += ppl[(i+n) % h]\\nres = [(sl[0] + h - index - 1) % h + 1  for index in ans]\\n# print(n)\\n# print(m)\\nprint(min(res))\\n\\n    \\n\", \"# Q.C\\nn = int(input())\\na = input().split(\\\" \\\")\\na = list(map(int,a))\\ns,f = list(map(int, input().split(\\\" \\\")))\\na.insert(0,0)\\n\\nx = 1\\nxm = x\\nli = s-x+1\\nri = f-x\\ntotalm = sum(a[i] for i in range(li,ri+1))\\ntotal = totalm\\n\\nfor x in range(2, n+1):\\n    li -= 1\\n    if li == 0:\\n        li = n\\n    total += a[li]\\n    total -= a[ri]\\n    ri -= 1\\n    if ri == 0:\\n        ri = n\\n    if total > totalm:\\n        totalm = total\\n        xm = x\\nprint(xm)\", \"n = int(input())\\n\\ninp = input().split(\\\" \\\")\\n\\npeople = []\\nfor i in range(n):\\n\\tpeople.append(int(inp[i]))\\n\\ninp = input().split(\\\" \\\")\\nstart = int(inp[0])\\nend = int(inp[1])\\ndiff = end - start\\n\\noptimal = 1\\npeople = people + people\\nm = sum(people[0: diff])\\nprev_sum = m\\n\\nfor i in range(1, n):\\n\\toffset = min(diff, n - i)\\n\\tprev_sum -= people[i - 1]\\n\\tprev_sum += people[i + diff - 1]\\n\\n\\tif prev_sum > m:\\n\\t\\tm = prev_sum\\n\\t\\toptimal = i + diff\\n\\t\\toptimal = (end - optimal) % n\\n\\t\\tif optimal == 0:\\n\\t\\t\\toptimal = n\\n\\t\\t\\t\\n\\tif prev_sum == m:\\n\\t\\toptimal2 = i + diff\\n\\t\\toptimal2 = (end - optimal2) % n\\n\\t\\tif optimal2 == 0:\\n\\t\\t\\toptimal2 = n\\n\\n\\t\\tif optimal2 < optimal:\\n\\t\\t\\toptimal = optimal2\\n\\nif m == 0:\\n\\toptimal = 1\\n\\nprint(optimal)\\n\"]",
        "difficulty": "interview",
        "input": "10\n7171 2280 6982 9126 9490 2598 569 6744 5754 1855\n7 9\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/939/C"
    },
    {
        "id": 1943,
        "task_id": 2086,
        "test_case_id": 5,
        "question": "In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time \"0 hours\", instead of it \"n hours\" is used. When local time in the 1-st timezone is 1 hour, local time in the i-th timezone is i hours.\n\nSome online programming contests platform wants to conduct a contest that lasts for an hour in such a way that its beginning coincides with beginning of some hour (in all time zones). The platform knows, that there are a_{i} people from i-th timezone who want to participate in the contest. Each person will participate if and only if the contest starts no earlier than s hours 00 minutes local time and ends not later than f hours 00 minutes local time. Values s and f are equal for all time zones. If the contest starts at f hours 00 minutes local time, the person won't participate in it.\n\nHelp platform select such an hour, that the number of people who will participate in the contest is maximum. \n\n\n-----Input-----\n\nThe first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of hours in day.\n\nThe second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10 000), where a_{i} is the number of people in the i-th timezone who want to participate in the contest.\n\nThe third line contains two space-separated integers s and f (1 ≤ s < f ≤ n).\n\n\n-----Output-----\n\nOutput a single integer — the time of the beginning of the contest (in the first timezone local time), such that the number of participants will be maximum possible. If there are many answers, output the smallest among them.\n\n\n-----Examples-----\nInput\n3\n1 2 3\n1 3\n\nOutput\n3\n\nInput\n5\n1 2 3 4 1\n1 3\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example, it's optimal to start competition at 3 hours (in first timezone). In this case, it will be 1 hour in the second timezone and 2 hours in the third timezone. Only one person from the first timezone won't participate.\n\nIn second example only people from the third and the fourth timezones will participate.",
        "solutions": "[\"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = [int(i) for i in input().split()]\\na = a + a\\nln = f - s\\nans = sum(a[:ln])\\nmx = ans\\nh = s\\nfor i in range(n - 1):\\n    ans = ans - a[i] + a[i + ln]\\n    if ans > mx:\\n        ans = mx\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n  \\n        h = k\\n    elif ans == mx:\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n    \\n        h = min(h, k)\\nprint(h)\\n\", \"import sys, math\\n\\n#f = open('input/input_1', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\na = list(map(int, f.readline().split()))\\nstart, end = list(map(int, f.readline().split()))\\n\\ntime_len = end-start\\nsum_p = 0\\nmax_sum = -1\\nmax_sum_end = 10000000\\nfor i in range(N*2):\\n  if i >= time_len:\\n    sum_p -= a[(i-time_len)%N]\\n  sum_p += a[i % N]\\n  ans = (2*N + end - i - 1) % N\\n  if ans == 0:\\n    ans = N\\n  if i >= time_len-1 and \\\\\\n    (max_sum < sum_p or (max_sum == sum_p and max_sum_end > ans)):\\n    max_sum = sum_p\\n    max_sum_end = ans\\n\\nprint(max_sum_end)\\n\\n'''\\n5\\n10 2 3 4 10\\n1 5\\n\\n1 2 3 4 5\\n4 5 1 2 3\\n'''\\n\", \"n = int(input())\\nL = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\ncount = 0\\ncount_max = 0\\nans = 0\\nfor i in range(s - 1, f - 1):\\n    count += L[i]\\nfor i in range(n):\\n    count -= L[f - 1]\\n    s -= 1\\n    f -= 1\\n    if s == -1:\\n        s = n - 1\\n    if f == -1:\\n        f = n - 1\\n    count += L[s]\\n    if count > count_max:\\n        count_max = count\\n        ans = i\\nprint(ans + 1) \\n\", \"R = lambda : map(int, input().split())\\n\\nn = int(input())\\na = list(R())\\ns,f = R()\\n\\nd = f-s\\n\\ndef solve(a,d,n,s):\\n    if (n < d + 1):\\n        return s\\n\\n    t = 0\\n    for i in range(0, d):\\n        t += a[i]\\n\\n    m = t\\n    res = s\\n    for i in range(1, n):\\n        t += a[(i + d - 1) % n] - a[i - 1]\\n        if t > m:\\n            m = t\\n            res = gr(i,s,n)\\n        elif t == m:\\n            res = min(res, gr(i,s,n))\\n    \\n    return res\\n    \\n\\ndef gr(i,s,n):\\n    res = (s-i) % n\\n    if (res <= 0):\\n        return n-res\\n    return res\\n\\nprint(solve(a,d,n,s))\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\ndef ps(l, i, j):\\n    if i > j:\\n        return l[-1]-l[i-1] + l[j]\\n    if i==0:\\n        return l[j]\\n    else:\\n        return l[j]-l[i-1]\\n\\nn =  int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\n\\nl = [a[0]]\\nfor i in a[1:]:\\n    l.append(l[-1]+i)\\nx = s-1\\ny = f-2\\nans = 0\\ntm = 0\\nfor i in range(n):\\n    temp = ps(l, x, y)\\n    if temp > ans:\\n        tm = i+1\\n        ans = temp \\n    x -= 1\\n    y -= 1\\n    if x < 0:\\n        x = n-1\\n    if y < 0:\\n        y = n-1\\nprint(tm)\", \"n = int(input())\\narr = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nnum = 0\\nfor i in range(s - 1, f - 1):\\n\\tnum += arr[i]\\n\\nt = 0\\ncurrent = num\\nfor time in range(n):\\n\\tcurrent = current - arr[(s - 1 + time) % n] + arr[(f - 1 + time) % n]\\n\\tif (current >= num):\\n\\t\\tnum = current\\n\\t\\tt = time\\n\\nprint(n - t)\\n\", \"# C\\n\\nimport copy\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nB = copy.deepcopy(A)\\nC = A + B  # A\\u3092\\u4e8c\\u3064\\u9023\\u7d50\\u3057\\u305f\\u30ea\\u30b9\\u30c8\\n\\nl = f - s\\nmax_list = []\\nmax_number = 0\\n\\nsumC = [0 for i in range(N)]\\n\\nsumC[0] = sum(C[0:l])\\nfor i in range(1, N):\\n    sumC[i] = sumC[i-1] + C[i+l-1] - C[i-1]\\n\\nfor i in range(N):\\n    if sumC[i] > max_number:\\n        max_list = [i]\\n        max_number = sumC[i]\\n    elif sumC[i] == max_number:\\n        max_list.append(i)\\n\\nans_list = []\\nfor j in max_list:\\n    for i in range(N):\\n        if j + i < N:\\n            if s + i <= N:\\n                A[j + i] = s + i\\n            else:\\n                A[j + i] = s + i - N\\n        else:\\n            if s + i <= N:\\n                A[j + i - N] = s + i\\n            else:\\n                A[j + i - N] = s + i - N\\n    ans_list.append(A[0])\\n\\nprint(min(ans_list))\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 2\\npref = [0] * n\\npref[0] = a[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + a[i]\\nmx = -1\\nans = 0\\nfor hour in range(n):\\n\\tleft = s - hour\\n\\tright = f - hour\\n\\tif left < 0:\\n\\t\\tleft += n\\n\\tif right < 0:\\n\\t\\tright += n\\n\\tres = -1\\n\\tif left <= right:\\n\\t\\tres = pref[right] - (pref[left - 1] if left > 0 else 0)\\n\\telse:\\n\\t\\tres = pref[n - 1] - (pref[left - 1] if left > 0 else 0) + pref[right]\\n\\tif res > mx:\\n\\t\\tmx = res\\n\\t\\tans = hour + 1\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nd = f-s\\nmsum = 0\\nminx = 10**6\\ntemp = a+a[:d+1]\\nsumt=0\\n\\nfor x in range(n + d + 1):\\n    sumt+=temp[x]\\n    if (x >= d):\\n        sumt-= temp[x-d]\\n    #print(sumt, (n - x + s + d- 2)%n + 1, x)\\n    if (sumt > msum):\\n        minx = 10**6\\n        msum = sumt\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\n    elif (sumt == msum):\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\nprint(minx)\\n\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\ns, f = list(map(int, input().split()))\\n\\ns -= 1\\nf -= 1\\n\\nm = int(1e+9)\\n\\nbest_sum = sum(A[s: f + 1])\\ncur_sum = best_sum\\nbest_i = 0\\n\\nfor i in range(1, n):\\n    cur_sum += A[(s - i + n) % n]\\n    cur_sum -= A[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\n\\nprint(best_i + 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f + 1])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\na = [0]\\nb =input().split()\\na = a+b\\nans  = 0\\nm = 0\\nfor i in range(1,n+1):\\n    a[i] = int(a[i])\\ns,f = input().split()\\ns = int(s)\\nf = int(f)\\nfor i in range(s,f):\\n    m+=a[i]\\nma = m\\nans = 1\\nstart = s-1\\ncount = f-1\\nif count<1:\\n    count = n\\nif start<1:\\n    start = n\\nfor i in range(2,n+1):\\n    m = m-a[count] + a[start]\\n    count = count-1\\n    start = start - 1\\n    if count==0:\\n        count = n\\n    if start==0:\\n        start = start=n\\n    if m>ma:\\n        ma = m\\n        ans = i\\nprint(ans) \", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\nA = [int(x) for x in input().split()]\\nA = A+A\\ns,f = list(map(int,input().split()))\\n\\nl = f-s\\nS = sum(A[:l])\\nmi = 0\\nmS = S\\nans = (s-1-mi)%n + 1\\nfor i in range(n-1):\\n    S = S + A[i+l] - A[i] \\n    if mS == S:\\n        mi = i+1\\n        ans = min(ans, (s-1-mi)%n + 1) # Update min\\n    if mS < S:\\n        mS = S\\n        mi = i+1\\n        ans = (s-1-mi)%n + 1 # Set min\\nprint(ans)\\n\", \"#import sys\\n#sys.stdin = open ('464-C.in', 'r')\\n\\nn = int(input())\\nn = n*2\\na = list(map(int,input().split()))\\na = a+a\\ns, f = list(map(int, input().split()))\\nsum = [0 for i in range(n+1)]\\nfor i in range(1,n+1):\\n    sum[i] = sum[i-1]+a[i-1]\\nran = f-s\\nmsum, idx = 0, 0\\nbb = int(1e18)\\nfor i in range(ran,n+1):\\n   # print (i, \\\" = \\\", sum[i]-sum[i-ran])\\n    if sum[i]-sum[i-ran] > msum:\\n        msum = sum[i] - sum[i - ran]\\n        idx = i-ran+1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        bb = idx\\n    elif sum[i]-sum[i-ran] == msum:\\n        idx = i - ran + 1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        if idx < bb:\\n            bb = idx\\n            msum = sum[i] - sum[i - ran]\\n\\n\\n#print (msum, \\\" \\\", idx)\\n\\nprint (bb)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns,f = [int(x) for x in input().split()]\\nzones = f-s\\ncurrans = 1\\ncurrmax = sum(a[s-1 : f-2])\\nans=1\\nmaxppl = currmax\\nfst = s-1\\nlst = f-2\\nfor currans in range(2, n+1):\\n    currmax += a[fst-1 if fst > 0 else n-1]\\n    currmax -= a[lst]\\n    fst = fst-1 if fst > 0 else n-1\\n    lst = lst - 1 if lst > 0 else n - 1\\n    if currmax > maxppl:\\n        maxppl = currmax\\n        ans = currans\\nprint(ans)\\n\", \"n=int(input())\\na=[int(i) for i in input().split()]\\ns,f=(int(i) for i in input().split())\\npref=[a[0]]\\nfor i in range(1,n):\\n\\tpref.append(a[i]+pref[i-1])\\n\\t\\ndef nb_people(strt, end):\\n\\tif strt<=end:\\n\\t\\tif strt==0:\\n\\t\\t\\treturn pref[end]\\n\\t\\telse:\\n\\t\\t\\treturn pref[end]-pref[strt-1]\\n\\telse:\\n\\t\\tret = pref[end]+pref[n-1]\\n\\t\\tif strt>0:\\n\\t\\t\\tret-=pref[strt-1]\\n\\t\\treturn ret\\n\\t\\nmax_people=0\\nopt_h=0\\nfor h in range(1,n+1):\\n\\tstrt=s-h+1#\\u00e0 h heures ds le 1er fuseau o\\u00f9 est - il s heures ?\\n\\tif strt<=0:\\n\\t\\tstrt+=n\\n\\tend =f-h#pareil avec f-1\\n\\tif end<=0:\\n\\t\\tend+=n\\n\\ttmp_people = nb_people(strt-1, end-1)\\n\\t#print(\\\"h\\\",h,\\\"strt\\\", strt, \\\"end\\\", end,\\\"tmp_people\\\",tmp_people)\\n\\tif tmp_people>max_people:\\n\\t\\tmax_people=tmp_people\\n\\t\\topt_h = h\\nprint(opt_h)\\n\", \"from sys import stdin as si\\nfrom collections import Counter as c\\n\\n\\nclass Solution:\\n\\n    def bazinga(self, n,m, k):\\n        mnp = sum(m[k[0]-1:k[1]-1])    # min number of participants\\n        diff = k[1]-k[0]\\n        mxp,ans = mnp, 0              # maximizing participants\\n        for i in range(1,n):\\n            # print (i,diff, mxp,mnp, sum(m[i: diff+i]))\\n            mxp +=  m[(k[0]-i-1 + n) % n]\\n            mxp -= m[(k[1]-i-1 + n) % n]\\n            if mxp > mnp:\\n                mnp,ans = mxp, i\\n        return ans +1\\n\\n\\ndef __starting_point():\\n    #for i in range(int(si.readline().strip())):\\n    n = int(si.readline().strip())\\n    m = list(map(int, si.readline().strip().split()))\\n    k = tuple(map(int, si.readline().strip().split()))\\n    S = Solution()\\n    print(S.bazinga(n, m, k))\\n\\n\\n\\n'''\\nhttp://codeforces.com/contest/939/problem/C\\n'''\\n__starting_point()\", \"n = int(input())\\na = [0] + list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nw = f - s\\nmax_s = cur_s = sum(a[s:f])\\nmax_h = cur_h = s\\n\\nfor i in range(2, n+1):\\n\\tcur_h -= 1\\n\\tif cur_h == 0: \\n\\t\\tcur_h = n\\n\\tj = i + w - 1\\n\\tif j > n:\\n\\t\\tj -= n\\n\\tcur_s = cur_s - a[i-1] + a[j]\\n\\tif (cur_s > max_s) or (cur_s == max_s and cur_h < max_h):\\n\\t\\tmax_s = cur_s\\n\\t\\tmax_h = cur_h\\n\\t\\t\\nprint(max_h)\\n\\t\\n\\t\\n\", \"def main():\\n    n = int(input())\\n\\n    a = [int(x) for x in input().split()]\\n    a += a\\n\\n    s, f = [int(x) for x in input().split()]\\n\\n    dp = [0 for _ in range(2 * n + 1)]\\n    for i in range(2 * n):\\n        dp[i + 1] = dp[i] + a[i]\\n\\n    ans, sum = 0, 0\\n\\n    for i in range(n):\\n        cur_sum = dp[f + n - i - 1] - dp[s + n - i - 1]\\n\\n        if cur_sum > sum:\\n            ans = i\\n            sum = cur_sum\\n\\n    ans += 1\\n    print(ans)        \\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nps = [ int(a) for a in input().split() ]\\ns,f = [ int(a) for a in input().split() ]\\n\\nwindow = f-s\\nps += ps[:window]\\n\\ndef f(x):\\n    return (s-1-x)%n + 1\\n\\nanswers = []\\nc = m = sum(ps[:window])\\nfor i in range(n):\\n    if c > m:\\n        answers = [f(i)]\\n        m = c\\n    elif c == m:\\n        answers += [f(i)]\\n    c += ps[i+window]-ps[i]\\n\\nprint(min(answers))\", \"h = int(input())\\nppl = [int(x) for x in input().split()]\\nsl = [int(x) for x in input().split()]\\nn = sl[1] - sl[0] if sl[1] > sl[0] else sl[1] - sl[0] + h\\nm = 0\\nindex = 0\\ntemp = sum(ppl[0:n])\\nans = []\\nfor i in range(h):\\n    if m < temp:\\n        m = temp \\n        ans.clear()\\n        ans.append(i)\\n    elif m == temp:\\n        ans.append(i)\\n    temp -= ppl[i]\\n    temp += ppl[(i+n) % h]\\nres = [(sl[0] + h - index - 1) % h + 1  for index in ans]\\n# print(n)\\n# print(m)\\nprint(min(res))\\n\\n    \\n\", \"# Q.C\\nn = int(input())\\na = input().split(\\\" \\\")\\na = list(map(int,a))\\ns,f = list(map(int, input().split(\\\" \\\")))\\na.insert(0,0)\\n\\nx = 1\\nxm = x\\nli = s-x+1\\nri = f-x\\ntotalm = sum(a[i] for i in range(li,ri+1))\\ntotal = totalm\\n\\nfor x in range(2, n+1):\\n    li -= 1\\n    if li == 0:\\n        li = n\\n    total += a[li]\\n    total -= a[ri]\\n    ri -= 1\\n    if ri == 0:\\n        ri = n\\n    if total > totalm:\\n        totalm = total\\n        xm = x\\nprint(xm)\", \"n = int(input())\\n\\ninp = input().split(\\\" \\\")\\n\\npeople = []\\nfor i in range(n):\\n\\tpeople.append(int(inp[i]))\\n\\ninp = input().split(\\\" \\\")\\nstart = int(inp[0])\\nend = int(inp[1])\\ndiff = end - start\\n\\noptimal = 1\\npeople = people + people\\nm = sum(people[0: diff])\\nprev_sum = m\\n\\nfor i in range(1, n):\\n\\toffset = min(diff, n - i)\\n\\tprev_sum -= people[i - 1]\\n\\tprev_sum += people[i + diff - 1]\\n\\n\\tif prev_sum > m:\\n\\t\\tm = prev_sum\\n\\t\\toptimal = i + diff\\n\\t\\toptimal = (end - optimal) % n\\n\\t\\tif optimal == 0:\\n\\t\\t\\toptimal = n\\n\\t\\t\\t\\n\\tif prev_sum == m:\\n\\t\\toptimal2 = i + diff\\n\\t\\toptimal2 = (end - optimal2) % n\\n\\t\\tif optimal2 == 0:\\n\\t\\t\\toptimal2 = n\\n\\n\\t\\tif optimal2 < optimal:\\n\\t\\t\\toptimal = optimal2\\n\\nif m == 0:\\n\\toptimal = 1\\n\\nprint(optimal)\\n\"]",
        "difficulty": "interview",
        "input": "10\n5827 8450 8288 5592 6627 8234 3557 7568 4607 6949\n2 10\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/939/C"
    },
    {
        "id": 1944,
        "task_id": 2086,
        "test_case_id": 6,
        "question": "In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time \"0 hours\", instead of it \"n hours\" is used. When local time in the 1-st timezone is 1 hour, local time in the i-th timezone is i hours.\n\nSome online programming contests platform wants to conduct a contest that lasts for an hour in such a way that its beginning coincides with beginning of some hour (in all time zones). The platform knows, that there are a_{i} people from i-th timezone who want to participate in the contest. Each person will participate if and only if the contest starts no earlier than s hours 00 minutes local time and ends not later than f hours 00 minutes local time. Values s and f are equal for all time zones. If the contest starts at f hours 00 minutes local time, the person won't participate in it.\n\nHelp platform select such an hour, that the number of people who will participate in the contest is maximum. \n\n\n-----Input-----\n\nThe first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of hours in day.\n\nThe second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10 000), where a_{i} is the number of people in the i-th timezone who want to participate in the contest.\n\nThe third line contains two space-separated integers s and f (1 ≤ s < f ≤ n).\n\n\n-----Output-----\n\nOutput a single integer — the time of the beginning of the contest (in the first timezone local time), such that the number of participants will be maximum possible. If there are many answers, output the smallest among them.\n\n\n-----Examples-----\nInput\n3\n1 2 3\n1 3\n\nOutput\n3\n\nInput\n5\n1 2 3 4 1\n1 3\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example, it's optimal to start competition at 3 hours (in first timezone). In this case, it will be 1 hour in the second timezone and 2 hours in the third timezone. Only one person from the first timezone won't participate.\n\nIn second example only people from the third and the fourth timezones will participate.",
        "solutions": "[\"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = [int(i) for i in input().split()]\\na = a + a\\nln = f - s\\nans = sum(a[:ln])\\nmx = ans\\nh = s\\nfor i in range(n - 1):\\n    ans = ans - a[i] + a[i + ln]\\n    if ans > mx:\\n        ans = mx\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n  \\n        h = k\\n    elif ans == mx:\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n    \\n        h = min(h, k)\\nprint(h)\\n\", \"import sys, math\\n\\n#f = open('input/input_1', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\na = list(map(int, f.readline().split()))\\nstart, end = list(map(int, f.readline().split()))\\n\\ntime_len = end-start\\nsum_p = 0\\nmax_sum = -1\\nmax_sum_end = 10000000\\nfor i in range(N*2):\\n  if i >= time_len:\\n    sum_p -= a[(i-time_len)%N]\\n  sum_p += a[i % N]\\n  ans = (2*N + end - i - 1) % N\\n  if ans == 0:\\n    ans = N\\n  if i >= time_len-1 and \\\\\\n    (max_sum < sum_p or (max_sum == sum_p and max_sum_end > ans)):\\n    max_sum = sum_p\\n    max_sum_end = ans\\n\\nprint(max_sum_end)\\n\\n'''\\n5\\n10 2 3 4 10\\n1 5\\n\\n1 2 3 4 5\\n4 5 1 2 3\\n'''\\n\", \"n = int(input())\\nL = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\ncount = 0\\ncount_max = 0\\nans = 0\\nfor i in range(s - 1, f - 1):\\n    count += L[i]\\nfor i in range(n):\\n    count -= L[f - 1]\\n    s -= 1\\n    f -= 1\\n    if s == -1:\\n        s = n - 1\\n    if f == -1:\\n        f = n - 1\\n    count += L[s]\\n    if count > count_max:\\n        count_max = count\\n        ans = i\\nprint(ans + 1) \\n\", \"R = lambda : map(int, input().split())\\n\\nn = int(input())\\na = list(R())\\ns,f = R()\\n\\nd = f-s\\n\\ndef solve(a,d,n,s):\\n    if (n < d + 1):\\n        return s\\n\\n    t = 0\\n    for i in range(0, d):\\n        t += a[i]\\n\\n    m = t\\n    res = s\\n    for i in range(1, n):\\n        t += a[(i + d - 1) % n] - a[i - 1]\\n        if t > m:\\n            m = t\\n            res = gr(i,s,n)\\n        elif t == m:\\n            res = min(res, gr(i,s,n))\\n    \\n    return res\\n    \\n\\ndef gr(i,s,n):\\n    res = (s-i) % n\\n    if (res <= 0):\\n        return n-res\\n    return res\\n\\nprint(solve(a,d,n,s))\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\ndef ps(l, i, j):\\n    if i > j:\\n        return l[-1]-l[i-1] + l[j]\\n    if i==0:\\n        return l[j]\\n    else:\\n        return l[j]-l[i-1]\\n\\nn =  int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\n\\nl = [a[0]]\\nfor i in a[1:]:\\n    l.append(l[-1]+i)\\nx = s-1\\ny = f-2\\nans = 0\\ntm = 0\\nfor i in range(n):\\n    temp = ps(l, x, y)\\n    if temp > ans:\\n        tm = i+1\\n        ans = temp \\n    x -= 1\\n    y -= 1\\n    if x < 0:\\n        x = n-1\\n    if y < 0:\\n        y = n-1\\nprint(tm)\", \"n = int(input())\\narr = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nnum = 0\\nfor i in range(s - 1, f - 1):\\n\\tnum += arr[i]\\n\\nt = 0\\ncurrent = num\\nfor time in range(n):\\n\\tcurrent = current - arr[(s - 1 + time) % n] + arr[(f - 1 + time) % n]\\n\\tif (current >= num):\\n\\t\\tnum = current\\n\\t\\tt = time\\n\\nprint(n - t)\\n\", \"# C\\n\\nimport copy\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nB = copy.deepcopy(A)\\nC = A + B  # A\\u3092\\u4e8c\\u3064\\u9023\\u7d50\\u3057\\u305f\\u30ea\\u30b9\\u30c8\\n\\nl = f - s\\nmax_list = []\\nmax_number = 0\\n\\nsumC = [0 for i in range(N)]\\n\\nsumC[0] = sum(C[0:l])\\nfor i in range(1, N):\\n    sumC[i] = sumC[i-1] + C[i+l-1] - C[i-1]\\n\\nfor i in range(N):\\n    if sumC[i] > max_number:\\n        max_list = [i]\\n        max_number = sumC[i]\\n    elif sumC[i] == max_number:\\n        max_list.append(i)\\n\\nans_list = []\\nfor j in max_list:\\n    for i in range(N):\\n        if j + i < N:\\n            if s + i <= N:\\n                A[j + i] = s + i\\n            else:\\n                A[j + i] = s + i - N\\n        else:\\n            if s + i <= N:\\n                A[j + i - N] = s + i\\n            else:\\n                A[j + i - N] = s + i - N\\n    ans_list.append(A[0])\\n\\nprint(min(ans_list))\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 2\\npref = [0] * n\\npref[0] = a[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + a[i]\\nmx = -1\\nans = 0\\nfor hour in range(n):\\n\\tleft = s - hour\\n\\tright = f - hour\\n\\tif left < 0:\\n\\t\\tleft += n\\n\\tif right < 0:\\n\\t\\tright += n\\n\\tres = -1\\n\\tif left <= right:\\n\\t\\tres = pref[right] - (pref[left - 1] if left > 0 else 0)\\n\\telse:\\n\\t\\tres = pref[n - 1] - (pref[left - 1] if left > 0 else 0) + pref[right]\\n\\tif res > mx:\\n\\t\\tmx = res\\n\\t\\tans = hour + 1\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nd = f-s\\nmsum = 0\\nminx = 10**6\\ntemp = a+a[:d+1]\\nsumt=0\\n\\nfor x in range(n + d + 1):\\n    sumt+=temp[x]\\n    if (x >= d):\\n        sumt-= temp[x-d]\\n    #print(sumt, (n - x + s + d- 2)%n + 1, x)\\n    if (sumt > msum):\\n        minx = 10**6\\n        msum = sumt\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\n    elif (sumt == msum):\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\nprint(minx)\\n\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\ns, f = list(map(int, input().split()))\\n\\ns -= 1\\nf -= 1\\n\\nm = int(1e+9)\\n\\nbest_sum = sum(A[s: f + 1])\\ncur_sum = best_sum\\nbest_i = 0\\n\\nfor i in range(1, n):\\n    cur_sum += A[(s - i + n) % n]\\n    cur_sum -= A[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\n\\nprint(best_i + 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f + 1])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\na = [0]\\nb =input().split()\\na = a+b\\nans  = 0\\nm = 0\\nfor i in range(1,n+1):\\n    a[i] = int(a[i])\\ns,f = input().split()\\ns = int(s)\\nf = int(f)\\nfor i in range(s,f):\\n    m+=a[i]\\nma = m\\nans = 1\\nstart = s-1\\ncount = f-1\\nif count<1:\\n    count = n\\nif start<1:\\n    start = n\\nfor i in range(2,n+1):\\n    m = m-a[count] + a[start]\\n    count = count-1\\n    start = start - 1\\n    if count==0:\\n        count = n\\n    if start==0:\\n        start = start=n\\n    if m>ma:\\n        ma = m\\n        ans = i\\nprint(ans) \", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\nA = [int(x) for x in input().split()]\\nA = A+A\\ns,f = list(map(int,input().split()))\\n\\nl = f-s\\nS = sum(A[:l])\\nmi = 0\\nmS = S\\nans = (s-1-mi)%n + 1\\nfor i in range(n-1):\\n    S = S + A[i+l] - A[i] \\n    if mS == S:\\n        mi = i+1\\n        ans = min(ans, (s-1-mi)%n + 1) # Update min\\n    if mS < S:\\n        mS = S\\n        mi = i+1\\n        ans = (s-1-mi)%n + 1 # Set min\\nprint(ans)\\n\", \"#import sys\\n#sys.stdin = open ('464-C.in', 'r')\\n\\nn = int(input())\\nn = n*2\\na = list(map(int,input().split()))\\na = a+a\\ns, f = list(map(int, input().split()))\\nsum = [0 for i in range(n+1)]\\nfor i in range(1,n+1):\\n    sum[i] = sum[i-1]+a[i-1]\\nran = f-s\\nmsum, idx = 0, 0\\nbb = int(1e18)\\nfor i in range(ran,n+1):\\n   # print (i, \\\" = \\\", sum[i]-sum[i-ran])\\n    if sum[i]-sum[i-ran] > msum:\\n        msum = sum[i] - sum[i - ran]\\n        idx = i-ran+1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        bb = idx\\n    elif sum[i]-sum[i-ran] == msum:\\n        idx = i - ran + 1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        if idx < bb:\\n            bb = idx\\n            msum = sum[i] - sum[i - ran]\\n\\n\\n#print (msum, \\\" \\\", idx)\\n\\nprint (bb)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns,f = [int(x) for x in input().split()]\\nzones = f-s\\ncurrans = 1\\ncurrmax = sum(a[s-1 : f-2])\\nans=1\\nmaxppl = currmax\\nfst = s-1\\nlst = f-2\\nfor currans in range(2, n+1):\\n    currmax += a[fst-1 if fst > 0 else n-1]\\n    currmax -= a[lst]\\n    fst = fst-1 if fst > 0 else n-1\\n    lst = lst - 1 if lst > 0 else n - 1\\n    if currmax > maxppl:\\n        maxppl = currmax\\n        ans = currans\\nprint(ans)\\n\", \"n=int(input())\\na=[int(i) for i in input().split()]\\ns,f=(int(i) for i in input().split())\\npref=[a[0]]\\nfor i in range(1,n):\\n\\tpref.append(a[i]+pref[i-1])\\n\\t\\ndef nb_people(strt, end):\\n\\tif strt<=end:\\n\\t\\tif strt==0:\\n\\t\\t\\treturn pref[end]\\n\\t\\telse:\\n\\t\\t\\treturn pref[end]-pref[strt-1]\\n\\telse:\\n\\t\\tret = pref[end]+pref[n-1]\\n\\t\\tif strt>0:\\n\\t\\t\\tret-=pref[strt-1]\\n\\t\\treturn ret\\n\\t\\nmax_people=0\\nopt_h=0\\nfor h in range(1,n+1):\\n\\tstrt=s-h+1#\\u00e0 h heures ds le 1er fuseau o\\u00f9 est - il s heures ?\\n\\tif strt<=0:\\n\\t\\tstrt+=n\\n\\tend =f-h#pareil avec f-1\\n\\tif end<=0:\\n\\t\\tend+=n\\n\\ttmp_people = nb_people(strt-1, end-1)\\n\\t#print(\\\"h\\\",h,\\\"strt\\\", strt, \\\"end\\\", end,\\\"tmp_people\\\",tmp_people)\\n\\tif tmp_people>max_people:\\n\\t\\tmax_people=tmp_people\\n\\t\\topt_h = h\\nprint(opt_h)\\n\", \"from sys import stdin as si\\nfrom collections import Counter as c\\n\\n\\nclass Solution:\\n\\n    def bazinga(self, n,m, k):\\n        mnp = sum(m[k[0]-1:k[1]-1])    # min number of participants\\n        diff = k[1]-k[0]\\n        mxp,ans = mnp, 0              # maximizing participants\\n        for i in range(1,n):\\n            # print (i,diff, mxp,mnp, sum(m[i: diff+i]))\\n            mxp +=  m[(k[0]-i-1 + n) % n]\\n            mxp -= m[(k[1]-i-1 + n) % n]\\n            if mxp > mnp:\\n                mnp,ans = mxp, i\\n        return ans +1\\n\\n\\ndef __starting_point():\\n    #for i in range(int(si.readline().strip())):\\n    n = int(si.readline().strip())\\n    m = list(map(int, si.readline().strip().split()))\\n    k = tuple(map(int, si.readline().strip().split()))\\n    S = Solution()\\n    print(S.bazinga(n, m, k))\\n\\n\\n\\n'''\\nhttp://codeforces.com/contest/939/problem/C\\n'''\\n__starting_point()\", \"n = int(input())\\na = [0] + list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nw = f - s\\nmax_s = cur_s = sum(a[s:f])\\nmax_h = cur_h = s\\n\\nfor i in range(2, n+1):\\n\\tcur_h -= 1\\n\\tif cur_h == 0: \\n\\t\\tcur_h = n\\n\\tj = i + w - 1\\n\\tif j > n:\\n\\t\\tj -= n\\n\\tcur_s = cur_s - a[i-1] + a[j]\\n\\tif (cur_s > max_s) or (cur_s == max_s and cur_h < max_h):\\n\\t\\tmax_s = cur_s\\n\\t\\tmax_h = cur_h\\n\\t\\t\\nprint(max_h)\\n\\t\\n\\t\\n\", \"def main():\\n    n = int(input())\\n\\n    a = [int(x) for x in input().split()]\\n    a += a\\n\\n    s, f = [int(x) for x in input().split()]\\n\\n    dp = [0 for _ in range(2 * n + 1)]\\n    for i in range(2 * n):\\n        dp[i + 1] = dp[i] + a[i]\\n\\n    ans, sum = 0, 0\\n\\n    for i in range(n):\\n        cur_sum = dp[f + n - i - 1] - dp[s + n - i - 1]\\n\\n        if cur_sum > sum:\\n            ans = i\\n            sum = cur_sum\\n\\n    ans += 1\\n    print(ans)        \\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nps = [ int(a) for a in input().split() ]\\ns,f = [ int(a) for a in input().split() ]\\n\\nwindow = f-s\\nps += ps[:window]\\n\\ndef f(x):\\n    return (s-1-x)%n + 1\\n\\nanswers = []\\nc = m = sum(ps[:window])\\nfor i in range(n):\\n    if c > m:\\n        answers = [f(i)]\\n        m = c\\n    elif c == m:\\n        answers += [f(i)]\\n    c += ps[i+window]-ps[i]\\n\\nprint(min(answers))\", \"h = int(input())\\nppl = [int(x) for x in input().split()]\\nsl = [int(x) for x in input().split()]\\nn = sl[1] - sl[0] if sl[1] > sl[0] else sl[1] - sl[0] + h\\nm = 0\\nindex = 0\\ntemp = sum(ppl[0:n])\\nans = []\\nfor i in range(h):\\n    if m < temp:\\n        m = temp \\n        ans.clear()\\n        ans.append(i)\\n    elif m == temp:\\n        ans.append(i)\\n    temp -= ppl[i]\\n    temp += ppl[(i+n) % h]\\nres = [(sl[0] + h - index - 1) % h + 1  for index in ans]\\n# print(n)\\n# print(m)\\nprint(min(res))\\n\\n    \\n\", \"# Q.C\\nn = int(input())\\na = input().split(\\\" \\\")\\na = list(map(int,a))\\ns,f = list(map(int, input().split(\\\" \\\")))\\na.insert(0,0)\\n\\nx = 1\\nxm = x\\nli = s-x+1\\nri = f-x\\ntotalm = sum(a[i] for i in range(li,ri+1))\\ntotal = totalm\\n\\nfor x in range(2, n+1):\\n    li -= 1\\n    if li == 0:\\n        li = n\\n    total += a[li]\\n    total -= a[ri]\\n    ri -= 1\\n    if ri == 0:\\n        ri = n\\n    if total > totalm:\\n        totalm = total\\n        xm = x\\nprint(xm)\", \"n = int(input())\\n\\ninp = input().split(\\\" \\\")\\n\\npeople = []\\nfor i in range(n):\\n\\tpeople.append(int(inp[i]))\\n\\ninp = input().split(\\\" \\\")\\nstart = int(inp[0])\\nend = int(inp[1])\\ndiff = end - start\\n\\noptimal = 1\\npeople = people + people\\nm = sum(people[0: diff])\\nprev_sum = m\\n\\nfor i in range(1, n):\\n\\toffset = min(diff, n - i)\\n\\tprev_sum -= people[i - 1]\\n\\tprev_sum += people[i + diff - 1]\\n\\n\\tif prev_sum > m:\\n\\t\\tm = prev_sum\\n\\t\\toptimal = i + diff\\n\\t\\toptimal = (end - optimal) % n\\n\\t\\tif optimal == 0:\\n\\t\\t\\toptimal = n\\n\\t\\t\\t\\n\\tif prev_sum == m:\\n\\t\\toptimal2 = i + diff\\n\\t\\toptimal2 = (end - optimal2) % n\\n\\t\\tif optimal2 == 0:\\n\\t\\t\\toptimal2 = n\\n\\n\\t\\tif optimal2 < optimal:\\n\\t\\t\\toptimal = optimal2\\n\\nif m == 0:\\n\\toptimal = 1\\n\\nprint(optimal)\\n\"]",
        "difficulty": "interview",
        "input": "50\n2847 339 1433 128 5933 4805 4277 5697 2574 9638 6992 5045 2254 7675 7503 3802 4012 1388 5307 3652 4764 214 9507 1832 118 7737 8279 9826 9941 250 8894 1871 616 147 9249 8867 1076 7551 5165 4709 1376 5758 4581 6670 8775 9351 4750 5294 9850 9793\n11 36\n",
        "output": "36\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/939/C"
    },
    {
        "id": 1945,
        "task_id": 2086,
        "test_case_id": 7,
        "question": "In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time \"0 hours\", instead of it \"n hours\" is used. When local time in the 1-st timezone is 1 hour, local time in the i-th timezone is i hours.\n\nSome online programming contests platform wants to conduct a contest that lasts for an hour in such a way that its beginning coincides with beginning of some hour (in all time zones). The platform knows, that there are a_{i} people from i-th timezone who want to participate in the contest. Each person will participate if and only if the contest starts no earlier than s hours 00 minutes local time and ends not later than f hours 00 minutes local time. Values s and f are equal for all time zones. If the contest starts at f hours 00 minutes local time, the person won't participate in it.\n\nHelp platform select such an hour, that the number of people who will participate in the contest is maximum. \n\n\n-----Input-----\n\nThe first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of hours in day.\n\nThe second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10 000), where a_{i} is the number of people in the i-th timezone who want to participate in the contest.\n\nThe third line contains two space-separated integers s and f (1 ≤ s < f ≤ n).\n\n\n-----Output-----\n\nOutput a single integer — the time of the beginning of the contest (in the first timezone local time), such that the number of participants will be maximum possible. If there are many answers, output the smallest among them.\n\n\n-----Examples-----\nInput\n3\n1 2 3\n1 3\n\nOutput\n3\n\nInput\n5\n1 2 3 4 1\n1 3\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example, it's optimal to start competition at 3 hours (in first timezone). In this case, it will be 1 hour in the second timezone and 2 hours in the third timezone. Only one person from the first timezone won't participate.\n\nIn second example only people from the third and the fourth timezones will participate.",
        "solutions": "[\"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = [int(i) for i in input().split()]\\na = a + a\\nln = f - s\\nans = sum(a[:ln])\\nmx = ans\\nh = s\\nfor i in range(n - 1):\\n    ans = ans - a[i] + a[i + ln]\\n    if ans > mx:\\n        ans = mx\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n  \\n        h = k\\n    elif ans == mx:\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n    \\n        h = min(h, k)\\nprint(h)\\n\", \"import sys, math\\n\\n#f = open('input/input_1', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\na = list(map(int, f.readline().split()))\\nstart, end = list(map(int, f.readline().split()))\\n\\ntime_len = end-start\\nsum_p = 0\\nmax_sum = -1\\nmax_sum_end = 10000000\\nfor i in range(N*2):\\n  if i >= time_len:\\n    sum_p -= a[(i-time_len)%N]\\n  sum_p += a[i % N]\\n  ans = (2*N + end - i - 1) % N\\n  if ans == 0:\\n    ans = N\\n  if i >= time_len-1 and \\\\\\n    (max_sum < sum_p or (max_sum == sum_p and max_sum_end > ans)):\\n    max_sum = sum_p\\n    max_sum_end = ans\\n\\nprint(max_sum_end)\\n\\n'''\\n5\\n10 2 3 4 10\\n1 5\\n\\n1 2 3 4 5\\n4 5 1 2 3\\n'''\\n\", \"n = int(input())\\nL = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\ncount = 0\\ncount_max = 0\\nans = 0\\nfor i in range(s - 1, f - 1):\\n    count += L[i]\\nfor i in range(n):\\n    count -= L[f - 1]\\n    s -= 1\\n    f -= 1\\n    if s == -1:\\n        s = n - 1\\n    if f == -1:\\n        f = n - 1\\n    count += L[s]\\n    if count > count_max:\\n        count_max = count\\n        ans = i\\nprint(ans + 1) \\n\", \"R = lambda : map(int, input().split())\\n\\nn = int(input())\\na = list(R())\\ns,f = R()\\n\\nd = f-s\\n\\ndef solve(a,d,n,s):\\n    if (n < d + 1):\\n        return s\\n\\n    t = 0\\n    for i in range(0, d):\\n        t += a[i]\\n\\n    m = t\\n    res = s\\n    for i in range(1, n):\\n        t += a[(i + d - 1) % n] - a[i - 1]\\n        if t > m:\\n            m = t\\n            res = gr(i,s,n)\\n        elif t == m:\\n            res = min(res, gr(i,s,n))\\n    \\n    return res\\n    \\n\\ndef gr(i,s,n):\\n    res = (s-i) % n\\n    if (res <= 0):\\n        return n-res\\n    return res\\n\\nprint(solve(a,d,n,s))\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\ndef ps(l, i, j):\\n    if i > j:\\n        return l[-1]-l[i-1] + l[j]\\n    if i==0:\\n        return l[j]\\n    else:\\n        return l[j]-l[i-1]\\n\\nn =  int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\n\\nl = [a[0]]\\nfor i in a[1:]:\\n    l.append(l[-1]+i)\\nx = s-1\\ny = f-2\\nans = 0\\ntm = 0\\nfor i in range(n):\\n    temp = ps(l, x, y)\\n    if temp > ans:\\n        tm = i+1\\n        ans = temp \\n    x -= 1\\n    y -= 1\\n    if x < 0:\\n        x = n-1\\n    if y < 0:\\n        y = n-1\\nprint(tm)\", \"n = int(input())\\narr = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nnum = 0\\nfor i in range(s - 1, f - 1):\\n\\tnum += arr[i]\\n\\nt = 0\\ncurrent = num\\nfor time in range(n):\\n\\tcurrent = current - arr[(s - 1 + time) % n] + arr[(f - 1 + time) % n]\\n\\tif (current >= num):\\n\\t\\tnum = current\\n\\t\\tt = time\\n\\nprint(n - t)\\n\", \"# C\\n\\nimport copy\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nB = copy.deepcopy(A)\\nC = A + B  # A\\u3092\\u4e8c\\u3064\\u9023\\u7d50\\u3057\\u305f\\u30ea\\u30b9\\u30c8\\n\\nl = f - s\\nmax_list = []\\nmax_number = 0\\n\\nsumC = [0 for i in range(N)]\\n\\nsumC[0] = sum(C[0:l])\\nfor i in range(1, N):\\n    sumC[i] = sumC[i-1] + C[i+l-1] - C[i-1]\\n\\nfor i in range(N):\\n    if sumC[i] > max_number:\\n        max_list = [i]\\n        max_number = sumC[i]\\n    elif sumC[i] == max_number:\\n        max_list.append(i)\\n\\nans_list = []\\nfor j in max_list:\\n    for i in range(N):\\n        if j + i < N:\\n            if s + i <= N:\\n                A[j + i] = s + i\\n            else:\\n                A[j + i] = s + i - N\\n        else:\\n            if s + i <= N:\\n                A[j + i - N] = s + i\\n            else:\\n                A[j + i - N] = s + i - N\\n    ans_list.append(A[0])\\n\\nprint(min(ans_list))\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 2\\npref = [0] * n\\npref[0] = a[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + a[i]\\nmx = -1\\nans = 0\\nfor hour in range(n):\\n\\tleft = s - hour\\n\\tright = f - hour\\n\\tif left < 0:\\n\\t\\tleft += n\\n\\tif right < 0:\\n\\t\\tright += n\\n\\tres = -1\\n\\tif left <= right:\\n\\t\\tres = pref[right] - (pref[left - 1] if left > 0 else 0)\\n\\telse:\\n\\t\\tres = pref[n - 1] - (pref[left - 1] if left > 0 else 0) + pref[right]\\n\\tif res > mx:\\n\\t\\tmx = res\\n\\t\\tans = hour + 1\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nd = f-s\\nmsum = 0\\nminx = 10**6\\ntemp = a+a[:d+1]\\nsumt=0\\n\\nfor x in range(n + d + 1):\\n    sumt+=temp[x]\\n    if (x >= d):\\n        sumt-= temp[x-d]\\n    #print(sumt, (n - x + s + d- 2)%n + 1, x)\\n    if (sumt > msum):\\n        minx = 10**6\\n        msum = sumt\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\n    elif (sumt == msum):\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\nprint(minx)\\n\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\ns, f = list(map(int, input().split()))\\n\\ns -= 1\\nf -= 1\\n\\nm = int(1e+9)\\n\\nbest_sum = sum(A[s: f + 1])\\ncur_sum = best_sum\\nbest_i = 0\\n\\nfor i in range(1, n):\\n    cur_sum += A[(s - i + n) % n]\\n    cur_sum -= A[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\n\\nprint(best_i + 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f + 1])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\na = [0]\\nb =input().split()\\na = a+b\\nans  = 0\\nm = 0\\nfor i in range(1,n+1):\\n    a[i] = int(a[i])\\ns,f = input().split()\\ns = int(s)\\nf = int(f)\\nfor i in range(s,f):\\n    m+=a[i]\\nma = m\\nans = 1\\nstart = s-1\\ncount = f-1\\nif count<1:\\n    count = n\\nif start<1:\\n    start = n\\nfor i in range(2,n+1):\\n    m = m-a[count] + a[start]\\n    count = count-1\\n    start = start - 1\\n    if count==0:\\n        count = n\\n    if start==0:\\n        start = start=n\\n    if m>ma:\\n        ma = m\\n        ans = i\\nprint(ans) \", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\nA = [int(x) for x in input().split()]\\nA = A+A\\ns,f = list(map(int,input().split()))\\n\\nl = f-s\\nS = sum(A[:l])\\nmi = 0\\nmS = S\\nans = (s-1-mi)%n + 1\\nfor i in range(n-1):\\n    S = S + A[i+l] - A[i] \\n    if mS == S:\\n        mi = i+1\\n        ans = min(ans, (s-1-mi)%n + 1) # Update min\\n    if mS < S:\\n        mS = S\\n        mi = i+1\\n        ans = (s-1-mi)%n + 1 # Set min\\nprint(ans)\\n\", \"#import sys\\n#sys.stdin = open ('464-C.in', 'r')\\n\\nn = int(input())\\nn = n*2\\na = list(map(int,input().split()))\\na = a+a\\ns, f = list(map(int, input().split()))\\nsum = [0 for i in range(n+1)]\\nfor i in range(1,n+1):\\n    sum[i] = sum[i-1]+a[i-1]\\nran = f-s\\nmsum, idx = 0, 0\\nbb = int(1e18)\\nfor i in range(ran,n+1):\\n   # print (i, \\\" = \\\", sum[i]-sum[i-ran])\\n    if sum[i]-sum[i-ran] > msum:\\n        msum = sum[i] - sum[i - ran]\\n        idx = i-ran+1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        bb = idx\\n    elif sum[i]-sum[i-ran] == msum:\\n        idx = i - ran + 1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        if idx < bb:\\n            bb = idx\\n            msum = sum[i] - sum[i - ran]\\n\\n\\n#print (msum, \\\" \\\", idx)\\n\\nprint (bb)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns,f = [int(x) for x in input().split()]\\nzones = f-s\\ncurrans = 1\\ncurrmax = sum(a[s-1 : f-2])\\nans=1\\nmaxppl = currmax\\nfst = s-1\\nlst = f-2\\nfor currans in range(2, n+1):\\n    currmax += a[fst-1 if fst > 0 else n-1]\\n    currmax -= a[lst]\\n    fst = fst-1 if fst > 0 else n-1\\n    lst = lst - 1 if lst > 0 else n - 1\\n    if currmax > maxppl:\\n        maxppl = currmax\\n        ans = currans\\nprint(ans)\\n\", \"n=int(input())\\na=[int(i) for i in input().split()]\\ns,f=(int(i) for i in input().split())\\npref=[a[0]]\\nfor i in range(1,n):\\n\\tpref.append(a[i]+pref[i-1])\\n\\t\\ndef nb_people(strt, end):\\n\\tif strt<=end:\\n\\t\\tif strt==0:\\n\\t\\t\\treturn pref[end]\\n\\t\\telse:\\n\\t\\t\\treturn pref[end]-pref[strt-1]\\n\\telse:\\n\\t\\tret = pref[end]+pref[n-1]\\n\\t\\tif strt>0:\\n\\t\\t\\tret-=pref[strt-1]\\n\\t\\treturn ret\\n\\t\\nmax_people=0\\nopt_h=0\\nfor h in range(1,n+1):\\n\\tstrt=s-h+1#\\u00e0 h heures ds le 1er fuseau o\\u00f9 est - il s heures ?\\n\\tif strt<=0:\\n\\t\\tstrt+=n\\n\\tend =f-h#pareil avec f-1\\n\\tif end<=0:\\n\\t\\tend+=n\\n\\ttmp_people = nb_people(strt-1, end-1)\\n\\t#print(\\\"h\\\",h,\\\"strt\\\", strt, \\\"end\\\", end,\\\"tmp_people\\\",tmp_people)\\n\\tif tmp_people>max_people:\\n\\t\\tmax_people=tmp_people\\n\\t\\topt_h = h\\nprint(opt_h)\\n\", \"from sys import stdin as si\\nfrom collections import Counter as c\\n\\n\\nclass Solution:\\n\\n    def bazinga(self, n,m, k):\\n        mnp = sum(m[k[0]-1:k[1]-1])    # min number of participants\\n        diff = k[1]-k[0]\\n        mxp,ans = mnp, 0              # maximizing participants\\n        for i in range(1,n):\\n            # print (i,diff, mxp,mnp, sum(m[i: diff+i]))\\n            mxp +=  m[(k[0]-i-1 + n) % n]\\n            mxp -= m[(k[1]-i-1 + n) % n]\\n            if mxp > mnp:\\n                mnp,ans = mxp, i\\n        return ans +1\\n\\n\\ndef __starting_point():\\n    #for i in range(int(si.readline().strip())):\\n    n = int(si.readline().strip())\\n    m = list(map(int, si.readline().strip().split()))\\n    k = tuple(map(int, si.readline().strip().split()))\\n    S = Solution()\\n    print(S.bazinga(n, m, k))\\n\\n\\n\\n'''\\nhttp://codeforces.com/contest/939/problem/C\\n'''\\n__starting_point()\", \"n = int(input())\\na = [0] + list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nw = f - s\\nmax_s = cur_s = sum(a[s:f])\\nmax_h = cur_h = s\\n\\nfor i in range(2, n+1):\\n\\tcur_h -= 1\\n\\tif cur_h == 0: \\n\\t\\tcur_h = n\\n\\tj = i + w - 1\\n\\tif j > n:\\n\\t\\tj -= n\\n\\tcur_s = cur_s - a[i-1] + a[j]\\n\\tif (cur_s > max_s) or (cur_s == max_s and cur_h < max_h):\\n\\t\\tmax_s = cur_s\\n\\t\\tmax_h = cur_h\\n\\t\\t\\nprint(max_h)\\n\\t\\n\\t\\n\", \"def main():\\n    n = int(input())\\n\\n    a = [int(x) for x in input().split()]\\n    a += a\\n\\n    s, f = [int(x) for x in input().split()]\\n\\n    dp = [0 for _ in range(2 * n + 1)]\\n    for i in range(2 * n):\\n        dp[i + 1] = dp[i] + a[i]\\n\\n    ans, sum = 0, 0\\n\\n    for i in range(n):\\n        cur_sum = dp[f + n - i - 1] - dp[s + n - i - 1]\\n\\n        if cur_sum > sum:\\n            ans = i\\n            sum = cur_sum\\n\\n    ans += 1\\n    print(ans)        \\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nps = [ int(a) for a in input().split() ]\\ns,f = [ int(a) for a in input().split() ]\\n\\nwindow = f-s\\nps += ps[:window]\\n\\ndef f(x):\\n    return (s-1-x)%n + 1\\n\\nanswers = []\\nc = m = sum(ps[:window])\\nfor i in range(n):\\n    if c > m:\\n        answers = [f(i)]\\n        m = c\\n    elif c == m:\\n        answers += [f(i)]\\n    c += ps[i+window]-ps[i]\\n\\nprint(min(answers))\", \"h = int(input())\\nppl = [int(x) for x in input().split()]\\nsl = [int(x) for x in input().split()]\\nn = sl[1] - sl[0] if sl[1] > sl[0] else sl[1] - sl[0] + h\\nm = 0\\nindex = 0\\ntemp = sum(ppl[0:n])\\nans = []\\nfor i in range(h):\\n    if m < temp:\\n        m = temp \\n        ans.clear()\\n        ans.append(i)\\n    elif m == temp:\\n        ans.append(i)\\n    temp -= ppl[i]\\n    temp += ppl[(i+n) % h]\\nres = [(sl[0] + h - index - 1) % h + 1  for index in ans]\\n# print(n)\\n# print(m)\\nprint(min(res))\\n\\n    \\n\", \"# Q.C\\nn = int(input())\\na = input().split(\\\" \\\")\\na = list(map(int,a))\\ns,f = list(map(int, input().split(\\\" \\\")))\\na.insert(0,0)\\n\\nx = 1\\nxm = x\\nli = s-x+1\\nri = f-x\\ntotalm = sum(a[i] for i in range(li,ri+1))\\ntotal = totalm\\n\\nfor x in range(2, n+1):\\n    li -= 1\\n    if li == 0:\\n        li = n\\n    total += a[li]\\n    total -= a[ri]\\n    ri -= 1\\n    if ri == 0:\\n        ri = n\\n    if total > totalm:\\n        totalm = total\\n        xm = x\\nprint(xm)\", \"n = int(input())\\n\\ninp = input().split(\\\" \\\")\\n\\npeople = []\\nfor i in range(n):\\n\\tpeople.append(int(inp[i]))\\n\\ninp = input().split(\\\" \\\")\\nstart = int(inp[0])\\nend = int(inp[1])\\ndiff = end - start\\n\\noptimal = 1\\npeople = people + people\\nm = sum(people[0: diff])\\nprev_sum = m\\n\\nfor i in range(1, n):\\n\\toffset = min(diff, n - i)\\n\\tprev_sum -= people[i - 1]\\n\\tprev_sum += people[i + diff - 1]\\n\\n\\tif prev_sum > m:\\n\\t\\tm = prev_sum\\n\\t\\toptimal = i + diff\\n\\t\\toptimal = (end - optimal) % n\\n\\t\\tif optimal == 0:\\n\\t\\t\\toptimal = n\\n\\t\\t\\t\\n\\tif prev_sum == m:\\n\\t\\toptimal2 = i + diff\\n\\t\\toptimal2 = (end - optimal2) % n\\n\\t\\tif optimal2 == 0:\\n\\t\\t\\toptimal2 = n\\n\\n\\t\\tif optimal2 < optimal:\\n\\t\\t\\toptimal = optimal2\\n\\nif m == 0:\\n\\toptimal = 1\\n\\nprint(optimal)\\n\"]",
        "difficulty": "interview",
        "input": "100\n6072 8210 6405 1191 2533 8552 7594 8793 2207 8855 7415 6252 3433 2339 5532 3118 3054 5750 3690 9843 3881 1390 936 8611 7099 988 7730 3835 7065 5030 6932 6936 5531 5173 1331 8975 5454 1592 8516 328 1091 4368 8275 6462 8638 4002 5534 113 6295 5960 1688 3668 6604 9632 4214 8687 7950 3483 6149 4301 6607 1119 6466 6687 2042 6134 7008 1000 5627 7357 6998 6160 2003 4838 8478 5889 6486 470 7624 7581 524 9719 7029 6213 6963 8103 6892 7091 9451 520 2248 4482 633 3886 247 992 9861 2404 1677 4083\n75 95\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/939/C"
    },
    {
        "id": 1946,
        "task_id": 2086,
        "test_case_id": 8,
        "question": "In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time \"0 hours\", instead of it \"n hours\" is used. When local time in the 1-st timezone is 1 hour, local time in the i-th timezone is i hours.\n\nSome online programming contests platform wants to conduct a contest that lasts for an hour in such a way that its beginning coincides with beginning of some hour (in all time zones). The platform knows, that there are a_{i} people from i-th timezone who want to participate in the contest. Each person will participate if and only if the contest starts no earlier than s hours 00 minutes local time and ends not later than f hours 00 minutes local time. Values s and f are equal for all time zones. If the contest starts at f hours 00 minutes local time, the person won't participate in it.\n\nHelp platform select such an hour, that the number of people who will participate in the contest is maximum. \n\n\n-----Input-----\n\nThe first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of hours in day.\n\nThe second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10 000), where a_{i} is the number of people in the i-th timezone who want to participate in the contest.\n\nThe third line contains two space-separated integers s and f (1 ≤ s < f ≤ n).\n\n\n-----Output-----\n\nOutput a single integer — the time of the beginning of the contest (in the first timezone local time), such that the number of participants will be maximum possible. If there are many answers, output the smallest among them.\n\n\n-----Examples-----\nInput\n3\n1 2 3\n1 3\n\nOutput\n3\n\nInput\n5\n1 2 3 4 1\n1 3\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example, it's optimal to start competition at 3 hours (in first timezone). In this case, it will be 1 hour in the second timezone and 2 hours in the third timezone. Only one person from the first timezone won't participate.\n\nIn second example only people from the third and the fourth timezones will participate.",
        "solutions": "[\"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = [int(i) for i in input().split()]\\na = a + a\\nln = f - s\\nans = sum(a[:ln])\\nmx = ans\\nh = s\\nfor i in range(n - 1):\\n    ans = ans - a[i] + a[i + ln]\\n    if ans > mx:\\n        ans = mx\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n  \\n        h = k\\n    elif ans == mx:\\n        k = s + (n - (i + 2) + 1)\\n        if k > n:\\n            k -= n    \\n        h = min(h, k)\\nprint(h)\\n\", \"import sys, math\\n\\n#f = open('input/input_1', 'r')\\nf = sys.stdin\\n\\nN = int(f.readline())\\na = list(map(int, f.readline().split()))\\nstart, end = list(map(int, f.readline().split()))\\n\\ntime_len = end-start\\nsum_p = 0\\nmax_sum = -1\\nmax_sum_end = 10000000\\nfor i in range(N*2):\\n  if i >= time_len:\\n    sum_p -= a[(i-time_len)%N]\\n  sum_p += a[i % N]\\n  ans = (2*N + end - i - 1) % N\\n  if ans == 0:\\n    ans = N\\n  if i >= time_len-1 and \\\\\\n    (max_sum < sum_p or (max_sum == sum_p and max_sum_end > ans)):\\n    max_sum = sum_p\\n    max_sum_end = ans\\n\\nprint(max_sum_end)\\n\\n'''\\n5\\n10 2 3 4 10\\n1 5\\n\\n1 2 3 4 5\\n4 5 1 2 3\\n'''\\n\", \"n = int(input())\\nL = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\ncount = 0\\ncount_max = 0\\nans = 0\\nfor i in range(s - 1, f - 1):\\n    count += L[i]\\nfor i in range(n):\\n    count -= L[f - 1]\\n    s -= 1\\n    f -= 1\\n    if s == -1:\\n        s = n - 1\\n    if f == -1:\\n        f = n - 1\\n    count += L[s]\\n    if count > count_max:\\n        count_max = count\\n        ans = i\\nprint(ans + 1) \\n\", \"R = lambda : map(int, input().split())\\n\\nn = int(input())\\na = list(R())\\ns,f = R()\\n\\nd = f-s\\n\\ndef solve(a,d,n,s):\\n    if (n < d + 1):\\n        return s\\n\\n    t = 0\\n    for i in range(0, d):\\n        t += a[i]\\n\\n    m = t\\n    res = s\\n    for i in range(1, n):\\n        t += a[(i + d - 1) % n] - a[i - 1]\\n        if t > m:\\n            m = t\\n            res = gr(i,s,n)\\n        elif t == m:\\n            res = min(res, gr(i,s,n))\\n    \\n    return res\\n    \\n\\ndef gr(i,s,n):\\n    res = (s-i) % n\\n    if (res <= 0):\\n        return n-res\\n    return res\\n\\nprint(solve(a,d,n,s))\", \"#This code sucks, you know it and I know it.  \\n#Move on and call me an idiot later.\\n\\ndef ps(l, i, j):\\n    if i > j:\\n        return l[-1]-l[i-1] + l[j]\\n    if i==0:\\n        return l[j]\\n    else:\\n        return l[j]-l[i-1]\\n\\nn =  int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\n\\nl = [a[0]]\\nfor i in a[1:]:\\n    l.append(l[-1]+i)\\nx = s-1\\ny = f-2\\nans = 0\\ntm = 0\\nfor i in range(n):\\n    temp = ps(l, x, y)\\n    if temp > ans:\\n        tm = i+1\\n        ans = temp \\n    x -= 1\\n    y -= 1\\n    if x < 0:\\n        x = n-1\\n    if y < 0:\\n        y = n-1\\nprint(tm)\", \"n = int(input())\\narr = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nnum = 0\\nfor i in range(s - 1, f - 1):\\n\\tnum += arr[i]\\n\\nt = 0\\ncurrent = num\\nfor time in range(n):\\n\\tcurrent = current - arr[(s - 1 + time) % n] + arr[(f - 1 + time) % n]\\n\\tif (current >= num):\\n\\t\\tnum = current\\n\\t\\tt = time\\n\\nprint(n - t)\\n\", \"# C\\n\\nimport copy\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nB = copy.deepcopy(A)\\nC = A + B  # A\\u3092\\u4e8c\\u3064\\u9023\\u7d50\\u3057\\u305f\\u30ea\\u30b9\\u30c8\\n\\nl = f - s\\nmax_list = []\\nmax_number = 0\\n\\nsumC = [0 for i in range(N)]\\n\\nsumC[0] = sum(C[0:l])\\nfor i in range(1, N):\\n    sumC[i] = sumC[i-1] + C[i+l-1] - C[i-1]\\n\\nfor i in range(N):\\n    if sumC[i] > max_number:\\n        max_list = [i]\\n        max_number = sumC[i]\\n    elif sumC[i] == max_number:\\n        max_list.append(i)\\n\\nans_list = []\\nfor j in max_list:\\n    for i in range(N):\\n        if j + i < N:\\n            if s + i <= N:\\n                A[j + i] = s + i\\n            else:\\n                A[j + i] = s + i - N\\n        else:\\n            if s + i <= N:\\n                A[j + i - N] = s + i\\n            else:\\n                A[j + i - N] = s + i - N\\n    ans_list.append(A[0])\\n\\nprint(min(ans_list))\\n\", \"n = int(input())\\na = [int(i) for i in input().split()]\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 2\\npref = [0] * n\\npref[0] = a[0]\\nfor i in range(1, n):\\n\\tpref[i] = pref[i - 1] + a[i]\\nmx = -1\\nans = 0\\nfor hour in range(n):\\n\\tleft = s - hour\\n\\tright = f - hour\\n\\tif left < 0:\\n\\t\\tleft += n\\n\\tif right < 0:\\n\\t\\tright += n\\n\\tres = -1\\n\\tif left <= right:\\n\\t\\tres = pref[right] - (pref[left - 1] if left > 0 else 0)\\n\\telse:\\n\\t\\tres = pref[n - 1] - (pref[left - 1] if left > 0 else 0) + pref[right]\\n\\tif res > mx:\\n\\t\\tmx = res\\n\\t\\tans = hour + 1\\nprint(ans)\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nd = f-s\\nmsum = 0\\nminx = 10**6\\ntemp = a+a[:d+1]\\nsumt=0\\n\\nfor x in range(n + d + 1):\\n    sumt+=temp[x]\\n    if (x >= d):\\n        sumt-= temp[x-d]\\n    #print(sumt, (n - x + s + d- 2)%n + 1, x)\\n    if (sumt > msum):\\n        minx = 10**6\\n        msum = sumt\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\n    elif (sumt == msum):\\n        minx = min(minx, (n-x+s+d - 2)%n + 1)\\nprint(minx)\\n\", \"n = int(input())\\n\\nA = list(map(int, input().split()))\\n\\ns, f = list(map(int, input().split()))\\n\\ns -= 1\\nf -= 1\\n\\nm = int(1e+9)\\n\\nbest_sum = sum(A[s: f + 1])\\ncur_sum = best_sum\\nbest_i = 0\\n\\nfor i in range(1, n):\\n    cur_sum += A[(s - i + n) % n]\\n    cur_sum -= A[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\n\\nprint(best_i + 1)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f + 1])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\na = [0]\\nb =input().split()\\na = a+b\\nans  = 0\\nm = 0\\nfor i in range(1,n+1):\\n    a[i] = int(a[i])\\ns,f = input().split()\\ns = int(s)\\nf = int(f)\\nfor i in range(s,f):\\n    m+=a[i]\\nma = m\\nans = 1\\nstart = s-1\\ncount = f-1\\nif count<1:\\n    count = n\\nif start<1:\\n    start = n\\nfor i in range(2,n+1):\\n    m = m-a[count] + a[start]\\n    count = count-1\\n    start = start - 1\\n    if count==0:\\n        count = n\\n    if start==0:\\n        start = start=n\\n    if m>ma:\\n        ma = m\\n        ans = i\\nprint(ans) \", \"n = int(input())\\na = list(map(int, input().split()))\\ns, f = map(int, input().split())\\ns -= 1\\nf -= 1\\nbest_sum = sum(a[s:f])\\nbest_i = 0\\ncur_sum = best_sum\\nfor i in range(1, n):\\n    cur_sum += a[(s - i + n) % n]\\n    cur_sum -= a[(f - i + n) % n]\\n    if cur_sum > best_sum:\\n        best_sum = cur_sum\\n        best_i = i\\nprint(best_i + 1)\", \"n = int(input())\\nA = [int(x) for x in input().split()]\\nA = A+A\\ns,f = list(map(int,input().split()))\\n\\nl = f-s\\nS = sum(A[:l])\\nmi = 0\\nmS = S\\nans = (s-1-mi)%n + 1\\nfor i in range(n-1):\\n    S = S + A[i+l] - A[i] \\n    if mS == S:\\n        mi = i+1\\n        ans = min(ans, (s-1-mi)%n + 1) # Update min\\n    if mS < S:\\n        mS = S\\n        mi = i+1\\n        ans = (s-1-mi)%n + 1 # Set min\\nprint(ans)\\n\", \"#import sys\\n#sys.stdin = open ('464-C.in', 'r')\\n\\nn = int(input())\\nn = n*2\\na = list(map(int,input().split()))\\na = a+a\\ns, f = list(map(int, input().split()))\\nsum = [0 for i in range(n+1)]\\nfor i in range(1,n+1):\\n    sum[i] = sum[i-1]+a[i-1]\\nran = f-s\\nmsum, idx = 0, 0\\nbb = int(1e18)\\nfor i in range(ran,n+1):\\n   # print (i, \\\" = \\\", sum[i]-sum[i-ran])\\n    if sum[i]-sum[i-ran] > msum:\\n        msum = sum[i] - sum[i - ran]\\n        idx = i-ran+1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        bb = idx\\n    elif sum[i]-sum[i-ran] == msum:\\n        idx = i - ran + 1\\n        if idx < s:\\n            idx = s - idx + 1\\n        elif idx > s:\\n            idx = 1 - abs(s - idx)\\n            idx += n\\n        else:\\n            idx = 1\\n        idx = idx % (int(n / 2))\\n        if (idx == 0):\\n            idx = int(n / 2)\\n        if idx < bb:\\n            bb = idx\\n            msum = sum[i] - sum[i - ran]\\n\\n\\n#print (msum, \\\" \\\", idx)\\n\\nprint (bb)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns,f = [int(x) for x in input().split()]\\nzones = f-s\\ncurrans = 1\\ncurrmax = sum(a[s-1 : f-2])\\nans=1\\nmaxppl = currmax\\nfst = s-1\\nlst = f-2\\nfor currans in range(2, n+1):\\n    currmax += a[fst-1 if fst > 0 else n-1]\\n    currmax -= a[lst]\\n    fst = fst-1 if fst > 0 else n-1\\n    lst = lst - 1 if lst > 0 else n - 1\\n    if currmax > maxppl:\\n        maxppl = currmax\\n        ans = currans\\nprint(ans)\\n\", \"n=int(input())\\na=[int(i) for i in input().split()]\\ns,f=(int(i) for i in input().split())\\npref=[a[0]]\\nfor i in range(1,n):\\n\\tpref.append(a[i]+pref[i-1])\\n\\t\\ndef nb_people(strt, end):\\n\\tif strt<=end:\\n\\t\\tif strt==0:\\n\\t\\t\\treturn pref[end]\\n\\t\\telse:\\n\\t\\t\\treturn pref[end]-pref[strt-1]\\n\\telse:\\n\\t\\tret = pref[end]+pref[n-1]\\n\\t\\tif strt>0:\\n\\t\\t\\tret-=pref[strt-1]\\n\\t\\treturn ret\\n\\t\\nmax_people=0\\nopt_h=0\\nfor h in range(1,n+1):\\n\\tstrt=s-h+1#\\u00e0 h heures ds le 1er fuseau o\\u00f9 est - il s heures ?\\n\\tif strt<=0:\\n\\t\\tstrt+=n\\n\\tend =f-h#pareil avec f-1\\n\\tif end<=0:\\n\\t\\tend+=n\\n\\ttmp_people = nb_people(strt-1, end-1)\\n\\t#print(\\\"h\\\",h,\\\"strt\\\", strt, \\\"end\\\", end,\\\"tmp_people\\\",tmp_people)\\n\\tif tmp_people>max_people:\\n\\t\\tmax_people=tmp_people\\n\\t\\topt_h = h\\nprint(opt_h)\\n\", \"from sys import stdin as si\\nfrom collections import Counter as c\\n\\n\\nclass Solution:\\n\\n    def bazinga(self, n,m, k):\\n        mnp = sum(m[k[0]-1:k[1]-1])    # min number of participants\\n        diff = k[1]-k[0]\\n        mxp,ans = mnp, 0              # maximizing participants\\n        for i in range(1,n):\\n            # print (i,diff, mxp,mnp, sum(m[i: diff+i]))\\n            mxp +=  m[(k[0]-i-1 + n) % n]\\n            mxp -= m[(k[1]-i-1 + n) % n]\\n            if mxp > mnp:\\n                mnp,ans = mxp, i\\n        return ans +1\\n\\n\\ndef __starting_point():\\n    #for i in range(int(si.readline().strip())):\\n    n = int(si.readline().strip())\\n    m = list(map(int, si.readline().strip().split()))\\n    k = tuple(map(int, si.readline().strip().split()))\\n    S = Solution()\\n    print(S.bazinga(n, m, k))\\n\\n\\n\\n'''\\nhttp://codeforces.com/contest/939/problem/C\\n'''\\n__starting_point()\", \"n = int(input())\\na = [0] + list(map(int, input().split()))\\ns, f = list(map(int, input().split()))\\n\\nw = f - s\\nmax_s = cur_s = sum(a[s:f])\\nmax_h = cur_h = s\\n\\nfor i in range(2, n+1):\\n\\tcur_h -= 1\\n\\tif cur_h == 0: \\n\\t\\tcur_h = n\\n\\tj = i + w - 1\\n\\tif j > n:\\n\\t\\tj -= n\\n\\tcur_s = cur_s - a[i-1] + a[j]\\n\\tif (cur_s > max_s) or (cur_s == max_s and cur_h < max_h):\\n\\t\\tmax_s = cur_s\\n\\t\\tmax_h = cur_h\\n\\t\\t\\nprint(max_h)\\n\\t\\n\\t\\n\", \"def main():\\n    n = int(input())\\n\\n    a = [int(x) for x in input().split()]\\n    a += a\\n\\n    s, f = [int(x) for x in input().split()]\\n\\n    dp = [0 for _ in range(2 * n + 1)]\\n    for i in range(2 * n):\\n        dp[i + 1] = dp[i] + a[i]\\n\\n    ans, sum = 0, 0\\n\\n    for i in range(n):\\n        cur_sum = dp[f + n - i - 1] - dp[s + n - i - 1]\\n\\n        if cur_sum > sum:\\n            ans = i\\n            sum = cur_sum\\n\\n    ans += 1\\n    print(ans)        \\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nps = [ int(a) for a in input().split() ]\\ns,f = [ int(a) for a in input().split() ]\\n\\nwindow = f-s\\nps += ps[:window]\\n\\ndef f(x):\\n    return (s-1-x)%n + 1\\n\\nanswers = []\\nc = m = sum(ps[:window])\\nfor i in range(n):\\n    if c > m:\\n        answers = [f(i)]\\n        m = c\\n    elif c == m:\\n        answers += [f(i)]\\n    c += ps[i+window]-ps[i]\\n\\nprint(min(answers))\", \"h = int(input())\\nppl = [int(x) for x in input().split()]\\nsl = [int(x) for x in input().split()]\\nn = sl[1] - sl[0] if sl[1] > sl[0] else sl[1] - sl[0] + h\\nm = 0\\nindex = 0\\ntemp = sum(ppl[0:n])\\nans = []\\nfor i in range(h):\\n    if m < temp:\\n        m = temp \\n        ans.clear()\\n        ans.append(i)\\n    elif m == temp:\\n        ans.append(i)\\n    temp -= ppl[i]\\n    temp += ppl[(i+n) % h]\\nres = [(sl[0] + h - index - 1) % h + 1  for index in ans]\\n# print(n)\\n# print(m)\\nprint(min(res))\\n\\n    \\n\", \"# Q.C\\nn = int(input())\\na = input().split(\\\" \\\")\\na = list(map(int,a))\\ns,f = list(map(int, input().split(\\\" \\\")))\\na.insert(0,0)\\n\\nx = 1\\nxm = x\\nli = s-x+1\\nri = f-x\\ntotalm = sum(a[i] for i in range(li,ri+1))\\ntotal = totalm\\n\\nfor x in range(2, n+1):\\n    li -= 1\\n    if li == 0:\\n        li = n\\n    total += a[li]\\n    total -= a[ri]\\n    ri -= 1\\n    if ri == 0:\\n        ri = n\\n    if total > totalm:\\n        totalm = total\\n        xm = x\\nprint(xm)\", \"n = int(input())\\n\\ninp = input().split(\\\" \\\")\\n\\npeople = []\\nfor i in range(n):\\n\\tpeople.append(int(inp[i]))\\n\\ninp = input().split(\\\" \\\")\\nstart = int(inp[0])\\nend = int(inp[1])\\ndiff = end - start\\n\\noptimal = 1\\npeople = people + people\\nm = sum(people[0: diff])\\nprev_sum = m\\n\\nfor i in range(1, n):\\n\\toffset = min(diff, n - i)\\n\\tprev_sum -= people[i - 1]\\n\\tprev_sum += people[i + diff - 1]\\n\\n\\tif prev_sum > m:\\n\\t\\tm = prev_sum\\n\\t\\toptimal = i + diff\\n\\t\\toptimal = (end - optimal) % n\\n\\t\\tif optimal == 0:\\n\\t\\t\\toptimal = n\\n\\t\\t\\t\\n\\tif prev_sum == m:\\n\\t\\toptimal2 = i + diff\\n\\t\\toptimal2 = (end - optimal2) % n\\n\\t\\tif optimal2 == 0:\\n\\t\\t\\toptimal2 = n\\n\\n\\t\\tif optimal2 < optimal:\\n\\t\\t\\toptimal = optimal2\\n\\nif m == 0:\\n\\toptimal = 1\\n\\nprint(optimal)\\n\"]",
        "difficulty": "interview",
        "input": "2\n5 1\n1 2\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/939/C"
    },
    {
        "id": 1947,
        "task_id": 2190,
        "test_case_id": 1,
        "question": "You are given $n$ positive integers $a_1, \\ldots, a_n$, and an integer $k \\geq 2$. Count the number of pairs $i, j$ such that $1 \\leq i < j \\leq n$, and there exists an integer $x$ such that $a_i \\cdot a_j = x^k$.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $k$ ($2 \\leq n \\leq 10^5$, $2 \\leq k \\leq 100$).\n\nThe second line contains $n$ integers $a_1, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^5$).\n\n\n-----Output-----\n\nPrint a single integer — the number of suitable pairs.\n\n\n-----Example-----\nInput\n6 3\n1 3 9 8 24 1\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the sample case, the suitable pairs are: $a_1 \\cdot a_4 = 8 = 2^3$; $a_1 \\cdot a_6 = 1 = 1^3$; $a_2 \\cdot a_3 = 27 = 3^3$; $a_3 \\cdot a_5 = 216 = 6^3$; $a_4 \\cdot a_6 = 8 = 2^3$.",
        "solutions": "[\"def f(n):\\n    Ans = []\\n    d = 2\\n    while d * d <= n:\\n        if n % d == 0:\\n            Ans.append(d)\\n            n //= d\\n        else:\\n            d += 1\\n    if n > 1:\\n        Ans.append(n)\\n    return Ans\\n\\n\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\n\\nm = {}\\nc = 0\\nfor i in arr:\\n    r = {}\\n    d = 2\\n    while d * d <= i:\\n        if i % d == 0:\\n            r[d] = (r.get(d, 0) + 1) % k\\n            i //= d\\n        else:\\n            d += 1\\n    if i > 1:\\n        r[i] = (r.get(i, 0) + 1) % k\\n    r = tuple([x for x in list(r.items()) if x[1]])\\n    r2 = tuple([(x[0], k - x[1]) for x in r])\\n    c += m.get(r2, 0)\\n    m[r] = m.get(r, 0) + 1\\nprint(c)\\n\", \"from collections import defaultdict\\nimport math\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\n\\nans = 0\\nhm = defaultdict(int)\\n\\nfor i in range(n):\\n    x = 2\\n    t = []\\n    t1 = []\\n    y = a[i]\\n    while x<=math.sqrt(a[i]):\\n        if a[i]%x==0:\\n            c = 0\\n            while y%x==0:\\n                y = y//x\\n                c += 1\\n            if c%k>0:\\n                t.append((x,c%k))\\n                t1.append((x,k-(c%k)))\\n        x += 1\\n    if y>1:\\n        t.append((y,1%k))\\n        t1.append((y,k-(1%k)))\\n\\n    ans += hm[tuple(t1)]\\n    hm[tuple(t)] += 1\\n\\nprint(ans)\\n        \\n\", \"from collections import defaultdict\\n\\ntotal = 0 \\nimport math\\ndic = defaultdict(int)\\nn, k = list(map(int, input().split()))\\nz = list(map(int, input().split()))\\nfor ii in z:\\n\\n    i = ii\\n    x = []\\n    x2=[]\\n    a = 2\\n    while a<=math.sqrt(ii):\\n        co = 0\\n        while i % a == 0:\\n            i = i//a\\n            co += 1\\n        co=co%k\\n        if co:\\n            x.append((a, co))\\n            x2.append((a, k-co))\\n        a += 1\\n    if i>1:\\n        x.append((i,1))\\n        x2.append((i,k-1))\\n    # print(i)\\n    # print(x)\\n    # print(dic)\\n    dic[tuple(x)] += 1\\n    total += dic[tuple(x2)]\\n        # print(f\\\"ans:{x} and {inver(x)}\\\")\\n    if(x2 == x):\\n        total-=1\\n\\n\\n\\n# print(x)\\nprint(total)\\n\", \"n,k=list(map(int,input().split()))\\narr=list(map(int,input().split()))\\nans=0\\nd={}\\nfor i in range(n):\\n\\tx=2\\n\\ta=[]\\n\\tb=[]\\n\\ty=arr[i]\\n\\twhile x*x<=arr[i]:\\n\\t\\tif arr[i]%x==0:\\n\\t\\t\\tc=0\\n\\t\\t\\twhile y%x==0:\\n\\t\\t\\t\\ty=y//x\\n\\t\\t\\t\\tc+=1\\n\\t\\t\\tif c%k>0:\\n\\t\\t\\t\\ta.append((x,c%k))\\n\\t\\t\\t\\tb.append((x,k-(c%k)))\\n\\t\\tx+=1\\n\\tif y>1:\\n\\t\\ta.append((y,1%k))\\n\\t\\tb.append((y,k-(1%k)))\\n\\ttry:\\n\\t\\tans+=d[tuple(b)]\\n\\texcept:\\n\\t\\tpass\\n\\ttry:\\n\\t\\td[tuple(a)]+=1\\n\\texcept:\\n\\t\\td[tuple(a)]=1\\nprint(ans)\\n\", \"n, k = map(int, input().split())\\n*a, = map(int, input().split())\\nd = {}\\nans = 0\\nfor i in a:\\n    x, j, tmp1, tmp2 = i, 2, [], []\\n    while j * j <= i:\\n        c = 0\\n        while x % j == 0:\\n            c += 1\\n            x //= j\\n        if c % k:\\n            tmp2.append((j, k - c % k))\\n            tmp1.append((j, c % k))\\n        j += 1\\n    if x > 1:\\n        tmp1.append((x, 1))\\n        tmp2.append((x, k - 1))\\n    tmp1, tmp2 = tuple(tmp1), tuple(tmp2)\\n    ans += d.get(tmp2, 0)\\n    d[tmp1] = d.get(tmp1, 0) + 1\\nprint(ans)\", \"import math\\nfrom collections import Counter\\n \\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n \\nans = 0\\nprev = Counter()\\nfor x in a:\\n\\tsig = []\\n\\tp = 2\\n\\twhile p <= math.sqrt(x):\\n\\t\\tcnt = 0\\n\\t\\twhile x % p == 0:\\n\\t\\t\\tcnt += 1\\n\\t\\t\\tx = x // p\\n \\n\\t\\tcnt = cnt % k\\n\\t\\tif cnt > 0:\\n\\t\\t\\tsig.append((p, cnt))\\n \\n\\t\\tp += 1\\n \\n\\tif x > 1:\\n\\t\\tsig.append((x, 1))\\n \\n\\tcom_sig = []\\n\\tfor p, val in sig:\\n\\t\\tcom_sig.append((p, (k - val) % k))\\n \\n\\tans += prev[tuple(sig)]\\n\\tprev[tuple(com_sig)] += 1\\n \\nprint(ans)\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\nd = {}\\nans = 0\\n\\nfor el in a:\\n    i = 2\\n    a = []\\n    b = []\\n    while i*i <= el:\\n        cnt = 0\\n        while not(el%i):\\n            el //= i\\n            cnt += 1\\n        if cnt%k:\\n            a.append((i, cnt%k))\\n            b.append((i, k-(cnt%k)))\\n        i += 1\\n    \\n    if el > 1:\\n        a.append((el, 1))\\n        b.append((el, k-1))\\n\\n    a = tuple(a)\\n    b = tuple(b)\\n\\n    ans += d.get(b, 0)\\n    d[a] = d.get(a, 0)+1\\n    \\nprint(ans)\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 2/11/20\\n\\n\\\"\\\"\\\"\\n\\nimport collections\\nimport time\\nimport os\\nimport sys\\nimport bisect\\nimport heapq\\nfrom typing import List\\nimport math\\n\\n\\ndef factors(val):\\n    wc = []\\n    for i in range(2, int(math.sqrt(val)) + 2):\\n        if i > val:\\n            break\\n        if val % i == 0:\\n            c = 0\\n            while val % i == 0:\\n                c += 1\\n                val //= i\\n            wc.append((i, c))\\n    if val > 1:\\n        wc.append((val, 1))\\n    return wc\\n\\n\\ndef expand(fc, maxd, k):\\n    def dfs(index, mul):\\n        if index >= len(fc):\\n            return [mul]\\n        \\n        w, c = fc[index]\\n        d = k - (c % k) if c % k != 0 else 0\\n        x = []\\n        t = mul * (w ** d)\\n        while t <= maxd:\\n            x.extend(dfs(index + 1, t))\\n            d += k\\n            t *= w**k\\n        \\n        return x\\n        \\n    return dfs(0, 1)\\n    \\ndef solve(N, K, A):\\n    wc = collections.defaultdict(int)\\n    ans = 0\\n    for v in A:\\n        fc = factors(v)\\n        fc = [(f, c % K) for f, c in fc if c % K != 0]\\n        key = '_'.join(['{}+{}'.format(f, c) for f, c in fc])\\n        cov = [(f, K-c) for f, c in fc]\\n        ckey = '_'.join(['{}+{}'.format(f, c) for f, c in cov])\\n        ans += wc[ckey]\\n        wc[key] += 1\\n\\n    return ans\\n    \\nN, K = map(int, input().split())\\nA = [int(x) for x in input().split()]\\nprint(solve(N, K, A))\", \"from math import *\\n\\nn, k = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nma = max(a)\\n\\np = []\\nprime = [True] * (ma + 1)\\nprime[0] = False\\nprime[1] = False\\nfor i in range(2, ma + 1):\\n    if prime[i]:\\n        p.append(i)\\n        if i**2 <= n:\\n            for j in range(i**2, ma + 1, i):\\n                prime[j] = False\\n\\n\\ndef factor(x):\\n    res = {}\\n    sq = ceil(sqrt(x))\\n    for i in p:\\n        if i > sq or x <= 1:\\n            break\\n        if x % i == 0:\\n            res[i] = 0\\n            while x % i == 0:\\n                res[i] += 1\\n                x //= i\\n    if x > 1:\\n        res[x] = 1\\n    nres = []\\n    for j in res:\\n        if res[j] % k > 0:\\n            nres.append((j, res[j] % k))\\n    \\n    return tuple(nres)\\n\\nd = {}\\nfor i in range(n):\\n    f = factor(a[i])\\n    #print(f, a[i])\\n    if f not in d:\\n        d[f] = 1\\n    else:\\n        d[f] += 1\\n        \\nans = 0\\n#print(d)\\nfor x in d:\\n    y = []\\n    for i in x:\\n        y.append((i[0], k - i[1]))\\n    y = tuple(y)\\n    if y in d:\\n        if y != x:\\n            ans += d[x] * d[y]\\n        else:\\n            ans += d[x] * (d[y] - 1)\\n    #print(x, y, ans)\\n\\nprint(ans//2)\\n\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\ndel mark\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\n\\nd = defaultdict(int)\\n\\nans = 0\\nfor i in a:\\n\\tt, t1 = [], []\\n\\tfor j in primes:\\n\\t\\tif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt.append((j,z))\\n\\t\\t\\t\\tt1.append((j,k-z))\\n\\t\\telif i == 1:break\\n\\tif i != 1:\\n\\t\\tt.append((i,1))\\n\\t\\tt1.append((i,k-1))\\n\\n\\tt = tuple(t)\\n\\tt1 = tuple(t1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"import math\\n\\n\\ndef fac(a):\\n    ans = {}\\n\\n    for i in range(2, int(math.sqrt(a)) + 1):\\n        if a % i == 0:\\n            ans[i] = 0\\n            while a % i == 0:\\n                a //= i\\n                ans[i] += 1\\n\\n    ans[a] = 1\\n\\n    return ans\\n\\n\\ndef inverse(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = (k - a[j] % k) % k\\n\\n    return buf\\n\\n\\ndef normal(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = a[j] % k\\n\\n    return buf\\n\\n\\ndef getHash(d):\\n    ans = 1\\n    for i in d.keys():\\n        ans *= i ** d[i]\\n    return ans\\n\\n\\nn, k = map(int, input().split(' '))\\n\\na = [i for i in map(int, input().split(' '))]\\n\\nb = [i for i in map(fac, a)]\\n\\nfactors = {}\\n\\nfor i in b:\\n    buf = getHash(inverse(i, k))\\n    if buf in factors.keys():\\n        factors[buf] += 1\\n    else:\\n        factors[buf] = 1\\n\\nans = 0\\n\\nfor i in range(len(b)):\\n    b[i] = normal(b[i], k)\\n    if getHash(b[i]) == getHash(inverse(b[i], k)):\\n        ans -= 1\\n\\nfor i in map(getHash, b):\\n    if i in factors.keys():\\n        ans += factors[i]\\n\\nprint(ans // 2)\", \"import sys\\ninput =  lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\n\\ndef factors(n, k):\\n    i = 2\\n    sq = int(n**0.5)+1\\n    di={}\\n    while n != 1:\\n        if n % i == 0:\\n            cur = 0\\n            while n % i == 0:\\n                n = n // i\\n                cur += 1\\n            if cur % k != 0:\\n                di[i] = cur % k\\n        i += 1\\n        if i > sq:break\\n    if n != 1:\\n        di[n] = 1\\n    return \\\"|\\\".join(\\\"%d:%d\\\" % (i, di[i]) for i in di)\\n\\nft = {}\\ndi = {}\\n\\nfor i in a:\\n    ft[i] = factors(i, k)\\n    di[ft[i]] = 1 if ft[i] not in di else di[ft[i]] + 1\\n\\nans = 0\\nfor i in a:\\n    ftt = ft[i]\\n    if ftt == \\\"\\\":\\n        ans += di[ftt] - 1\\n    else:\\n        dx = {}\\n        for oo in ftt.split(\\\"|\\\"):\\n            x, y = map(int, oo.split(\\\":\\\"))\\n            dx[x] = - y % k\\n        ftt2 = \\\"|\\\".join(\\\"%d:%d\\\" % (i, dx[i]) for i in dx)\\n        if ftt == ftt2:\\n            ans += di[ftt2] - 1\\n        else:\\n            if ftt2 in di:\\n                ans += di[ftt2]\\n\\nprint(ans//2)\", \"from collections import defaultdict as dc\\ndic=dc(lambda:0)\\nx,y=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nsiv=[0]*(max(s)+1)\\nln=len(siv)\\nsiv[1]=1;\\n\\nfor n in range(2,ln):\\n    if siv[n]==0:\\n        siv[n]=n\\n        for k in range(2*n,ln,n):\\n            if siv[k]==0:\\n                siv[k]=n\\n\\ndef prf(x):\\n    dic=dc(lambda:0)\\n    while x>1:\\n        d=siv[x]\\n        dic[siv[x]]+=1\\n        x//=siv[x]\\n    \\n    return dic\\n\\ndef req(dic,k):\\n    cur=dic\\n    for n in cur:\\n        cur[n]%=k\\n    for n in cur:\\n        cur[n]=(k-cur[n])%k\\n    tot=1\\n    for n in cur:\\n        tot*=(n**cur[n])\\n    return tot\\n\\ndef conv(x,k):\\n    dicc=prf(x)\\n    for n in dicc:\\n        dicc[n]%=k\\n    tot=1\\n    for n in dicc:\\n        tot*=(n**dicc[n])\\n\\n    return tot\\n\\nres=0\\nfor n in s:\\n    re=req(prf(n),y)\\n    res+=dic[re]\\n    dic[conv(n,y)]+=1\\n\\nprint(res)\\n\", \"from math import sqrt\\ndef gd(n, k):\\n    ans = 1\\n    obrans = 1\\n    for i in range(2, int(sqrt(n) + 1)):\\n        j = 0\\n        while n % i == 0:\\n            j += 1\\n            n //= i\\n        ans *= pow(i, j%k)\\n        obrans *= pow(i, (-j)%k)\\n    ans *= n\\n    obrans *= pow(n, (k-1))\\n    return ans, obrans\\nn, k = map(int,input().split())\\noba = set()\\ndct = {}\\nfor i in list(map(int,input().split())):\\n    a,b = gd(i, k)\\n    dct[a] = dct.get(a, 0) + 1\\n    a,b = min(a,b), max(a,b)\\n    oba.add((a,b))\\nans = 0\\nfor i, j in oba:\\n    if i == j:\\n        ans += (dct.get(i, 0)  * dct.get(j, 0) - dct.get(i, 0)) // 2\\n    else:\\n        ans += dct.get(i, 0) * dct.get(j, 0)\\nprint(ans)\", \"import itertools as it\\nfrom collections import defaultdict\\nimport os\\nimport sys\\n\\n\\ndef sieve(n):\\n    is_prime = [True] * n\\n\\n    for candidate in it.chain([2], list(range(3, int(n ** 0.5) + 1, 2))):\\n        if is_prime[candidate]:\\n            for k in range(2 * candidate, n, candidate):\\n                is_prime[k] = False\\n\\n    primes = [idx for idx, k in enumerate(is_prime) if idx >= 2 and k]\\n    return primes\\n\\n\\ndef factorize(n, primes, k):\\n    factors = []\\n    number = n\\n    for f in primes:\\n        count = 0\\n        while number % f == 0:\\n            count += 1\\n            number //= f\\n\\n        if count % k:\\n            factors.append((f, count % k))\\n\\n        if f > number:\\n            break\\n\\n    if number > 1:\\n        factors.append((number, 1))\\n\\n    return tuple(factors)\\n\\n\\ndef solve(arr, k):\\n    total = 0\\n    d = defaultdict(int, {})\\n    primes = sieve(int(1e5 ** 0.5) + 10)\\n    for a in arr:\\n        fac = factorize(a, primes, k)\\n        fac_complement = tuple((f, k - count) for f, count in fac)\\n        total += d[fac_complement]\\n        d[fac] += 1\\n\\n    return total\\n\\n\\ndef pp(input):\\n    # T = int(input())\\n    # for t in range(T):\\n    n, k = list(map(int, input().strip().split()))\\n    arr = list(map(int, input().strip().split()))\\n    print(solve(arr, k))\\n\\n\\nif \\\"paalto\\\" in os.getcwd():\\n    from string_source import string_source, codeforces_parse\\n\\n    pp(\\n        string_source(\\n            \\\"\\\"\\\"6 3\\n1 3 9 8 24 1\\\"\\\"\\\"\\n        )\\n    )\\nelse:\\n    pp(sys.stdin.readline)\\n\", \"from collections import defaultdict\\nimport sys as _sys\\n\\n\\ndef main():\\n    n, k = _read_ints()\\n    a = tuple(_read_ints())\\n    result = find_good_pairs_n(a, k)\\n    print(result)\\n\\n\\ndef _read_line():\\n    result = _sys.stdin.readline()\\n    assert result[-1] == \\\"\\\\n\\\"\\n    return result[:-1]\\n\\n\\ndef _read_ints():\\n    return list(map(int, _read_line().split()))\\n\\n\\ndef find_good_pairs_n(sequence, k):\\n    sequence = tuple(sequence)\\n    factors_seq = tuple(map(_find_prime_factors, sequence))\\n    \\n    factors_seq = [[(kv[0], kv[1] % k) for kv in list(factors.items())] for factors in factors_seq]\\n    factors_seq = [[kv for kv in factors if kv[1] > 0] for factors in factors_seq]\\n    factors_seq = list(map(sorted, factors_seq))\\n    factors_seq = tuple(map(tuple, factors_seq))\\n    \\n    counter = defaultdict(int)\\n    for factors in factors_seq:\\n        counter[factors] += 1\\n    \\n    result = 0\\n    for factors in factors_seq:\\n        necessary_factors = tuple((factor, k - amount) for factor, amount in factors)\\n        result += counter[necessary_factors]\\n        if factors == necessary_factors:\\n            result -= 1\\n    \\n    assert result % 2 == 0\\n    result //= 2\\n    return result\\n\\n\\ndef _find_prime_factors(x):\\n    result = dict()\\n    \\n    if x % 2 == 0:\\n        factor_2_n = 0\\n        while x & 1 == 0:\\n            x >>= 1\\n            factor_2_n += 1\\n        result[2] = factor_2_n\\n    \\n    factor = 3\\n    while x != 1 and factor * factor <= x:\\n        if x % factor == 0:\\n            factor_n = 0\\n            while x % factor == 0:\\n                x //= factor\\n                factor_n += 1\\n            result[factor] = factor_n\\n        factor += 2\\n\\n    if x != 1:\\n        result[x] = 1\\n\\n    return result\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"from collections import defaultdict\\n\\nclass Primes():\\n    def __init__(self, N):\\n        self.N = N\\n        self.prime = {i for i in range(2, self.N+1)}\\n        self.spf = [-1]*(N + 1)\\n        for i in range(2, self.N+1):\\n            if i in self.prime:\\n                self.spf[i] = i\\n                for j in range(i*2, self.N+1, i):\\n                    if j in self.prime:\\n                        self.spf[j] = i\\n                        self.prime.remove(j)\\n\\n    def fact(self,Number):\\n        v = Number\\n        d = defaultdict(int)\\n        while v > 1:\\n            x = self.spf[v]\\n            d[x] += 1\\n            v//=x\\n        return d\\n\\n\\nP = Primes(10**5)\\n\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ncnt = [0]*(10**5 + 1)\\nfor v in a:\\n    cnt[v] += 1\\n\\nans = 0\\nfor v in a:\\n    cnt[v] -= 1\\n    d = P.fact(v)\\n    res = 1\\n    for num,order in list(d.items()):\\n        res *= pow(num,(k-order%k)%k)\\n    if res <= 10**5:\\n        for i in range(1,1000):\\n            if pow(i,k)*res > 10**5:\\n                break\\n            ans += cnt[pow(i,k)*res]\\nprint(ans)\\n\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "6 3\n1 3 9 8 24 1\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1225/D"
    },
    {
        "id": 1948,
        "task_id": 2190,
        "test_case_id": 2,
        "question": "You are given $n$ positive integers $a_1, \\ldots, a_n$, and an integer $k \\geq 2$. Count the number of pairs $i, j$ such that $1 \\leq i < j \\leq n$, and there exists an integer $x$ such that $a_i \\cdot a_j = x^k$.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $k$ ($2 \\leq n \\leq 10^5$, $2 \\leq k \\leq 100$).\n\nThe second line contains $n$ integers $a_1, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^5$).\n\n\n-----Output-----\n\nPrint a single integer — the number of suitable pairs.\n\n\n-----Example-----\nInput\n6 3\n1 3 9 8 24 1\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the sample case, the suitable pairs are: $a_1 \\cdot a_4 = 8 = 2^3$; $a_1 \\cdot a_6 = 1 = 1^3$; $a_2 \\cdot a_3 = 27 = 3^3$; $a_3 \\cdot a_5 = 216 = 6^3$; $a_4 \\cdot a_6 = 8 = 2^3$.",
        "solutions": "[\"def f(n):\\n    Ans = []\\n    d = 2\\n    while d * d <= n:\\n        if n % d == 0:\\n            Ans.append(d)\\n            n //= d\\n        else:\\n            d += 1\\n    if n > 1:\\n        Ans.append(n)\\n    return Ans\\n\\n\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\n\\nm = {}\\nc = 0\\nfor i in arr:\\n    r = {}\\n    d = 2\\n    while d * d <= i:\\n        if i % d == 0:\\n            r[d] = (r.get(d, 0) + 1) % k\\n            i //= d\\n        else:\\n            d += 1\\n    if i > 1:\\n        r[i] = (r.get(i, 0) + 1) % k\\n    r = tuple([x for x in list(r.items()) if x[1]])\\n    r2 = tuple([(x[0], k - x[1]) for x in r])\\n    c += m.get(r2, 0)\\n    m[r] = m.get(r, 0) + 1\\nprint(c)\\n\", \"from collections import defaultdict\\nimport math\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\n\\nans = 0\\nhm = defaultdict(int)\\n\\nfor i in range(n):\\n    x = 2\\n    t = []\\n    t1 = []\\n    y = a[i]\\n    while x<=math.sqrt(a[i]):\\n        if a[i]%x==0:\\n            c = 0\\n            while y%x==0:\\n                y = y//x\\n                c += 1\\n            if c%k>0:\\n                t.append((x,c%k))\\n                t1.append((x,k-(c%k)))\\n        x += 1\\n    if y>1:\\n        t.append((y,1%k))\\n        t1.append((y,k-(1%k)))\\n\\n    ans += hm[tuple(t1)]\\n    hm[tuple(t)] += 1\\n\\nprint(ans)\\n        \\n\", \"from collections import defaultdict\\n\\ntotal = 0 \\nimport math\\ndic = defaultdict(int)\\nn, k = list(map(int, input().split()))\\nz = list(map(int, input().split()))\\nfor ii in z:\\n\\n    i = ii\\n    x = []\\n    x2=[]\\n    a = 2\\n    while a<=math.sqrt(ii):\\n        co = 0\\n        while i % a == 0:\\n            i = i//a\\n            co += 1\\n        co=co%k\\n        if co:\\n            x.append((a, co))\\n            x2.append((a, k-co))\\n        a += 1\\n    if i>1:\\n        x.append((i,1))\\n        x2.append((i,k-1))\\n    # print(i)\\n    # print(x)\\n    # print(dic)\\n    dic[tuple(x)] += 1\\n    total += dic[tuple(x2)]\\n        # print(f\\\"ans:{x} and {inver(x)}\\\")\\n    if(x2 == x):\\n        total-=1\\n\\n\\n\\n# print(x)\\nprint(total)\\n\", \"n,k=list(map(int,input().split()))\\narr=list(map(int,input().split()))\\nans=0\\nd={}\\nfor i in range(n):\\n\\tx=2\\n\\ta=[]\\n\\tb=[]\\n\\ty=arr[i]\\n\\twhile x*x<=arr[i]:\\n\\t\\tif arr[i]%x==0:\\n\\t\\t\\tc=0\\n\\t\\t\\twhile y%x==0:\\n\\t\\t\\t\\ty=y//x\\n\\t\\t\\t\\tc+=1\\n\\t\\t\\tif c%k>0:\\n\\t\\t\\t\\ta.append((x,c%k))\\n\\t\\t\\t\\tb.append((x,k-(c%k)))\\n\\t\\tx+=1\\n\\tif y>1:\\n\\t\\ta.append((y,1%k))\\n\\t\\tb.append((y,k-(1%k)))\\n\\ttry:\\n\\t\\tans+=d[tuple(b)]\\n\\texcept:\\n\\t\\tpass\\n\\ttry:\\n\\t\\td[tuple(a)]+=1\\n\\texcept:\\n\\t\\td[tuple(a)]=1\\nprint(ans)\\n\", \"n, k = map(int, input().split())\\n*a, = map(int, input().split())\\nd = {}\\nans = 0\\nfor i in a:\\n    x, j, tmp1, tmp2 = i, 2, [], []\\n    while j * j <= i:\\n        c = 0\\n        while x % j == 0:\\n            c += 1\\n            x //= j\\n        if c % k:\\n            tmp2.append((j, k - c % k))\\n            tmp1.append((j, c % k))\\n        j += 1\\n    if x > 1:\\n        tmp1.append((x, 1))\\n        tmp2.append((x, k - 1))\\n    tmp1, tmp2 = tuple(tmp1), tuple(tmp2)\\n    ans += d.get(tmp2, 0)\\n    d[tmp1] = d.get(tmp1, 0) + 1\\nprint(ans)\", \"import math\\nfrom collections import Counter\\n \\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n \\nans = 0\\nprev = Counter()\\nfor x in a:\\n\\tsig = []\\n\\tp = 2\\n\\twhile p <= math.sqrt(x):\\n\\t\\tcnt = 0\\n\\t\\twhile x % p == 0:\\n\\t\\t\\tcnt += 1\\n\\t\\t\\tx = x // p\\n \\n\\t\\tcnt = cnt % k\\n\\t\\tif cnt > 0:\\n\\t\\t\\tsig.append((p, cnt))\\n \\n\\t\\tp += 1\\n \\n\\tif x > 1:\\n\\t\\tsig.append((x, 1))\\n \\n\\tcom_sig = []\\n\\tfor p, val in sig:\\n\\t\\tcom_sig.append((p, (k - val) % k))\\n \\n\\tans += prev[tuple(sig)]\\n\\tprev[tuple(com_sig)] += 1\\n \\nprint(ans)\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\nd = {}\\nans = 0\\n\\nfor el in a:\\n    i = 2\\n    a = []\\n    b = []\\n    while i*i <= el:\\n        cnt = 0\\n        while not(el%i):\\n            el //= i\\n            cnt += 1\\n        if cnt%k:\\n            a.append((i, cnt%k))\\n            b.append((i, k-(cnt%k)))\\n        i += 1\\n    \\n    if el > 1:\\n        a.append((el, 1))\\n        b.append((el, k-1))\\n\\n    a = tuple(a)\\n    b = tuple(b)\\n\\n    ans += d.get(b, 0)\\n    d[a] = d.get(a, 0)+1\\n    \\nprint(ans)\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 2/11/20\\n\\n\\\"\\\"\\\"\\n\\nimport collections\\nimport time\\nimport os\\nimport sys\\nimport bisect\\nimport heapq\\nfrom typing import List\\nimport math\\n\\n\\ndef factors(val):\\n    wc = []\\n    for i in range(2, int(math.sqrt(val)) + 2):\\n        if i > val:\\n            break\\n        if val % i == 0:\\n            c = 0\\n            while val % i == 0:\\n                c += 1\\n                val //= i\\n            wc.append((i, c))\\n    if val > 1:\\n        wc.append((val, 1))\\n    return wc\\n\\n\\ndef expand(fc, maxd, k):\\n    def dfs(index, mul):\\n        if index >= len(fc):\\n            return [mul]\\n        \\n        w, c = fc[index]\\n        d = k - (c % k) if c % k != 0 else 0\\n        x = []\\n        t = mul * (w ** d)\\n        while t <= maxd:\\n            x.extend(dfs(index + 1, t))\\n            d += k\\n            t *= w**k\\n        \\n        return x\\n        \\n    return dfs(0, 1)\\n    \\ndef solve(N, K, A):\\n    wc = collections.defaultdict(int)\\n    ans = 0\\n    for v in A:\\n        fc = factors(v)\\n        fc = [(f, c % K) for f, c in fc if c % K != 0]\\n        key = '_'.join(['{}+{}'.format(f, c) for f, c in fc])\\n        cov = [(f, K-c) for f, c in fc]\\n        ckey = '_'.join(['{}+{}'.format(f, c) for f, c in cov])\\n        ans += wc[ckey]\\n        wc[key] += 1\\n\\n    return ans\\n    \\nN, K = map(int, input().split())\\nA = [int(x) for x in input().split()]\\nprint(solve(N, K, A))\", \"from math import *\\n\\nn, k = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nma = max(a)\\n\\np = []\\nprime = [True] * (ma + 1)\\nprime[0] = False\\nprime[1] = False\\nfor i in range(2, ma + 1):\\n    if prime[i]:\\n        p.append(i)\\n        if i**2 <= n:\\n            for j in range(i**2, ma + 1, i):\\n                prime[j] = False\\n\\n\\ndef factor(x):\\n    res = {}\\n    sq = ceil(sqrt(x))\\n    for i in p:\\n        if i > sq or x <= 1:\\n            break\\n        if x % i == 0:\\n            res[i] = 0\\n            while x % i == 0:\\n                res[i] += 1\\n                x //= i\\n    if x > 1:\\n        res[x] = 1\\n    nres = []\\n    for j in res:\\n        if res[j] % k > 0:\\n            nres.append((j, res[j] % k))\\n    \\n    return tuple(nres)\\n\\nd = {}\\nfor i in range(n):\\n    f = factor(a[i])\\n    #print(f, a[i])\\n    if f not in d:\\n        d[f] = 1\\n    else:\\n        d[f] += 1\\n        \\nans = 0\\n#print(d)\\nfor x in d:\\n    y = []\\n    for i in x:\\n        y.append((i[0], k - i[1]))\\n    y = tuple(y)\\n    if y in d:\\n        if y != x:\\n            ans += d[x] * d[y]\\n        else:\\n            ans += d[x] * (d[y] - 1)\\n    #print(x, y, ans)\\n\\nprint(ans//2)\\n\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\ndel mark\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\n\\nd = defaultdict(int)\\n\\nans = 0\\nfor i in a:\\n\\tt, t1 = [], []\\n\\tfor j in primes:\\n\\t\\tif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt.append((j,z))\\n\\t\\t\\t\\tt1.append((j,k-z))\\n\\t\\telif i == 1:break\\n\\tif i != 1:\\n\\t\\tt.append((i,1))\\n\\t\\tt1.append((i,k-1))\\n\\n\\tt = tuple(t)\\n\\tt1 = tuple(t1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"import math\\n\\n\\ndef fac(a):\\n    ans = {}\\n\\n    for i in range(2, int(math.sqrt(a)) + 1):\\n        if a % i == 0:\\n            ans[i] = 0\\n            while a % i == 0:\\n                a //= i\\n                ans[i] += 1\\n\\n    ans[a] = 1\\n\\n    return ans\\n\\n\\ndef inverse(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = (k - a[j] % k) % k\\n\\n    return buf\\n\\n\\ndef normal(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = a[j] % k\\n\\n    return buf\\n\\n\\ndef getHash(d):\\n    ans = 1\\n    for i in d.keys():\\n        ans *= i ** d[i]\\n    return ans\\n\\n\\nn, k = map(int, input().split(' '))\\n\\na = [i for i in map(int, input().split(' '))]\\n\\nb = [i for i in map(fac, a)]\\n\\nfactors = {}\\n\\nfor i in b:\\n    buf = getHash(inverse(i, k))\\n    if buf in factors.keys():\\n        factors[buf] += 1\\n    else:\\n        factors[buf] = 1\\n\\nans = 0\\n\\nfor i in range(len(b)):\\n    b[i] = normal(b[i], k)\\n    if getHash(b[i]) == getHash(inverse(b[i], k)):\\n        ans -= 1\\n\\nfor i in map(getHash, b):\\n    if i in factors.keys():\\n        ans += factors[i]\\n\\nprint(ans // 2)\", \"import sys\\ninput =  lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\n\\ndef factors(n, k):\\n    i = 2\\n    sq = int(n**0.5)+1\\n    di={}\\n    while n != 1:\\n        if n % i == 0:\\n            cur = 0\\n            while n % i == 0:\\n                n = n // i\\n                cur += 1\\n            if cur % k != 0:\\n                di[i] = cur % k\\n        i += 1\\n        if i > sq:break\\n    if n != 1:\\n        di[n] = 1\\n    return \\\"|\\\".join(\\\"%d:%d\\\" % (i, di[i]) for i in di)\\n\\nft = {}\\ndi = {}\\n\\nfor i in a:\\n    ft[i] = factors(i, k)\\n    di[ft[i]] = 1 if ft[i] not in di else di[ft[i]] + 1\\n\\nans = 0\\nfor i in a:\\n    ftt = ft[i]\\n    if ftt == \\\"\\\":\\n        ans += di[ftt] - 1\\n    else:\\n        dx = {}\\n        for oo in ftt.split(\\\"|\\\"):\\n            x, y = map(int, oo.split(\\\":\\\"))\\n            dx[x] = - y % k\\n        ftt2 = \\\"|\\\".join(\\\"%d:%d\\\" % (i, dx[i]) for i in dx)\\n        if ftt == ftt2:\\n            ans += di[ftt2] - 1\\n        else:\\n            if ftt2 in di:\\n                ans += di[ftt2]\\n\\nprint(ans//2)\", \"from collections import defaultdict as dc\\ndic=dc(lambda:0)\\nx,y=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nsiv=[0]*(max(s)+1)\\nln=len(siv)\\nsiv[1]=1;\\n\\nfor n in range(2,ln):\\n    if siv[n]==0:\\n        siv[n]=n\\n        for k in range(2*n,ln,n):\\n            if siv[k]==0:\\n                siv[k]=n\\n\\ndef prf(x):\\n    dic=dc(lambda:0)\\n    while x>1:\\n        d=siv[x]\\n        dic[siv[x]]+=1\\n        x//=siv[x]\\n    \\n    return dic\\n\\ndef req(dic,k):\\n    cur=dic\\n    for n in cur:\\n        cur[n]%=k\\n    for n in cur:\\n        cur[n]=(k-cur[n])%k\\n    tot=1\\n    for n in cur:\\n        tot*=(n**cur[n])\\n    return tot\\n\\ndef conv(x,k):\\n    dicc=prf(x)\\n    for n in dicc:\\n        dicc[n]%=k\\n    tot=1\\n    for n in dicc:\\n        tot*=(n**dicc[n])\\n\\n    return tot\\n\\nres=0\\nfor n in s:\\n    re=req(prf(n),y)\\n    res+=dic[re]\\n    dic[conv(n,y)]+=1\\n\\nprint(res)\\n\", \"from math import sqrt\\ndef gd(n, k):\\n    ans = 1\\n    obrans = 1\\n    for i in range(2, int(sqrt(n) + 1)):\\n        j = 0\\n        while n % i == 0:\\n            j += 1\\n            n //= i\\n        ans *= pow(i, j%k)\\n        obrans *= pow(i, (-j)%k)\\n    ans *= n\\n    obrans *= pow(n, (k-1))\\n    return ans, obrans\\nn, k = map(int,input().split())\\noba = set()\\ndct = {}\\nfor i in list(map(int,input().split())):\\n    a,b = gd(i, k)\\n    dct[a] = dct.get(a, 0) + 1\\n    a,b = min(a,b), max(a,b)\\n    oba.add((a,b))\\nans = 0\\nfor i, j in oba:\\n    if i == j:\\n        ans += (dct.get(i, 0)  * dct.get(j, 0) - dct.get(i, 0)) // 2\\n    else:\\n        ans += dct.get(i, 0) * dct.get(j, 0)\\nprint(ans)\", \"import itertools as it\\nfrom collections import defaultdict\\nimport os\\nimport sys\\n\\n\\ndef sieve(n):\\n    is_prime = [True] * n\\n\\n    for candidate in it.chain([2], list(range(3, int(n ** 0.5) + 1, 2))):\\n        if is_prime[candidate]:\\n            for k in range(2 * candidate, n, candidate):\\n                is_prime[k] = False\\n\\n    primes = [idx for idx, k in enumerate(is_prime) if idx >= 2 and k]\\n    return primes\\n\\n\\ndef factorize(n, primes, k):\\n    factors = []\\n    number = n\\n    for f in primes:\\n        count = 0\\n        while number % f == 0:\\n            count += 1\\n            number //= f\\n\\n        if count % k:\\n            factors.append((f, count % k))\\n\\n        if f > number:\\n            break\\n\\n    if number > 1:\\n        factors.append((number, 1))\\n\\n    return tuple(factors)\\n\\n\\ndef solve(arr, k):\\n    total = 0\\n    d = defaultdict(int, {})\\n    primes = sieve(int(1e5 ** 0.5) + 10)\\n    for a in arr:\\n        fac = factorize(a, primes, k)\\n        fac_complement = tuple((f, k - count) for f, count in fac)\\n        total += d[fac_complement]\\n        d[fac] += 1\\n\\n    return total\\n\\n\\ndef pp(input):\\n    # T = int(input())\\n    # for t in range(T):\\n    n, k = list(map(int, input().strip().split()))\\n    arr = list(map(int, input().strip().split()))\\n    print(solve(arr, k))\\n\\n\\nif \\\"paalto\\\" in os.getcwd():\\n    from string_source import string_source, codeforces_parse\\n\\n    pp(\\n        string_source(\\n            \\\"\\\"\\\"6 3\\n1 3 9 8 24 1\\\"\\\"\\\"\\n        )\\n    )\\nelse:\\n    pp(sys.stdin.readline)\\n\", \"from collections import defaultdict\\nimport sys as _sys\\n\\n\\ndef main():\\n    n, k = _read_ints()\\n    a = tuple(_read_ints())\\n    result = find_good_pairs_n(a, k)\\n    print(result)\\n\\n\\ndef _read_line():\\n    result = _sys.stdin.readline()\\n    assert result[-1] == \\\"\\\\n\\\"\\n    return result[:-1]\\n\\n\\ndef _read_ints():\\n    return list(map(int, _read_line().split()))\\n\\n\\ndef find_good_pairs_n(sequence, k):\\n    sequence = tuple(sequence)\\n    factors_seq = tuple(map(_find_prime_factors, sequence))\\n    \\n    factors_seq = [[(kv[0], kv[1] % k) for kv in list(factors.items())] for factors in factors_seq]\\n    factors_seq = [[kv for kv in factors if kv[1] > 0] for factors in factors_seq]\\n    factors_seq = list(map(sorted, factors_seq))\\n    factors_seq = tuple(map(tuple, factors_seq))\\n    \\n    counter = defaultdict(int)\\n    for factors in factors_seq:\\n        counter[factors] += 1\\n    \\n    result = 0\\n    for factors in factors_seq:\\n        necessary_factors = tuple((factor, k - amount) for factor, amount in factors)\\n        result += counter[necessary_factors]\\n        if factors == necessary_factors:\\n            result -= 1\\n    \\n    assert result % 2 == 0\\n    result //= 2\\n    return result\\n\\n\\ndef _find_prime_factors(x):\\n    result = dict()\\n    \\n    if x % 2 == 0:\\n        factor_2_n = 0\\n        while x & 1 == 0:\\n            x >>= 1\\n            factor_2_n += 1\\n        result[2] = factor_2_n\\n    \\n    factor = 3\\n    while x != 1 and factor * factor <= x:\\n        if x % factor == 0:\\n            factor_n = 0\\n            while x % factor == 0:\\n                x //= factor\\n                factor_n += 1\\n            result[factor] = factor_n\\n        factor += 2\\n\\n    if x != 1:\\n        result[x] = 1\\n\\n    return result\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"from collections import defaultdict\\n\\nclass Primes():\\n    def __init__(self, N):\\n        self.N = N\\n        self.prime = {i for i in range(2, self.N+1)}\\n        self.spf = [-1]*(N + 1)\\n        for i in range(2, self.N+1):\\n            if i in self.prime:\\n                self.spf[i] = i\\n                for j in range(i*2, self.N+1, i):\\n                    if j in self.prime:\\n                        self.spf[j] = i\\n                        self.prime.remove(j)\\n\\n    def fact(self,Number):\\n        v = Number\\n        d = defaultdict(int)\\n        while v > 1:\\n            x = self.spf[v]\\n            d[x] += 1\\n            v//=x\\n        return d\\n\\n\\nP = Primes(10**5)\\n\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ncnt = [0]*(10**5 + 1)\\nfor v in a:\\n    cnt[v] += 1\\n\\nans = 0\\nfor v in a:\\n    cnt[v] -= 1\\n    d = P.fact(v)\\n    res = 1\\n    for num,order in list(d.items()):\\n        res *= pow(num,(k-order%k)%k)\\n    if res <= 10**5:\\n        for i in range(1,1000):\\n            if pow(i,k)*res > 10**5:\\n                break\\n            ans += cnt[pow(i,k)*res]\\nprint(ans)\\n\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 2\n40 90\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1225/D"
    },
    {
        "id": 1949,
        "task_id": 2190,
        "test_case_id": 3,
        "question": "You are given $n$ positive integers $a_1, \\ldots, a_n$, and an integer $k \\geq 2$. Count the number of pairs $i, j$ such that $1 \\leq i < j \\leq n$, and there exists an integer $x$ such that $a_i \\cdot a_j = x^k$.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $k$ ($2 \\leq n \\leq 10^5$, $2 \\leq k \\leq 100$).\n\nThe second line contains $n$ integers $a_1, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^5$).\n\n\n-----Output-----\n\nPrint a single integer — the number of suitable pairs.\n\n\n-----Example-----\nInput\n6 3\n1 3 9 8 24 1\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the sample case, the suitable pairs are: $a_1 \\cdot a_4 = 8 = 2^3$; $a_1 \\cdot a_6 = 1 = 1^3$; $a_2 \\cdot a_3 = 27 = 3^3$; $a_3 \\cdot a_5 = 216 = 6^3$; $a_4 \\cdot a_6 = 8 = 2^3$.",
        "solutions": "[\"def f(n):\\n    Ans = []\\n    d = 2\\n    while d * d <= n:\\n        if n % d == 0:\\n            Ans.append(d)\\n            n //= d\\n        else:\\n            d += 1\\n    if n > 1:\\n        Ans.append(n)\\n    return Ans\\n\\n\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\n\\nm = {}\\nc = 0\\nfor i in arr:\\n    r = {}\\n    d = 2\\n    while d * d <= i:\\n        if i % d == 0:\\n            r[d] = (r.get(d, 0) + 1) % k\\n            i //= d\\n        else:\\n            d += 1\\n    if i > 1:\\n        r[i] = (r.get(i, 0) + 1) % k\\n    r = tuple([x for x in list(r.items()) if x[1]])\\n    r2 = tuple([(x[0], k - x[1]) for x in r])\\n    c += m.get(r2, 0)\\n    m[r] = m.get(r, 0) + 1\\nprint(c)\\n\", \"from collections import defaultdict\\nimport math\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\n\\nans = 0\\nhm = defaultdict(int)\\n\\nfor i in range(n):\\n    x = 2\\n    t = []\\n    t1 = []\\n    y = a[i]\\n    while x<=math.sqrt(a[i]):\\n        if a[i]%x==0:\\n            c = 0\\n            while y%x==0:\\n                y = y//x\\n                c += 1\\n            if c%k>0:\\n                t.append((x,c%k))\\n                t1.append((x,k-(c%k)))\\n        x += 1\\n    if y>1:\\n        t.append((y,1%k))\\n        t1.append((y,k-(1%k)))\\n\\n    ans += hm[tuple(t1)]\\n    hm[tuple(t)] += 1\\n\\nprint(ans)\\n        \\n\", \"from collections import defaultdict\\n\\ntotal = 0 \\nimport math\\ndic = defaultdict(int)\\nn, k = list(map(int, input().split()))\\nz = list(map(int, input().split()))\\nfor ii in z:\\n\\n    i = ii\\n    x = []\\n    x2=[]\\n    a = 2\\n    while a<=math.sqrt(ii):\\n        co = 0\\n        while i % a == 0:\\n            i = i//a\\n            co += 1\\n        co=co%k\\n        if co:\\n            x.append((a, co))\\n            x2.append((a, k-co))\\n        a += 1\\n    if i>1:\\n        x.append((i,1))\\n        x2.append((i,k-1))\\n    # print(i)\\n    # print(x)\\n    # print(dic)\\n    dic[tuple(x)] += 1\\n    total += dic[tuple(x2)]\\n        # print(f\\\"ans:{x} and {inver(x)}\\\")\\n    if(x2 == x):\\n        total-=1\\n\\n\\n\\n# print(x)\\nprint(total)\\n\", \"n,k=list(map(int,input().split()))\\narr=list(map(int,input().split()))\\nans=0\\nd={}\\nfor i in range(n):\\n\\tx=2\\n\\ta=[]\\n\\tb=[]\\n\\ty=arr[i]\\n\\twhile x*x<=arr[i]:\\n\\t\\tif arr[i]%x==0:\\n\\t\\t\\tc=0\\n\\t\\t\\twhile y%x==0:\\n\\t\\t\\t\\ty=y//x\\n\\t\\t\\t\\tc+=1\\n\\t\\t\\tif c%k>0:\\n\\t\\t\\t\\ta.append((x,c%k))\\n\\t\\t\\t\\tb.append((x,k-(c%k)))\\n\\t\\tx+=1\\n\\tif y>1:\\n\\t\\ta.append((y,1%k))\\n\\t\\tb.append((y,k-(1%k)))\\n\\ttry:\\n\\t\\tans+=d[tuple(b)]\\n\\texcept:\\n\\t\\tpass\\n\\ttry:\\n\\t\\td[tuple(a)]+=1\\n\\texcept:\\n\\t\\td[tuple(a)]=1\\nprint(ans)\\n\", \"n, k = map(int, input().split())\\n*a, = map(int, input().split())\\nd = {}\\nans = 0\\nfor i in a:\\n    x, j, tmp1, tmp2 = i, 2, [], []\\n    while j * j <= i:\\n        c = 0\\n        while x % j == 0:\\n            c += 1\\n            x //= j\\n        if c % k:\\n            tmp2.append((j, k - c % k))\\n            tmp1.append((j, c % k))\\n        j += 1\\n    if x > 1:\\n        tmp1.append((x, 1))\\n        tmp2.append((x, k - 1))\\n    tmp1, tmp2 = tuple(tmp1), tuple(tmp2)\\n    ans += d.get(tmp2, 0)\\n    d[tmp1] = d.get(tmp1, 0) + 1\\nprint(ans)\", \"import math\\nfrom collections import Counter\\n \\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n \\nans = 0\\nprev = Counter()\\nfor x in a:\\n\\tsig = []\\n\\tp = 2\\n\\twhile p <= math.sqrt(x):\\n\\t\\tcnt = 0\\n\\t\\twhile x % p == 0:\\n\\t\\t\\tcnt += 1\\n\\t\\t\\tx = x // p\\n \\n\\t\\tcnt = cnt % k\\n\\t\\tif cnt > 0:\\n\\t\\t\\tsig.append((p, cnt))\\n \\n\\t\\tp += 1\\n \\n\\tif x > 1:\\n\\t\\tsig.append((x, 1))\\n \\n\\tcom_sig = []\\n\\tfor p, val in sig:\\n\\t\\tcom_sig.append((p, (k - val) % k))\\n \\n\\tans += prev[tuple(sig)]\\n\\tprev[tuple(com_sig)] += 1\\n \\nprint(ans)\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\nd = {}\\nans = 0\\n\\nfor el in a:\\n    i = 2\\n    a = []\\n    b = []\\n    while i*i <= el:\\n        cnt = 0\\n        while not(el%i):\\n            el //= i\\n            cnt += 1\\n        if cnt%k:\\n            a.append((i, cnt%k))\\n            b.append((i, k-(cnt%k)))\\n        i += 1\\n    \\n    if el > 1:\\n        a.append((el, 1))\\n        b.append((el, k-1))\\n\\n    a = tuple(a)\\n    b = tuple(b)\\n\\n    ans += d.get(b, 0)\\n    d[a] = d.get(a, 0)+1\\n    \\nprint(ans)\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 2/11/20\\n\\n\\\"\\\"\\\"\\n\\nimport collections\\nimport time\\nimport os\\nimport sys\\nimport bisect\\nimport heapq\\nfrom typing import List\\nimport math\\n\\n\\ndef factors(val):\\n    wc = []\\n    for i in range(2, int(math.sqrt(val)) + 2):\\n        if i > val:\\n            break\\n        if val % i == 0:\\n            c = 0\\n            while val % i == 0:\\n                c += 1\\n                val //= i\\n            wc.append((i, c))\\n    if val > 1:\\n        wc.append((val, 1))\\n    return wc\\n\\n\\ndef expand(fc, maxd, k):\\n    def dfs(index, mul):\\n        if index >= len(fc):\\n            return [mul]\\n        \\n        w, c = fc[index]\\n        d = k - (c % k) if c % k != 0 else 0\\n        x = []\\n        t = mul * (w ** d)\\n        while t <= maxd:\\n            x.extend(dfs(index + 1, t))\\n            d += k\\n            t *= w**k\\n        \\n        return x\\n        \\n    return dfs(0, 1)\\n    \\ndef solve(N, K, A):\\n    wc = collections.defaultdict(int)\\n    ans = 0\\n    for v in A:\\n        fc = factors(v)\\n        fc = [(f, c % K) for f, c in fc if c % K != 0]\\n        key = '_'.join(['{}+{}'.format(f, c) for f, c in fc])\\n        cov = [(f, K-c) for f, c in fc]\\n        ckey = '_'.join(['{}+{}'.format(f, c) for f, c in cov])\\n        ans += wc[ckey]\\n        wc[key] += 1\\n\\n    return ans\\n    \\nN, K = map(int, input().split())\\nA = [int(x) for x in input().split()]\\nprint(solve(N, K, A))\", \"from math import *\\n\\nn, k = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nma = max(a)\\n\\np = []\\nprime = [True] * (ma + 1)\\nprime[0] = False\\nprime[1] = False\\nfor i in range(2, ma + 1):\\n    if prime[i]:\\n        p.append(i)\\n        if i**2 <= n:\\n            for j in range(i**2, ma + 1, i):\\n                prime[j] = False\\n\\n\\ndef factor(x):\\n    res = {}\\n    sq = ceil(sqrt(x))\\n    for i in p:\\n        if i > sq or x <= 1:\\n            break\\n        if x % i == 0:\\n            res[i] = 0\\n            while x % i == 0:\\n                res[i] += 1\\n                x //= i\\n    if x > 1:\\n        res[x] = 1\\n    nres = []\\n    for j in res:\\n        if res[j] % k > 0:\\n            nres.append((j, res[j] % k))\\n    \\n    return tuple(nres)\\n\\nd = {}\\nfor i in range(n):\\n    f = factor(a[i])\\n    #print(f, a[i])\\n    if f not in d:\\n        d[f] = 1\\n    else:\\n        d[f] += 1\\n        \\nans = 0\\n#print(d)\\nfor x in d:\\n    y = []\\n    for i in x:\\n        y.append((i[0], k - i[1]))\\n    y = tuple(y)\\n    if y in d:\\n        if y != x:\\n            ans += d[x] * d[y]\\n        else:\\n            ans += d[x] * (d[y] - 1)\\n    #print(x, y, ans)\\n\\nprint(ans//2)\\n\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\ndel mark\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\n\\nd = defaultdict(int)\\n\\nans = 0\\nfor i in a:\\n\\tt, t1 = [], []\\n\\tfor j in primes:\\n\\t\\tif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt.append((j,z))\\n\\t\\t\\t\\tt1.append((j,k-z))\\n\\t\\telif i == 1:break\\n\\tif i != 1:\\n\\t\\tt.append((i,1))\\n\\t\\tt1.append((i,k-1))\\n\\n\\tt = tuple(t)\\n\\tt1 = tuple(t1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"import math\\n\\n\\ndef fac(a):\\n    ans = {}\\n\\n    for i in range(2, int(math.sqrt(a)) + 1):\\n        if a % i == 0:\\n            ans[i] = 0\\n            while a % i == 0:\\n                a //= i\\n                ans[i] += 1\\n\\n    ans[a] = 1\\n\\n    return ans\\n\\n\\ndef inverse(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = (k - a[j] % k) % k\\n\\n    return buf\\n\\n\\ndef normal(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = a[j] % k\\n\\n    return buf\\n\\n\\ndef getHash(d):\\n    ans = 1\\n    for i in d.keys():\\n        ans *= i ** d[i]\\n    return ans\\n\\n\\nn, k = map(int, input().split(' '))\\n\\na = [i for i in map(int, input().split(' '))]\\n\\nb = [i for i in map(fac, a)]\\n\\nfactors = {}\\n\\nfor i in b:\\n    buf = getHash(inverse(i, k))\\n    if buf in factors.keys():\\n        factors[buf] += 1\\n    else:\\n        factors[buf] = 1\\n\\nans = 0\\n\\nfor i in range(len(b)):\\n    b[i] = normal(b[i], k)\\n    if getHash(b[i]) == getHash(inverse(b[i], k)):\\n        ans -= 1\\n\\nfor i in map(getHash, b):\\n    if i in factors.keys():\\n        ans += factors[i]\\n\\nprint(ans // 2)\", \"import sys\\ninput =  lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\n\\ndef factors(n, k):\\n    i = 2\\n    sq = int(n**0.5)+1\\n    di={}\\n    while n != 1:\\n        if n % i == 0:\\n            cur = 0\\n            while n % i == 0:\\n                n = n // i\\n                cur += 1\\n            if cur % k != 0:\\n                di[i] = cur % k\\n        i += 1\\n        if i > sq:break\\n    if n != 1:\\n        di[n] = 1\\n    return \\\"|\\\".join(\\\"%d:%d\\\" % (i, di[i]) for i in di)\\n\\nft = {}\\ndi = {}\\n\\nfor i in a:\\n    ft[i] = factors(i, k)\\n    di[ft[i]] = 1 if ft[i] not in di else di[ft[i]] + 1\\n\\nans = 0\\nfor i in a:\\n    ftt = ft[i]\\n    if ftt == \\\"\\\":\\n        ans += di[ftt] - 1\\n    else:\\n        dx = {}\\n        for oo in ftt.split(\\\"|\\\"):\\n            x, y = map(int, oo.split(\\\":\\\"))\\n            dx[x] = - y % k\\n        ftt2 = \\\"|\\\".join(\\\"%d:%d\\\" % (i, dx[i]) for i in dx)\\n        if ftt == ftt2:\\n            ans += di[ftt2] - 1\\n        else:\\n            if ftt2 in di:\\n                ans += di[ftt2]\\n\\nprint(ans//2)\", \"from collections import defaultdict as dc\\ndic=dc(lambda:0)\\nx,y=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nsiv=[0]*(max(s)+1)\\nln=len(siv)\\nsiv[1]=1;\\n\\nfor n in range(2,ln):\\n    if siv[n]==0:\\n        siv[n]=n\\n        for k in range(2*n,ln,n):\\n            if siv[k]==0:\\n                siv[k]=n\\n\\ndef prf(x):\\n    dic=dc(lambda:0)\\n    while x>1:\\n        d=siv[x]\\n        dic[siv[x]]+=1\\n        x//=siv[x]\\n    \\n    return dic\\n\\ndef req(dic,k):\\n    cur=dic\\n    for n in cur:\\n        cur[n]%=k\\n    for n in cur:\\n        cur[n]=(k-cur[n])%k\\n    tot=1\\n    for n in cur:\\n        tot*=(n**cur[n])\\n    return tot\\n\\ndef conv(x,k):\\n    dicc=prf(x)\\n    for n in dicc:\\n        dicc[n]%=k\\n    tot=1\\n    for n in dicc:\\n        tot*=(n**dicc[n])\\n\\n    return tot\\n\\nres=0\\nfor n in s:\\n    re=req(prf(n),y)\\n    res+=dic[re]\\n    dic[conv(n,y)]+=1\\n\\nprint(res)\\n\", \"from math import sqrt\\ndef gd(n, k):\\n    ans = 1\\n    obrans = 1\\n    for i in range(2, int(sqrt(n) + 1)):\\n        j = 0\\n        while n % i == 0:\\n            j += 1\\n            n //= i\\n        ans *= pow(i, j%k)\\n        obrans *= pow(i, (-j)%k)\\n    ans *= n\\n    obrans *= pow(n, (k-1))\\n    return ans, obrans\\nn, k = map(int,input().split())\\noba = set()\\ndct = {}\\nfor i in list(map(int,input().split())):\\n    a,b = gd(i, k)\\n    dct[a] = dct.get(a, 0) + 1\\n    a,b = min(a,b), max(a,b)\\n    oba.add((a,b))\\nans = 0\\nfor i, j in oba:\\n    if i == j:\\n        ans += (dct.get(i, 0)  * dct.get(j, 0) - dct.get(i, 0)) // 2\\n    else:\\n        ans += dct.get(i, 0) * dct.get(j, 0)\\nprint(ans)\", \"import itertools as it\\nfrom collections import defaultdict\\nimport os\\nimport sys\\n\\n\\ndef sieve(n):\\n    is_prime = [True] * n\\n\\n    for candidate in it.chain([2], list(range(3, int(n ** 0.5) + 1, 2))):\\n        if is_prime[candidate]:\\n            for k in range(2 * candidate, n, candidate):\\n                is_prime[k] = False\\n\\n    primes = [idx for idx, k in enumerate(is_prime) if idx >= 2 and k]\\n    return primes\\n\\n\\ndef factorize(n, primes, k):\\n    factors = []\\n    number = n\\n    for f in primes:\\n        count = 0\\n        while number % f == 0:\\n            count += 1\\n            number //= f\\n\\n        if count % k:\\n            factors.append((f, count % k))\\n\\n        if f > number:\\n            break\\n\\n    if number > 1:\\n        factors.append((number, 1))\\n\\n    return tuple(factors)\\n\\n\\ndef solve(arr, k):\\n    total = 0\\n    d = defaultdict(int, {})\\n    primes = sieve(int(1e5 ** 0.5) + 10)\\n    for a in arr:\\n        fac = factorize(a, primes, k)\\n        fac_complement = tuple((f, k - count) for f, count in fac)\\n        total += d[fac_complement]\\n        d[fac] += 1\\n\\n    return total\\n\\n\\ndef pp(input):\\n    # T = int(input())\\n    # for t in range(T):\\n    n, k = list(map(int, input().strip().split()))\\n    arr = list(map(int, input().strip().split()))\\n    print(solve(arr, k))\\n\\n\\nif \\\"paalto\\\" in os.getcwd():\\n    from string_source import string_source, codeforces_parse\\n\\n    pp(\\n        string_source(\\n            \\\"\\\"\\\"6 3\\n1 3 9 8 24 1\\\"\\\"\\\"\\n        )\\n    )\\nelse:\\n    pp(sys.stdin.readline)\\n\", \"from collections import defaultdict\\nimport sys as _sys\\n\\n\\ndef main():\\n    n, k = _read_ints()\\n    a = tuple(_read_ints())\\n    result = find_good_pairs_n(a, k)\\n    print(result)\\n\\n\\ndef _read_line():\\n    result = _sys.stdin.readline()\\n    assert result[-1] == \\\"\\\\n\\\"\\n    return result[:-1]\\n\\n\\ndef _read_ints():\\n    return list(map(int, _read_line().split()))\\n\\n\\ndef find_good_pairs_n(sequence, k):\\n    sequence = tuple(sequence)\\n    factors_seq = tuple(map(_find_prime_factors, sequence))\\n    \\n    factors_seq = [[(kv[0], kv[1] % k) for kv in list(factors.items())] for factors in factors_seq]\\n    factors_seq = [[kv for kv in factors if kv[1] > 0] for factors in factors_seq]\\n    factors_seq = list(map(sorted, factors_seq))\\n    factors_seq = tuple(map(tuple, factors_seq))\\n    \\n    counter = defaultdict(int)\\n    for factors in factors_seq:\\n        counter[factors] += 1\\n    \\n    result = 0\\n    for factors in factors_seq:\\n        necessary_factors = tuple((factor, k - amount) for factor, amount in factors)\\n        result += counter[necessary_factors]\\n        if factors == necessary_factors:\\n            result -= 1\\n    \\n    assert result % 2 == 0\\n    result //= 2\\n    return result\\n\\n\\ndef _find_prime_factors(x):\\n    result = dict()\\n    \\n    if x % 2 == 0:\\n        factor_2_n = 0\\n        while x & 1 == 0:\\n            x >>= 1\\n            factor_2_n += 1\\n        result[2] = factor_2_n\\n    \\n    factor = 3\\n    while x != 1 and factor * factor <= x:\\n        if x % factor == 0:\\n            factor_n = 0\\n            while x % factor == 0:\\n                x //= factor\\n                factor_n += 1\\n            result[factor] = factor_n\\n        factor += 2\\n\\n    if x != 1:\\n        result[x] = 1\\n\\n    return result\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"from collections import defaultdict\\n\\nclass Primes():\\n    def __init__(self, N):\\n        self.N = N\\n        self.prime = {i for i in range(2, self.N+1)}\\n        self.spf = [-1]*(N + 1)\\n        for i in range(2, self.N+1):\\n            if i in self.prime:\\n                self.spf[i] = i\\n                for j in range(i*2, self.N+1, i):\\n                    if j in self.prime:\\n                        self.spf[j] = i\\n                        self.prime.remove(j)\\n\\n    def fact(self,Number):\\n        v = Number\\n        d = defaultdict(int)\\n        while v > 1:\\n            x = self.spf[v]\\n            d[x] += 1\\n            v//=x\\n        return d\\n\\n\\nP = Primes(10**5)\\n\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ncnt = [0]*(10**5 + 1)\\nfor v in a:\\n    cnt[v] += 1\\n\\nans = 0\\nfor v in a:\\n    cnt[v] -= 1\\n    d = P.fact(v)\\n    res = 1\\n    for num,order in list(d.items()):\\n        res *= pow(num,(k-order%k)%k)\\n    if res <= 10**5:\\n        for i in range(1,1000):\\n            if pow(i,k)*res > 10**5:\\n                break\\n            ans += cnt[pow(i,k)*res]\\nprint(ans)\\n\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "10 2\n7 4 10 9 2 8 8 7 3 7\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1225/D"
    },
    {
        "id": 1950,
        "task_id": 2190,
        "test_case_id": 4,
        "question": "You are given $n$ positive integers $a_1, \\ldots, a_n$, and an integer $k \\geq 2$. Count the number of pairs $i, j$ such that $1 \\leq i < j \\leq n$, and there exists an integer $x$ such that $a_i \\cdot a_j = x^k$.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $k$ ($2 \\leq n \\leq 10^5$, $2 \\leq k \\leq 100$).\n\nThe second line contains $n$ integers $a_1, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^5$).\n\n\n-----Output-----\n\nPrint a single integer — the number of suitable pairs.\n\n\n-----Example-----\nInput\n6 3\n1 3 9 8 24 1\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the sample case, the suitable pairs are: $a_1 \\cdot a_4 = 8 = 2^3$; $a_1 \\cdot a_6 = 1 = 1^3$; $a_2 \\cdot a_3 = 27 = 3^3$; $a_3 \\cdot a_5 = 216 = 6^3$; $a_4 \\cdot a_6 = 8 = 2^3$.",
        "solutions": "[\"def f(n):\\n    Ans = []\\n    d = 2\\n    while d * d <= n:\\n        if n % d == 0:\\n            Ans.append(d)\\n            n //= d\\n        else:\\n            d += 1\\n    if n > 1:\\n        Ans.append(n)\\n    return Ans\\n\\n\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\n\\nm = {}\\nc = 0\\nfor i in arr:\\n    r = {}\\n    d = 2\\n    while d * d <= i:\\n        if i % d == 0:\\n            r[d] = (r.get(d, 0) + 1) % k\\n            i //= d\\n        else:\\n            d += 1\\n    if i > 1:\\n        r[i] = (r.get(i, 0) + 1) % k\\n    r = tuple([x for x in list(r.items()) if x[1]])\\n    r2 = tuple([(x[0], k - x[1]) for x in r])\\n    c += m.get(r2, 0)\\n    m[r] = m.get(r, 0) + 1\\nprint(c)\\n\", \"from collections import defaultdict\\nimport math\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\n\\nans = 0\\nhm = defaultdict(int)\\n\\nfor i in range(n):\\n    x = 2\\n    t = []\\n    t1 = []\\n    y = a[i]\\n    while x<=math.sqrt(a[i]):\\n        if a[i]%x==0:\\n            c = 0\\n            while y%x==0:\\n                y = y//x\\n                c += 1\\n            if c%k>0:\\n                t.append((x,c%k))\\n                t1.append((x,k-(c%k)))\\n        x += 1\\n    if y>1:\\n        t.append((y,1%k))\\n        t1.append((y,k-(1%k)))\\n\\n    ans += hm[tuple(t1)]\\n    hm[tuple(t)] += 1\\n\\nprint(ans)\\n        \\n\", \"from collections import defaultdict\\n\\ntotal = 0 \\nimport math\\ndic = defaultdict(int)\\nn, k = list(map(int, input().split()))\\nz = list(map(int, input().split()))\\nfor ii in z:\\n\\n    i = ii\\n    x = []\\n    x2=[]\\n    a = 2\\n    while a<=math.sqrt(ii):\\n        co = 0\\n        while i % a == 0:\\n            i = i//a\\n            co += 1\\n        co=co%k\\n        if co:\\n            x.append((a, co))\\n            x2.append((a, k-co))\\n        a += 1\\n    if i>1:\\n        x.append((i,1))\\n        x2.append((i,k-1))\\n    # print(i)\\n    # print(x)\\n    # print(dic)\\n    dic[tuple(x)] += 1\\n    total += dic[tuple(x2)]\\n        # print(f\\\"ans:{x} and {inver(x)}\\\")\\n    if(x2 == x):\\n        total-=1\\n\\n\\n\\n# print(x)\\nprint(total)\\n\", \"n,k=list(map(int,input().split()))\\narr=list(map(int,input().split()))\\nans=0\\nd={}\\nfor i in range(n):\\n\\tx=2\\n\\ta=[]\\n\\tb=[]\\n\\ty=arr[i]\\n\\twhile x*x<=arr[i]:\\n\\t\\tif arr[i]%x==0:\\n\\t\\t\\tc=0\\n\\t\\t\\twhile y%x==0:\\n\\t\\t\\t\\ty=y//x\\n\\t\\t\\t\\tc+=1\\n\\t\\t\\tif c%k>0:\\n\\t\\t\\t\\ta.append((x,c%k))\\n\\t\\t\\t\\tb.append((x,k-(c%k)))\\n\\t\\tx+=1\\n\\tif y>1:\\n\\t\\ta.append((y,1%k))\\n\\t\\tb.append((y,k-(1%k)))\\n\\ttry:\\n\\t\\tans+=d[tuple(b)]\\n\\texcept:\\n\\t\\tpass\\n\\ttry:\\n\\t\\td[tuple(a)]+=1\\n\\texcept:\\n\\t\\td[tuple(a)]=1\\nprint(ans)\\n\", \"n, k = map(int, input().split())\\n*a, = map(int, input().split())\\nd = {}\\nans = 0\\nfor i in a:\\n    x, j, tmp1, tmp2 = i, 2, [], []\\n    while j * j <= i:\\n        c = 0\\n        while x % j == 0:\\n            c += 1\\n            x //= j\\n        if c % k:\\n            tmp2.append((j, k - c % k))\\n            tmp1.append((j, c % k))\\n        j += 1\\n    if x > 1:\\n        tmp1.append((x, 1))\\n        tmp2.append((x, k - 1))\\n    tmp1, tmp2 = tuple(tmp1), tuple(tmp2)\\n    ans += d.get(tmp2, 0)\\n    d[tmp1] = d.get(tmp1, 0) + 1\\nprint(ans)\", \"import math\\nfrom collections import Counter\\n \\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n \\nans = 0\\nprev = Counter()\\nfor x in a:\\n\\tsig = []\\n\\tp = 2\\n\\twhile p <= math.sqrt(x):\\n\\t\\tcnt = 0\\n\\t\\twhile x % p == 0:\\n\\t\\t\\tcnt += 1\\n\\t\\t\\tx = x // p\\n \\n\\t\\tcnt = cnt % k\\n\\t\\tif cnt > 0:\\n\\t\\t\\tsig.append((p, cnt))\\n \\n\\t\\tp += 1\\n \\n\\tif x > 1:\\n\\t\\tsig.append((x, 1))\\n \\n\\tcom_sig = []\\n\\tfor p, val in sig:\\n\\t\\tcom_sig.append((p, (k - val) % k))\\n \\n\\tans += prev[tuple(sig)]\\n\\tprev[tuple(com_sig)] += 1\\n \\nprint(ans)\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\nd = {}\\nans = 0\\n\\nfor el in a:\\n    i = 2\\n    a = []\\n    b = []\\n    while i*i <= el:\\n        cnt = 0\\n        while not(el%i):\\n            el //= i\\n            cnt += 1\\n        if cnt%k:\\n            a.append((i, cnt%k))\\n            b.append((i, k-(cnt%k)))\\n        i += 1\\n    \\n    if el > 1:\\n        a.append((el, 1))\\n        b.append((el, k-1))\\n\\n    a = tuple(a)\\n    b = tuple(b)\\n\\n    ans += d.get(b, 0)\\n    d[a] = d.get(a, 0)+1\\n    \\nprint(ans)\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 2/11/20\\n\\n\\\"\\\"\\\"\\n\\nimport collections\\nimport time\\nimport os\\nimport sys\\nimport bisect\\nimport heapq\\nfrom typing import List\\nimport math\\n\\n\\ndef factors(val):\\n    wc = []\\n    for i in range(2, int(math.sqrt(val)) + 2):\\n        if i > val:\\n            break\\n        if val % i == 0:\\n            c = 0\\n            while val % i == 0:\\n                c += 1\\n                val //= i\\n            wc.append((i, c))\\n    if val > 1:\\n        wc.append((val, 1))\\n    return wc\\n\\n\\ndef expand(fc, maxd, k):\\n    def dfs(index, mul):\\n        if index >= len(fc):\\n            return [mul]\\n        \\n        w, c = fc[index]\\n        d = k - (c % k) if c % k != 0 else 0\\n        x = []\\n        t = mul * (w ** d)\\n        while t <= maxd:\\n            x.extend(dfs(index + 1, t))\\n            d += k\\n            t *= w**k\\n        \\n        return x\\n        \\n    return dfs(0, 1)\\n    \\ndef solve(N, K, A):\\n    wc = collections.defaultdict(int)\\n    ans = 0\\n    for v in A:\\n        fc = factors(v)\\n        fc = [(f, c % K) for f, c in fc if c % K != 0]\\n        key = '_'.join(['{}+{}'.format(f, c) for f, c in fc])\\n        cov = [(f, K-c) for f, c in fc]\\n        ckey = '_'.join(['{}+{}'.format(f, c) for f, c in cov])\\n        ans += wc[ckey]\\n        wc[key] += 1\\n\\n    return ans\\n    \\nN, K = map(int, input().split())\\nA = [int(x) for x in input().split()]\\nprint(solve(N, K, A))\", \"from math import *\\n\\nn, k = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nma = max(a)\\n\\np = []\\nprime = [True] * (ma + 1)\\nprime[0] = False\\nprime[1] = False\\nfor i in range(2, ma + 1):\\n    if prime[i]:\\n        p.append(i)\\n        if i**2 <= n:\\n            for j in range(i**2, ma + 1, i):\\n                prime[j] = False\\n\\n\\ndef factor(x):\\n    res = {}\\n    sq = ceil(sqrt(x))\\n    for i in p:\\n        if i > sq or x <= 1:\\n            break\\n        if x % i == 0:\\n            res[i] = 0\\n            while x % i == 0:\\n                res[i] += 1\\n                x //= i\\n    if x > 1:\\n        res[x] = 1\\n    nres = []\\n    for j in res:\\n        if res[j] % k > 0:\\n            nres.append((j, res[j] % k))\\n    \\n    return tuple(nres)\\n\\nd = {}\\nfor i in range(n):\\n    f = factor(a[i])\\n    #print(f, a[i])\\n    if f not in d:\\n        d[f] = 1\\n    else:\\n        d[f] += 1\\n        \\nans = 0\\n#print(d)\\nfor x in d:\\n    y = []\\n    for i in x:\\n        y.append((i[0], k - i[1]))\\n    y = tuple(y)\\n    if y in d:\\n        if y != x:\\n            ans += d[x] * d[y]\\n        else:\\n            ans += d[x] * (d[y] - 1)\\n    #print(x, y, ans)\\n\\nprint(ans//2)\\n\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\ndel mark\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\n\\nd = defaultdict(int)\\n\\nans = 0\\nfor i in a:\\n\\tt, t1 = [], []\\n\\tfor j in primes:\\n\\t\\tif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt.append((j,z))\\n\\t\\t\\t\\tt1.append((j,k-z))\\n\\t\\telif i == 1:break\\n\\tif i != 1:\\n\\t\\tt.append((i,1))\\n\\t\\tt1.append((i,k-1))\\n\\n\\tt = tuple(t)\\n\\tt1 = tuple(t1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"import math\\n\\n\\ndef fac(a):\\n    ans = {}\\n\\n    for i in range(2, int(math.sqrt(a)) + 1):\\n        if a % i == 0:\\n            ans[i] = 0\\n            while a % i == 0:\\n                a //= i\\n                ans[i] += 1\\n\\n    ans[a] = 1\\n\\n    return ans\\n\\n\\ndef inverse(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = (k - a[j] % k) % k\\n\\n    return buf\\n\\n\\ndef normal(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = a[j] % k\\n\\n    return buf\\n\\n\\ndef getHash(d):\\n    ans = 1\\n    for i in d.keys():\\n        ans *= i ** d[i]\\n    return ans\\n\\n\\nn, k = map(int, input().split(' '))\\n\\na = [i for i in map(int, input().split(' '))]\\n\\nb = [i for i in map(fac, a)]\\n\\nfactors = {}\\n\\nfor i in b:\\n    buf = getHash(inverse(i, k))\\n    if buf in factors.keys():\\n        factors[buf] += 1\\n    else:\\n        factors[buf] = 1\\n\\nans = 0\\n\\nfor i in range(len(b)):\\n    b[i] = normal(b[i], k)\\n    if getHash(b[i]) == getHash(inverse(b[i], k)):\\n        ans -= 1\\n\\nfor i in map(getHash, b):\\n    if i in factors.keys():\\n        ans += factors[i]\\n\\nprint(ans // 2)\", \"import sys\\ninput =  lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\n\\ndef factors(n, k):\\n    i = 2\\n    sq = int(n**0.5)+1\\n    di={}\\n    while n != 1:\\n        if n % i == 0:\\n            cur = 0\\n            while n % i == 0:\\n                n = n // i\\n                cur += 1\\n            if cur % k != 0:\\n                di[i] = cur % k\\n        i += 1\\n        if i > sq:break\\n    if n != 1:\\n        di[n] = 1\\n    return \\\"|\\\".join(\\\"%d:%d\\\" % (i, di[i]) for i in di)\\n\\nft = {}\\ndi = {}\\n\\nfor i in a:\\n    ft[i] = factors(i, k)\\n    di[ft[i]] = 1 if ft[i] not in di else di[ft[i]] + 1\\n\\nans = 0\\nfor i in a:\\n    ftt = ft[i]\\n    if ftt == \\\"\\\":\\n        ans += di[ftt] - 1\\n    else:\\n        dx = {}\\n        for oo in ftt.split(\\\"|\\\"):\\n            x, y = map(int, oo.split(\\\":\\\"))\\n            dx[x] = - y % k\\n        ftt2 = \\\"|\\\".join(\\\"%d:%d\\\" % (i, dx[i]) for i in dx)\\n        if ftt == ftt2:\\n            ans += di[ftt2] - 1\\n        else:\\n            if ftt2 in di:\\n                ans += di[ftt2]\\n\\nprint(ans//2)\", \"from collections import defaultdict as dc\\ndic=dc(lambda:0)\\nx,y=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nsiv=[0]*(max(s)+1)\\nln=len(siv)\\nsiv[1]=1;\\n\\nfor n in range(2,ln):\\n    if siv[n]==0:\\n        siv[n]=n\\n        for k in range(2*n,ln,n):\\n            if siv[k]==0:\\n                siv[k]=n\\n\\ndef prf(x):\\n    dic=dc(lambda:0)\\n    while x>1:\\n        d=siv[x]\\n        dic[siv[x]]+=1\\n        x//=siv[x]\\n    \\n    return dic\\n\\ndef req(dic,k):\\n    cur=dic\\n    for n in cur:\\n        cur[n]%=k\\n    for n in cur:\\n        cur[n]=(k-cur[n])%k\\n    tot=1\\n    for n in cur:\\n        tot*=(n**cur[n])\\n    return tot\\n\\ndef conv(x,k):\\n    dicc=prf(x)\\n    for n in dicc:\\n        dicc[n]%=k\\n    tot=1\\n    for n in dicc:\\n        tot*=(n**dicc[n])\\n\\n    return tot\\n\\nres=0\\nfor n in s:\\n    re=req(prf(n),y)\\n    res+=dic[re]\\n    dic[conv(n,y)]+=1\\n\\nprint(res)\\n\", \"from math import sqrt\\ndef gd(n, k):\\n    ans = 1\\n    obrans = 1\\n    for i in range(2, int(sqrt(n) + 1)):\\n        j = 0\\n        while n % i == 0:\\n            j += 1\\n            n //= i\\n        ans *= pow(i, j%k)\\n        obrans *= pow(i, (-j)%k)\\n    ans *= n\\n    obrans *= pow(n, (k-1))\\n    return ans, obrans\\nn, k = map(int,input().split())\\noba = set()\\ndct = {}\\nfor i in list(map(int,input().split())):\\n    a,b = gd(i, k)\\n    dct[a] = dct.get(a, 0) + 1\\n    a,b = min(a,b), max(a,b)\\n    oba.add((a,b))\\nans = 0\\nfor i, j in oba:\\n    if i == j:\\n        ans += (dct.get(i, 0)  * dct.get(j, 0) - dct.get(i, 0)) // 2\\n    else:\\n        ans += dct.get(i, 0) * dct.get(j, 0)\\nprint(ans)\", \"import itertools as it\\nfrom collections import defaultdict\\nimport os\\nimport sys\\n\\n\\ndef sieve(n):\\n    is_prime = [True] * n\\n\\n    for candidate in it.chain([2], list(range(3, int(n ** 0.5) + 1, 2))):\\n        if is_prime[candidate]:\\n            for k in range(2 * candidate, n, candidate):\\n                is_prime[k] = False\\n\\n    primes = [idx for idx, k in enumerate(is_prime) if idx >= 2 and k]\\n    return primes\\n\\n\\ndef factorize(n, primes, k):\\n    factors = []\\n    number = n\\n    for f in primes:\\n        count = 0\\n        while number % f == 0:\\n            count += 1\\n            number //= f\\n\\n        if count % k:\\n            factors.append((f, count % k))\\n\\n        if f > number:\\n            break\\n\\n    if number > 1:\\n        factors.append((number, 1))\\n\\n    return tuple(factors)\\n\\n\\ndef solve(arr, k):\\n    total = 0\\n    d = defaultdict(int, {})\\n    primes = sieve(int(1e5 ** 0.5) + 10)\\n    for a in arr:\\n        fac = factorize(a, primes, k)\\n        fac_complement = tuple((f, k - count) for f, count in fac)\\n        total += d[fac_complement]\\n        d[fac] += 1\\n\\n    return total\\n\\n\\ndef pp(input):\\n    # T = int(input())\\n    # for t in range(T):\\n    n, k = list(map(int, input().strip().split()))\\n    arr = list(map(int, input().strip().split()))\\n    print(solve(arr, k))\\n\\n\\nif \\\"paalto\\\" in os.getcwd():\\n    from string_source import string_source, codeforces_parse\\n\\n    pp(\\n        string_source(\\n            \\\"\\\"\\\"6 3\\n1 3 9 8 24 1\\\"\\\"\\\"\\n        )\\n    )\\nelse:\\n    pp(sys.stdin.readline)\\n\", \"from collections import defaultdict\\nimport sys as _sys\\n\\n\\ndef main():\\n    n, k = _read_ints()\\n    a = tuple(_read_ints())\\n    result = find_good_pairs_n(a, k)\\n    print(result)\\n\\n\\ndef _read_line():\\n    result = _sys.stdin.readline()\\n    assert result[-1] == \\\"\\\\n\\\"\\n    return result[:-1]\\n\\n\\ndef _read_ints():\\n    return list(map(int, _read_line().split()))\\n\\n\\ndef find_good_pairs_n(sequence, k):\\n    sequence = tuple(sequence)\\n    factors_seq = tuple(map(_find_prime_factors, sequence))\\n    \\n    factors_seq = [[(kv[0], kv[1] % k) for kv in list(factors.items())] for factors in factors_seq]\\n    factors_seq = [[kv for kv in factors if kv[1] > 0] for factors in factors_seq]\\n    factors_seq = list(map(sorted, factors_seq))\\n    factors_seq = tuple(map(tuple, factors_seq))\\n    \\n    counter = defaultdict(int)\\n    for factors in factors_seq:\\n        counter[factors] += 1\\n    \\n    result = 0\\n    for factors in factors_seq:\\n        necessary_factors = tuple((factor, k - amount) for factor, amount in factors)\\n        result += counter[necessary_factors]\\n        if factors == necessary_factors:\\n            result -= 1\\n    \\n    assert result % 2 == 0\\n    result //= 2\\n    return result\\n\\n\\ndef _find_prime_factors(x):\\n    result = dict()\\n    \\n    if x % 2 == 0:\\n        factor_2_n = 0\\n        while x & 1 == 0:\\n            x >>= 1\\n            factor_2_n += 1\\n        result[2] = factor_2_n\\n    \\n    factor = 3\\n    while x != 1 and factor * factor <= x:\\n        if x % factor == 0:\\n            factor_n = 0\\n            while x % factor == 0:\\n                x //= factor\\n                factor_n += 1\\n            result[factor] = factor_n\\n        factor += 2\\n\\n    if x != 1:\\n        result[x] = 1\\n\\n    return result\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"from collections import defaultdict\\n\\nclass Primes():\\n    def __init__(self, N):\\n        self.N = N\\n        self.prime = {i for i in range(2, self.N+1)}\\n        self.spf = [-1]*(N + 1)\\n        for i in range(2, self.N+1):\\n            if i in self.prime:\\n                self.spf[i] = i\\n                for j in range(i*2, self.N+1, i):\\n                    if j in self.prime:\\n                        self.spf[j] = i\\n                        self.prime.remove(j)\\n\\n    def fact(self,Number):\\n        v = Number\\n        d = defaultdict(int)\\n        while v > 1:\\n            x = self.spf[v]\\n            d[x] += 1\\n            v//=x\\n        return d\\n\\n\\nP = Primes(10**5)\\n\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ncnt = [0]*(10**5 + 1)\\nfor v in a:\\n    cnt[v] += 1\\n\\nans = 0\\nfor v in a:\\n    cnt[v] -= 1\\n    d = P.fact(v)\\n    res = 1\\n    for num,order in list(d.items()):\\n        res *= pow(num,(k-order%k)%k)\\n    if res <= 10**5:\\n        for i in range(1,1000):\\n            if pow(i,k)*res > 10**5:\\n                break\\n            ans += cnt[pow(i,k)*res]\\nprint(ans)\\n\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "100 3\n94 94 83 27 80 73 61 38 34 95 72 96 59 36 78 15 83 78 39 22 21 57 54 59 9 32 81 64 94 90 67 41 18 57 93 76 44 62 77 61 31 70 39 73 81 57 43 31 27 85 36 26 44 26 75 23 66 53 3 14 40 67 53 19 70 81 98 12 91 15 92 90 89 86 58 30 67 73 72 69 68 47 30 7 89 35 17 93 45 6 4 23 73 36 10 34 73 74 45 27\n",
        "output": "27\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1225/D"
    },
    {
        "id": 1951,
        "task_id": 2190,
        "test_case_id": 5,
        "question": "You are given $n$ positive integers $a_1, \\ldots, a_n$, and an integer $k \\geq 2$. Count the number of pairs $i, j$ such that $1 \\leq i < j \\leq n$, and there exists an integer $x$ such that $a_i \\cdot a_j = x^k$.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $k$ ($2 \\leq n \\leq 10^5$, $2 \\leq k \\leq 100$).\n\nThe second line contains $n$ integers $a_1, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^5$).\n\n\n-----Output-----\n\nPrint a single integer — the number of suitable pairs.\n\n\n-----Example-----\nInput\n6 3\n1 3 9 8 24 1\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the sample case, the suitable pairs are: $a_1 \\cdot a_4 = 8 = 2^3$; $a_1 \\cdot a_6 = 1 = 1^3$; $a_2 \\cdot a_3 = 27 = 3^3$; $a_3 \\cdot a_5 = 216 = 6^3$; $a_4 \\cdot a_6 = 8 = 2^3$.",
        "solutions": "[\"def f(n):\\n    Ans = []\\n    d = 2\\n    while d * d <= n:\\n        if n % d == 0:\\n            Ans.append(d)\\n            n //= d\\n        else:\\n            d += 1\\n    if n > 1:\\n        Ans.append(n)\\n    return Ans\\n\\n\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\n\\nm = {}\\nc = 0\\nfor i in arr:\\n    r = {}\\n    d = 2\\n    while d * d <= i:\\n        if i % d == 0:\\n            r[d] = (r.get(d, 0) + 1) % k\\n            i //= d\\n        else:\\n            d += 1\\n    if i > 1:\\n        r[i] = (r.get(i, 0) + 1) % k\\n    r = tuple([x for x in list(r.items()) if x[1]])\\n    r2 = tuple([(x[0], k - x[1]) for x in r])\\n    c += m.get(r2, 0)\\n    m[r] = m.get(r, 0) + 1\\nprint(c)\\n\", \"from collections import defaultdict\\nimport math\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\n\\nans = 0\\nhm = defaultdict(int)\\n\\nfor i in range(n):\\n    x = 2\\n    t = []\\n    t1 = []\\n    y = a[i]\\n    while x<=math.sqrt(a[i]):\\n        if a[i]%x==0:\\n            c = 0\\n            while y%x==0:\\n                y = y//x\\n                c += 1\\n            if c%k>0:\\n                t.append((x,c%k))\\n                t1.append((x,k-(c%k)))\\n        x += 1\\n    if y>1:\\n        t.append((y,1%k))\\n        t1.append((y,k-(1%k)))\\n\\n    ans += hm[tuple(t1)]\\n    hm[tuple(t)] += 1\\n\\nprint(ans)\\n        \\n\", \"from collections import defaultdict\\n\\ntotal = 0 \\nimport math\\ndic = defaultdict(int)\\nn, k = list(map(int, input().split()))\\nz = list(map(int, input().split()))\\nfor ii in z:\\n\\n    i = ii\\n    x = []\\n    x2=[]\\n    a = 2\\n    while a<=math.sqrt(ii):\\n        co = 0\\n        while i % a == 0:\\n            i = i//a\\n            co += 1\\n        co=co%k\\n        if co:\\n            x.append((a, co))\\n            x2.append((a, k-co))\\n        a += 1\\n    if i>1:\\n        x.append((i,1))\\n        x2.append((i,k-1))\\n    # print(i)\\n    # print(x)\\n    # print(dic)\\n    dic[tuple(x)] += 1\\n    total += dic[tuple(x2)]\\n        # print(f\\\"ans:{x} and {inver(x)}\\\")\\n    if(x2 == x):\\n        total-=1\\n\\n\\n\\n# print(x)\\nprint(total)\\n\", \"n,k=list(map(int,input().split()))\\narr=list(map(int,input().split()))\\nans=0\\nd={}\\nfor i in range(n):\\n\\tx=2\\n\\ta=[]\\n\\tb=[]\\n\\ty=arr[i]\\n\\twhile x*x<=arr[i]:\\n\\t\\tif arr[i]%x==0:\\n\\t\\t\\tc=0\\n\\t\\t\\twhile y%x==0:\\n\\t\\t\\t\\ty=y//x\\n\\t\\t\\t\\tc+=1\\n\\t\\t\\tif c%k>0:\\n\\t\\t\\t\\ta.append((x,c%k))\\n\\t\\t\\t\\tb.append((x,k-(c%k)))\\n\\t\\tx+=1\\n\\tif y>1:\\n\\t\\ta.append((y,1%k))\\n\\t\\tb.append((y,k-(1%k)))\\n\\ttry:\\n\\t\\tans+=d[tuple(b)]\\n\\texcept:\\n\\t\\tpass\\n\\ttry:\\n\\t\\td[tuple(a)]+=1\\n\\texcept:\\n\\t\\td[tuple(a)]=1\\nprint(ans)\\n\", \"n, k = map(int, input().split())\\n*a, = map(int, input().split())\\nd = {}\\nans = 0\\nfor i in a:\\n    x, j, tmp1, tmp2 = i, 2, [], []\\n    while j * j <= i:\\n        c = 0\\n        while x % j == 0:\\n            c += 1\\n            x //= j\\n        if c % k:\\n            tmp2.append((j, k - c % k))\\n            tmp1.append((j, c % k))\\n        j += 1\\n    if x > 1:\\n        tmp1.append((x, 1))\\n        tmp2.append((x, k - 1))\\n    tmp1, tmp2 = tuple(tmp1), tuple(tmp2)\\n    ans += d.get(tmp2, 0)\\n    d[tmp1] = d.get(tmp1, 0) + 1\\nprint(ans)\", \"import math\\nfrom collections import Counter\\n \\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n \\nans = 0\\nprev = Counter()\\nfor x in a:\\n\\tsig = []\\n\\tp = 2\\n\\twhile p <= math.sqrt(x):\\n\\t\\tcnt = 0\\n\\t\\twhile x % p == 0:\\n\\t\\t\\tcnt += 1\\n\\t\\t\\tx = x // p\\n \\n\\t\\tcnt = cnt % k\\n\\t\\tif cnt > 0:\\n\\t\\t\\tsig.append((p, cnt))\\n \\n\\t\\tp += 1\\n \\n\\tif x > 1:\\n\\t\\tsig.append((x, 1))\\n \\n\\tcom_sig = []\\n\\tfor p, val in sig:\\n\\t\\tcom_sig.append((p, (k - val) % k))\\n \\n\\tans += prev[tuple(sig)]\\n\\tprev[tuple(com_sig)] += 1\\n \\nprint(ans)\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\nd = {}\\nans = 0\\n\\nfor el in a:\\n    i = 2\\n    a = []\\n    b = []\\n    while i*i <= el:\\n        cnt = 0\\n        while not(el%i):\\n            el //= i\\n            cnt += 1\\n        if cnt%k:\\n            a.append((i, cnt%k))\\n            b.append((i, k-(cnt%k)))\\n        i += 1\\n    \\n    if el > 1:\\n        a.append((el, 1))\\n        b.append((el, k-1))\\n\\n    a = tuple(a)\\n    b = tuple(b)\\n\\n    ans += d.get(b, 0)\\n    d[a] = d.get(a, 0)+1\\n    \\nprint(ans)\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 2/11/20\\n\\n\\\"\\\"\\\"\\n\\nimport collections\\nimport time\\nimport os\\nimport sys\\nimport bisect\\nimport heapq\\nfrom typing import List\\nimport math\\n\\n\\ndef factors(val):\\n    wc = []\\n    for i in range(2, int(math.sqrt(val)) + 2):\\n        if i > val:\\n            break\\n        if val % i == 0:\\n            c = 0\\n            while val % i == 0:\\n                c += 1\\n                val //= i\\n            wc.append((i, c))\\n    if val > 1:\\n        wc.append((val, 1))\\n    return wc\\n\\n\\ndef expand(fc, maxd, k):\\n    def dfs(index, mul):\\n        if index >= len(fc):\\n            return [mul]\\n        \\n        w, c = fc[index]\\n        d = k - (c % k) if c % k != 0 else 0\\n        x = []\\n        t = mul * (w ** d)\\n        while t <= maxd:\\n            x.extend(dfs(index + 1, t))\\n            d += k\\n            t *= w**k\\n        \\n        return x\\n        \\n    return dfs(0, 1)\\n    \\ndef solve(N, K, A):\\n    wc = collections.defaultdict(int)\\n    ans = 0\\n    for v in A:\\n        fc = factors(v)\\n        fc = [(f, c % K) for f, c in fc if c % K != 0]\\n        key = '_'.join(['{}+{}'.format(f, c) for f, c in fc])\\n        cov = [(f, K-c) for f, c in fc]\\n        ckey = '_'.join(['{}+{}'.format(f, c) for f, c in cov])\\n        ans += wc[ckey]\\n        wc[key] += 1\\n\\n    return ans\\n    \\nN, K = map(int, input().split())\\nA = [int(x) for x in input().split()]\\nprint(solve(N, K, A))\", \"from math import *\\n\\nn, k = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nma = max(a)\\n\\np = []\\nprime = [True] * (ma + 1)\\nprime[0] = False\\nprime[1] = False\\nfor i in range(2, ma + 1):\\n    if prime[i]:\\n        p.append(i)\\n        if i**2 <= n:\\n            for j in range(i**2, ma + 1, i):\\n                prime[j] = False\\n\\n\\ndef factor(x):\\n    res = {}\\n    sq = ceil(sqrt(x))\\n    for i in p:\\n        if i > sq or x <= 1:\\n            break\\n        if x % i == 0:\\n            res[i] = 0\\n            while x % i == 0:\\n                res[i] += 1\\n                x //= i\\n    if x > 1:\\n        res[x] = 1\\n    nres = []\\n    for j in res:\\n        if res[j] % k > 0:\\n            nres.append((j, res[j] % k))\\n    \\n    return tuple(nres)\\n\\nd = {}\\nfor i in range(n):\\n    f = factor(a[i])\\n    #print(f, a[i])\\n    if f not in d:\\n        d[f] = 1\\n    else:\\n        d[f] += 1\\n        \\nans = 0\\n#print(d)\\nfor x in d:\\n    y = []\\n    for i in x:\\n        y.append((i[0], k - i[1]))\\n    y = tuple(y)\\n    if y in d:\\n        if y != x:\\n            ans += d[x] * d[y]\\n        else:\\n            ans += d[x] * (d[y] - 1)\\n    #print(x, y, ans)\\n\\nprint(ans//2)\\n\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\ndel mark\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\n\\nd = defaultdict(int)\\n\\nans = 0\\nfor i in a:\\n\\tt, t1 = [], []\\n\\tfor j in primes:\\n\\t\\tif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt.append((j,z))\\n\\t\\t\\t\\tt1.append((j,k-z))\\n\\t\\telif i == 1:break\\n\\tif i != 1:\\n\\t\\tt.append((i,1))\\n\\t\\tt1.append((i,k-1))\\n\\n\\tt = tuple(t)\\n\\tt1 = tuple(t1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"import math\\n\\n\\ndef fac(a):\\n    ans = {}\\n\\n    for i in range(2, int(math.sqrt(a)) + 1):\\n        if a % i == 0:\\n            ans[i] = 0\\n            while a % i == 0:\\n                a //= i\\n                ans[i] += 1\\n\\n    ans[a] = 1\\n\\n    return ans\\n\\n\\ndef inverse(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = (k - a[j] % k) % k\\n\\n    return buf\\n\\n\\ndef normal(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = a[j] % k\\n\\n    return buf\\n\\n\\ndef getHash(d):\\n    ans = 1\\n    for i in d.keys():\\n        ans *= i ** d[i]\\n    return ans\\n\\n\\nn, k = map(int, input().split(' '))\\n\\na = [i for i in map(int, input().split(' '))]\\n\\nb = [i for i in map(fac, a)]\\n\\nfactors = {}\\n\\nfor i in b:\\n    buf = getHash(inverse(i, k))\\n    if buf in factors.keys():\\n        factors[buf] += 1\\n    else:\\n        factors[buf] = 1\\n\\nans = 0\\n\\nfor i in range(len(b)):\\n    b[i] = normal(b[i], k)\\n    if getHash(b[i]) == getHash(inverse(b[i], k)):\\n        ans -= 1\\n\\nfor i in map(getHash, b):\\n    if i in factors.keys():\\n        ans += factors[i]\\n\\nprint(ans // 2)\", \"import sys\\ninput =  lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\n\\ndef factors(n, k):\\n    i = 2\\n    sq = int(n**0.5)+1\\n    di={}\\n    while n != 1:\\n        if n % i == 0:\\n            cur = 0\\n            while n % i == 0:\\n                n = n // i\\n                cur += 1\\n            if cur % k != 0:\\n                di[i] = cur % k\\n        i += 1\\n        if i > sq:break\\n    if n != 1:\\n        di[n] = 1\\n    return \\\"|\\\".join(\\\"%d:%d\\\" % (i, di[i]) for i in di)\\n\\nft = {}\\ndi = {}\\n\\nfor i in a:\\n    ft[i] = factors(i, k)\\n    di[ft[i]] = 1 if ft[i] not in di else di[ft[i]] + 1\\n\\nans = 0\\nfor i in a:\\n    ftt = ft[i]\\n    if ftt == \\\"\\\":\\n        ans += di[ftt] - 1\\n    else:\\n        dx = {}\\n        for oo in ftt.split(\\\"|\\\"):\\n            x, y = map(int, oo.split(\\\":\\\"))\\n            dx[x] = - y % k\\n        ftt2 = \\\"|\\\".join(\\\"%d:%d\\\" % (i, dx[i]) for i in dx)\\n        if ftt == ftt2:\\n            ans += di[ftt2] - 1\\n        else:\\n            if ftt2 in di:\\n                ans += di[ftt2]\\n\\nprint(ans//2)\", \"from collections import defaultdict as dc\\ndic=dc(lambda:0)\\nx,y=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nsiv=[0]*(max(s)+1)\\nln=len(siv)\\nsiv[1]=1;\\n\\nfor n in range(2,ln):\\n    if siv[n]==0:\\n        siv[n]=n\\n        for k in range(2*n,ln,n):\\n            if siv[k]==0:\\n                siv[k]=n\\n\\ndef prf(x):\\n    dic=dc(lambda:0)\\n    while x>1:\\n        d=siv[x]\\n        dic[siv[x]]+=1\\n        x//=siv[x]\\n    \\n    return dic\\n\\ndef req(dic,k):\\n    cur=dic\\n    for n in cur:\\n        cur[n]%=k\\n    for n in cur:\\n        cur[n]=(k-cur[n])%k\\n    tot=1\\n    for n in cur:\\n        tot*=(n**cur[n])\\n    return tot\\n\\ndef conv(x,k):\\n    dicc=prf(x)\\n    for n in dicc:\\n        dicc[n]%=k\\n    tot=1\\n    for n in dicc:\\n        tot*=(n**dicc[n])\\n\\n    return tot\\n\\nres=0\\nfor n in s:\\n    re=req(prf(n),y)\\n    res+=dic[re]\\n    dic[conv(n,y)]+=1\\n\\nprint(res)\\n\", \"from math import sqrt\\ndef gd(n, k):\\n    ans = 1\\n    obrans = 1\\n    for i in range(2, int(sqrt(n) + 1)):\\n        j = 0\\n        while n % i == 0:\\n            j += 1\\n            n //= i\\n        ans *= pow(i, j%k)\\n        obrans *= pow(i, (-j)%k)\\n    ans *= n\\n    obrans *= pow(n, (k-1))\\n    return ans, obrans\\nn, k = map(int,input().split())\\noba = set()\\ndct = {}\\nfor i in list(map(int,input().split())):\\n    a,b = gd(i, k)\\n    dct[a] = dct.get(a, 0) + 1\\n    a,b = min(a,b), max(a,b)\\n    oba.add((a,b))\\nans = 0\\nfor i, j in oba:\\n    if i == j:\\n        ans += (dct.get(i, 0)  * dct.get(j, 0) - dct.get(i, 0)) // 2\\n    else:\\n        ans += dct.get(i, 0) * dct.get(j, 0)\\nprint(ans)\", \"import itertools as it\\nfrom collections import defaultdict\\nimport os\\nimport sys\\n\\n\\ndef sieve(n):\\n    is_prime = [True] * n\\n\\n    for candidate in it.chain([2], list(range(3, int(n ** 0.5) + 1, 2))):\\n        if is_prime[candidate]:\\n            for k in range(2 * candidate, n, candidate):\\n                is_prime[k] = False\\n\\n    primes = [idx for idx, k in enumerate(is_prime) if idx >= 2 and k]\\n    return primes\\n\\n\\ndef factorize(n, primes, k):\\n    factors = []\\n    number = n\\n    for f in primes:\\n        count = 0\\n        while number % f == 0:\\n            count += 1\\n            number //= f\\n\\n        if count % k:\\n            factors.append((f, count % k))\\n\\n        if f > number:\\n            break\\n\\n    if number > 1:\\n        factors.append((number, 1))\\n\\n    return tuple(factors)\\n\\n\\ndef solve(arr, k):\\n    total = 0\\n    d = defaultdict(int, {})\\n    primes = sieve(int(1e5 ** 0.5) + 10)\\n    for a in arr:\\n        fac = factorize(a, primes, k)\\n        fac_complement = tuple((f, k - count) for f, count in fac)\\n        total += d[fac_complement]\\n        d[fac] += 1\\n\\n    return total\\n\\n\\ndef pp(input):\\n    # T = int(input())\\n    # for t in range(T):\\n    n, k = list(map(int, input().strip().split()))\\n    arr = list(map(int, input().strip().split()))\\n    print(solve(arr, k))\\n\\n\\nif \\\"paalto\\\" in os.getcwd():\\n    from string_source import string_source, codeforces_parse\\n\\n    pp(\\n        string_source(\\n            \\\"\\\"\\\"6 3\\n1 3 9 8 24 1\\\"\\\"\\\"\\n        )\\n    )\\nelse:\\n    pp(sys.stdin.readline)\\n\", \"from collections import defaultdict\\nimport sys as _sys\\n\\n\\ndef main():\\n    n, k = _read_ints()\\n    a = tuple(_read_ints())\\n    result = find_good_pairs_n(a, k)\\n    print(result)\\n\\n\\ndef _read_line():\\n    result = _sys.stdin.readline()\\n    assert result[-1] == \\\"\\\\n\\\"\\n    return result[:-1]\\n\\n\\ndef _read_ints():\\n    return list(map(int, _read_line().split()))\\n\\n\\ndef find_good_pairs_n(sequence, k):\\n    sequence = tuple(sequence)\\n    factors_seq = tuple(map(_find_prime_factors, sequence))\\n    \\n    factors_seq = [[(kv[0], kv[1] % k) for kv in list(factors.items())] for factors in factors_seq]\\n    factors_seq = [[kv for kv in factors if kv[1] > 0] for factors in factors_seq]\\n    factors_seq = list(map(sorted, factors_seq))\\n    factors_seq = tuple(map(tuple, factors_seq))\\n    \\n    counter = defaultdict(int)\\n    for factors in factors_seq:\\n        counter[factors] += 1\\n    \\n    result = 0\\n    for factors in factors_seq:\\n        necessary_factors = tuple((factor, k - amount) for factor, amount in factors)\\n        result += counter[necessary_factors]\\n        if factors == necessary_factors:\\n            result -= 1\\n    \\n    assert result % 2 == 0\\n    result //= 2\\n    return result\\n\\n\\ndef _find_prime_factors(x):\\n    result = dict()\\n    \\n    if x % 2 == 0:\\n        factor_2_n = 0\\n        while x & 1 == 0:\\n            x >>= 1\\n            factor_2_n += 1\\n        result[2] = factor_2_n\\n    \\n    factor = 3\\n    while x != 1 and factor * factor <= x:\\n        if x % factor == 0:\\n            factor_n = 0\\n            while x % factor == 0:\\n                x //= factor\\n                factor_n += 1\\n            result[factor] = factor_n\\n        factor += 2\\n\\n    if x != 1:\\n        result[x] = 1\\n\\n    return result\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"from collections import defaultdict\\n\\nclass Primes():\\n    def __init__(self, N):\\n        self.N = N\\n        self.prime = {i for i in range(2, self.N+1)}\\n        self.spf = [-1]*(N + 1)\\n        for i in range(2, self.N+1):\\n            if i in self.prime:\\n                self.spf[i] = i\\n                for j in range(i*2, self.N+1, i):\\n                    if j in self.prime:\\n                        self.spf[j] = i\\n                        self.prime.remove(j)\\n\\n    def fact(self,Number):\\n        v = Number\\n        d = defaultdict(int)\\n        while v > 1:\\n            x = self.spf[v]\\n            d[x] += 1\\n            v//=x\\n        return d\\n\\n\\nP = Primes(10**5)\\n\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ncnt = [0]*(10**5 + 1)\\nfor v in a:\\n    cnt[v] += 1\\n\\nans = 0\\nfor v in a:\\n    cnt[v] -= 1\\n    d = P.fact(v)\\n    res = 1\\n    for num,order in list(d.items()):\\n        res *= pow(num,(k-order%k)%k)\\n    if res <= 10**5:\\n        for i in range(1,1000):\\n            if pow(i,k)*res > 10**5:\\n                break\\n            ans += cnt[pow(i,k)*res]\\nprint(ans)\\n\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 2\n61441 92480\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1225/D"
    },
    {
        "id": 1952,
        "task_id": 2190,
        "test_case_id": 6,
        "question": "You are given $n$ positive integers $a_1, \\ldots, a_n$, and an integer $k \\geq 2$. Count the number of pairs $i, j$ such that $1 \\leq i < j \\leq n$, and there exists an integer $x$ such that $a_i \\cdot a_j = x^k$.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $k$ ($2 \\leq n \\leq 10^5$, $2 \\leq k \\leq 100$).\n\nThe second line contains $n$ integers $a_1, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^5$).\n\n\n-----Output-----\n\nPrint a single integer — the number of suitable pairs.\n\n\n-----Example-----\nInput\n6 3\n1 3 9 8 24 1\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the sample case, the suitable pairs are: $a_1 \\cdot a_4 = 8 = 2^3$; $a_1 \\cdot a_6 = 1 = 1^3$; $a_2 \\cdot a_3 = 27 = 3^3$; $a_3 \\cdot a_5 = 216 = 6^3$; $a_4 \\cdot a_6 = 8 = 2^3$.",
        "solutions": "[\"def f(n):\\n    Ans = []\\n    d = 2\\n    while d * d <= n:\\n        if n % d == 0:\\n            Ans.append(d)\\n            n //= d\\n        else:\\n            d += 1\\n    if n > 1:\\n        Ans.append(n)\\n    return Ans\\n\\n\\nn, k = list(map(int, input().split()))\\narr = list(map(int, input().split()))\\n\\nm = {}\\nc = 0\\nfor i in arr:\\n    r = {}\\n    d = 2\\n    while d * d <= i:\\n        if i % d == 0:\\n            r[d] = (r.get(d, 0) + 1) % k\\n            i //= d\\n        else:\\n            d += 1\\n    if i > 1:\\n        r[i] = (r.get(i, 0) + 1) % k\\n    r = tuple([x for x in list(r.items()) if x[1]])\\n    r2 = tuple([(x[0], k - x[1]) for x in r])\\n    c += m.get(r2, 0)\\n    m[r] = m.get(r, 0) + 1\\nprint(c)\\n\", \"from collections import defaultdict\\nimport math\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\n\\nans = 0\\nhm = defaultdict(int)\\n\\nfor i in range(n):\\n    x = 2\\n    t = []\\n    t1 = []\\n    y = a[i]\\n    while x<=math.sqrt(a[i]):\\n        if a[i]%x==0:\\n            c = 0\\n            while y%x==0:\\n                y = y//x\\n                c += 1\\n            if c%k>0:\\n                t.append((x,c%k))\\n                t1.append((x,k-(c%k)))\\n        x += 1\\n    if y>1:\\n        t.append((y,1%k))\\n        t1.append((y,k-(1%k)))\\n\\n    ans += hm[tuple(t1)]\\n    hm[tuple(t)] += 1\\n\\nprint(ans)\\n        \\n\", \"from collections import defaultdict\\n\\ntotal = 0 \\nimport math\\ndic = defaultdict(int)\\nn, k = list(map(int, input().split()))\\nz = list(map(int, input().split()))\\nfor ii in z:\\n\\n    i = ii\\n    x = []\\n    x2=[]\\n    a = 2\\n    while a<=math.sqrt(ii):\\n        co = 0\\n        while i % a == 0:\\n            i = i//a\\n            co += 1\\n        co=co%k\\n        if co:\\n            x.append((a, co))\\n            x2.append((a, k-co))\\n        a += 1\\n    if i>1:\\n        x.append((i,1))\\n        x2.append((i,k-1))\\n    # print(i)\\n    # print(x)\\n    # print(dic)\\n    dic[tuple(x)] += 1\\n    total += dic[tuple(x2)]\\n        # print(f\\\"ans:{x} and {inver(x)}\\\")\\n    if(x2 == x):\\n        total-=1\\n\\n\\n\\n# print(x)\\nprint(total)\\n\", \"n,k=list(map(int,input().split()))\\narr=list(map(int,input().split()))\\nans=0\\nd={}\\nfor i in range(n):\\n\\tx=2\\n\\ta=[]\\n\\tb=[]\\n\\ty=arr[i]\\n\\twhile x*x<=arr[i]:\\n\\t\\tif arr[i]%x==0:\\n\\t\\t\\tc=0\\n\\t\\t\\twhile y%x==0:\\n\\t\\t\\t\\ty=y//x\\n\\t\\t\\t\\tc+=1\\n\\t\\t\\tif c%k>0:\\n\\t\\t\\t\\ta.append((x,c%k))\\n\\t\\t\\t\\tb.append((x,k-(c%k)))\\n\\t\\tx+=1\\n\\tif y>1:\\n\\t\\ta.append((y,1%k))\\n\\t\\tb.append((y,k-(1%k)))\\n\\ttry:\\n\\t\\tans+=d[tuple(b)]\\n\\texcept:\\n\\t\\tpass\\n\\ttry:\\n\\t\\td[tuple(a)]+=1\\n\\texcept:\\n\\t\\td[tuple(a)]=1\\nprint(ans)\\n\", \"n, k = map(int, input().split())\\n*a, = map(int, input().split())\\nd = {}\\nans = 0\\nfor i in a:\\n    x, j, tmp1, tmp2 = i, 2, [], []\\n    while j * j <= i:\\n        c = 0\\n        while x % j == 0:\\n            c += 1\\n            x //= j\\n        if c % k:\\n            tmp2.append((j, k - c % k))\\n            tmp1.append((j, c % k))\\n        j += 1\\n    if x > 1:\\n        tmp1.append((x, 1))\\n        tmp2.append((x, k - 1))\\n    tmp1, tmp2 = tuple(tmp1), tuple(tmp2)\\n    ans += d.get(tmp2, 0)\\n    d[tmp1] = d.get(tmp1, 0) + 1\\nprint(ans)\", \"import math\\nfrom collections import Counter\\n \\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n \\nans = 0\\nprev = Counter()\\nfor x in a:\\n\\tsig = []\\n\\tp = 2\\n\\twhile p <= math.sqrt(x):\\n\\t\\tcnt = 0\\n\\t\\twhile x % p == 0:\\n\\t\\t\\tcnt += 1\\n\\t\\t\\tx = x // p\\n \\n\\t\\tcnt = cnt % k\\n\\t\\tif cnt > 0:\\n\\t\\t\\tsig.append((p, cnt))\\n \\n\\t\\tp += 1\\n \\n\\tif x > 1:\\n\\t\\tsig.append((x, 1))\\n \\n\\tcom_sig = []\\n\\tfor p, val in sig:\\n\\t\\tcom_sig.append((p, (k - val) % k))\\n \\n\\tans += prev[tuple(sig)]\\n\\tprev[tuple(com_sig)] += 1\\n \\nprint(ans)\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\nd = {}\\nans = 0\\n\\nfor el in a:\\n    i = 2\\n    a = []\\n    b = []\\n    while i*i <= el:\\n        cnt = 0\\n        while not(el%i):\\n            el //= i\\n            cnt += 1\\n        if cnt%k:\\n            a.append((i, cnt%k))\\n            b.append((i, k-(cnt%k)))\\n        i += 1\\n    \\n    if el > 1:\\n        a.append((el, 1))\\n        b.append((el, k-1))\\n\\n    a = tuple(a)\\n    b = tuple(b)\\n\\n    ans += d.get(b, 0)\\n    d[a] = d.get(a, 0)+1\\n    \\nprint(ans)\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 2/11/20\\n\\n\\\"\\\"\\\"\\n\\nimport collections\\nimport time\\nimport os\\nimport sys\\nimport bisect\\nimport heapq\\nfrom typing import List\\nimport math\\n\\n\\ndef factors(val):\\n    wc = []\\n    for i in range(2, int(math.sqrt(val)) + 2):\\n        if i > val:\\n            break\\n        if val % i == 0:\\n            c = 0\\n            while val % i == 0:\\n                c += 1\\n                val //= i\\n            wc.append((i, c))\\n    if val > 1:\\n        wc.append((val, 1))\\n    return wc\\n\\n\\ndef expand(fc, maxd, k):\\n    def dfs(index, mul):\\n        if index >= len(fc):\\n            return [mul]\\n        \\n        w, c = fc[index]\\n        d = k - (c % k) if c % k != 0 else 0\\n        x = []\\n        t = mul * (w ** d)\\n        while t <= maxd:\\n            x.extend(dfs(index + 1, t))\\n            d += k\\n            t *= w**k\\n        \\n        return x\\n        \\n    return dfs(0, 1)\\n    \\ndef solve(N, K, A):\\n    wc = collections.defaultdict(int)\\n    ans = 0\\n    for v in A:\\n        fc = factors(v)\\n        fc = [(f, c % K) for f, c in fc if c % K != 0]\\n        key = '_'.join(['{}+{}'.format(f, c) for f, c in fc])\\n        cov = [(f, K-c) for f, c in fc]\\n        ckey = '_'.join(['{}+{}'.format(f, c) for f, c in cov])\\n        ans += wc[ckey]\\n        wc[key] += 1\\n\\n    return ans\\n    \\nN, K = map(int, input().split())\\nA = [int(x) for x in input().split()]\\nprint(solve(N, K, A))\", \"from math import *\\n\\nn, k = list(map(int, input().split()))\\na = [int(i) for i in input().split()]\\nma = max(a)\\n\\np = []\\nprime = [True] * (ma + 1)\\nprime[0] = False\\nprime[1] = False\\nfor i in range(2, ma + 1):\\n    if prime[i]:\\n        p.append(i)\\n        if i**2 <= n:\\n            for j in range(i**2, ma + 1, i):\\n                prime[j] = False\\n\\n\\ndef factor(x):\\n    res = {}\\n    sq = ceil(sqrt(x))\\n    for i in p:\\n        if i > sq or x <= 1:\\n            break\\n        if x % i == 0:\\n            res[i] = 0\\n            while x % i == 0:\\n                res[i] += 1\\n                x //= i\\n    if x > 1:\\n        res[x] = 1\\n    nres = []\\n    for j in res:\\n        if res[j] % k > 0:\\n            nres.append((j, res[j] % k))\\n    \\n    return tuple(nres)\\n\\nd = {}\\nfor i in range(n):\\n    f = factor(a[i])\\n    #print(f, a[i])\\n    if f not in d:\\n        d[f] = 1\\n    else:\\n        d[f] += 1\\n        \\nans = 0\\n#print(d)\\nfor x in d:\\n    y = []\\n    for i in x:\\n        y.append((i[0], k - i[1]))\\n    y = tuple(y)\\n    if y in d:\\n        if y != x:\\n            ans += d[x] * d[y]\\n        else:\\n            ans += d[x] * (d[y] - 1)\\n    #print(x, y, ans)\\n\\nprint(ans//2)\\n\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\ndel mark\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\nd = defaultdict(int)\\nans = 0\\n\\nfor i in a:\\n\\tt, t1 = (), ()\\n\\tfor j in primes:\\n\\t\\tif i == 1:break\\n\\t\\telif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt += (j,z)\\n\\t\\t\\t\\tt1 += (j,k-z)\\n\\tif i != 1:\\n\\t\\tt += (i,1)\\n\\t\\tt1 += (i,k-1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"from collections import defaultdict\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\nn = int(max(a)**.5)\\nmark = [True]*(n+1)\\nprimes = []\\nfor i in range(2,n+1):\\n\\tif mark[i]:\\n\\t\\tprimes.append(i)\\n\\t\\tfor j in range(i, n+1, i): mark[j] = False\\n\\nd = defaultdict(int)\\n\\nans = 0\\nfor i in a:\\n\\tt, t1 = [], []\\n\\tfor j in primes:\\n\\t\\tif i%j == 0:\\n\\t\\t\\tx = 0\\n\\t\\t\\twhile i%j==0: \\n\\t\\t\\t\\ti//=j\\n\\t\\t\\t\\tx += 1\\n\\t\\t\\tz = x%k\\n\\t\\t\\tif z:\\n\\t\\t\\t\\tt.append((j,z))\\n\\t\\t\\t\\tt1.append((j,k-z))\\n\\t\\telif i == 1:break\\n\\tif i != 1:\\n\\t\\tt.append((i,1))\\n\\t\\tt1.append((i,k-1))\\n\\n\\tt = tuple(t)\\n\\tt1 = tuple(t1)\\n\\n\\tans += d[t1]\\n\\td[t] += 1\\nprint(ans)\", \"import math\\n\\n\\ndef fac(a):\\n    ans = {}\\n\\n    for i in range(2, int(math.sqrt(a)) + 1):\\n        if a % i == 0:\\n            ans[i] = 0\\n            while a % i == 0:\\n                a //= i\\n                ans[i] += 1\\n\\n    ans[a] = 1\\n\\n    return ans\\n\\n\\ndef inverse(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = (k - a[j] % k) % k\\n\\n    return buf\\n\\n\\ndef normal(a, k):\\n    buf = {}\\n\\n    for j in a.keys():\\n        buf[j] = a[j] % k\\n\\n    return buf\\n\\n\\ndef getHash(d):\\n    ans = 1\\n    for i in d.keys():\\n        ans *= i ** d[i]\\n    return ans\\n\\n\\nn, k = map(int, input().split(' '))\\n\\na = [i for i in map(int, input().split(' '))]\\n\\nb = [i for i in map(fac, a)]\\n\\nfactors = {}\\n\\nfor i in b:\\n    buf = getHash(inverse(i, k))\\n    if buf in factors.keys():\\n        factors[buf] += 1\\n    else:\\n        factors[buf] = 1\\n\\nans = 0\\n\\nfor i in range(len(b)):\\n    b[i] = normal(b[i], k)\\n    if getHash(b[i]) == getHash(inverse(b[i], k)):\\n        ans -= 1\\n\\nfor i in map(getHash, b):\\n    if i in factors.keys():\\n        ans += factors[i]\\n\\nprint(ans // 2)\", \"import sys\\ninput =  lambda: sys.stdin.readline().rstrip(\\\"\\\\r\\\\n\\\")\\n\\nn, k = map(int, input().split())\\na = list(map(int, input().split()))\\n\\n\\ndef factors(n, k):\\n    i = 2\\n    sq = int(n**0.5)+1\\n    di={}\\n    while n != 1:\\n        if n % i == 0:\\n            cur = 0\\n            while n % i == 0:\\n                n = n // i\\n                cur += 1\\n            if cur % k != 0:\\n                di[i] = cur % k\\n        i += 1\\n        if i > sq:break\\n    if n != 1:\\n        di[n] = 1\\n    return \\\"|\\\".join(\\\"%d:%d\\\" % (i, di[i]) for i in di)\\n\\nft = {}\\ndi = {}\\n\\nfor i in a:\\n    ft[i] = factors(i, k)\\n    di[ft[i]] = 1 if ft[i] not in di else di[ft[i]] + 1\\n\\nans = 0\\nfor i in a:\\n    ftt = ft[i]\\n    if ftt == \\\"\\\":\\n        ans += di[ftt] - 1\\n    else:\\n        dx = {}\\n        for oo in ftt.split(\\\"|\\\"):\\n            x, y = map(int, oo.split(\\\":\\\"))\\n            dx[x] = - y % k\\n        ftt2 = \\\"|\\\".join(\\\"%d:%d\\\" % (i, dx[i]) for i in dx)\\n        if ftt == ftt2:\\n            ans += di[ftt2] - 1\\n        else:\\n            if ftt2 in di:\\n                ans += di[ftt2]\\n\\nprint(ans//2)\", \"from collections import defaultdict as dc\\ndic=dc(lambda:0)\\nx,y=list(map(int,input().split()))\\ns=list(map(int,input().split()))\\nsiv=[0]*(max(s)+1)\\nln=len(siv)\\nsiv[1]=1;\\n\\nfor n in range(2,ln):\\n    if siv[n]==0:\\n        siv[n]=n\\n        for k in range(2*n,ln,n):\\n            if siv[k]==0:\\n                siv[k]=n\\n\\ndef prf(x):\\n    dic=dc(lambda:0)\\n    while x>1:\\n        d=siv[x]\\n        dic[siv[x]]+=1\\n        x//=siv[x]\\n    \\n    return dic\\n\\ndef req(dic,k):\\n    cur=dic\\n    for n in cur:\\n        cur[n]%=k\\n    for n in cur:\\n        cur[n]=(k-cur[n])%k\\n    tot=1\\n    for n in cur:\\n        tot*=(n**cur[n])\\n    return tot\\n\\ndef conv(x,k):\\n    dicc=prf(x)\\n    for n in dicc:\\n        dicc[n]%=k\\n    tot=1\\n    for n in dicc:\\n        tot*=(n**dicc[n])\\n\\n    return tot\\n\\nres=0\\nfor n in s:\\n    re=req(prf(n),y)\\n    res+=dic[re]\\n    dic[conv(n,y)]+=1\\n\\nprint(res)\\n\", \"from math import sqrt\\ndef gd(n, k):\\n    ans = 1\\n    obrans = 1\\n    for i in range(2, int(sqrt(n) + 1)):\\n        j = 0\\n        while n % i == 0:\\n            j += 1\\n            n //= i\\n        ans *= pow(i, j%k)\\n        obrans *= pow(i, (-j)%k)\\n    ans *= n\\n    obrans *= pow(n, (k-1))\\n    return ans, obrans\\nn, k = map(int,input().split())\\noba = set()\\ndct = {}\\nfor i in list(map(int,input().split())):\\n    a,b = gd(i, k)\\n    dct[a] = dct.get(a, 0) + 1\\n    a,b = min(a,b), max(a,b)\\n    oba.add((a,b))\\nans = 0\\nfor i, j in oba:\\n    if i == j:\\n        ans += (dct.get(i, 0)  * dct.get(j, 0) - dct.get(i, 0)) // 2\\n    else:\\n        ans += dct.get(i, 0) * dct.get(j, 0)\\nprint(ans)\", \"import itertools as it\\nfrom collections import defaultdict\\nimport os\\nimport sys\\n\\n\\ndef sieve(n):\\n    is_prime = [True] * n\\n\\n    for candidate in it.chain([2], list(range(3, int(n ** 0.5) + 1, 2))):\\n        if is_prime[candidate]:\\n            for k in range(2 * candidate, n, candidate):\\n                is_prime[k] = False\\n\\n    primes = [idx for idx, k in enumerate(is_prime) if idx >= 2 and k]\\n    return primes\\n\\n\\ndef factorize(n, primes, k):\\n    factors = []\\n    number = n\\n    for f in primes:\\n        count = 0\\n        while number % f == 0:\\n            count += 1\\n            number //= f\\n\\n        if count % k:\\n            factors.append((f, count % k))\\n\\n        if f > number:\\n            break\\n\\n    if number > 1:\\n        factors.append((number, 1))\\n\\n    return tuple(factors)\\n\\n\\ndef solve(arr, k):\\n    total = 0\\n    d = defaultdict(int, {})\\n    primes = sieve(int(1e5 ** 0.5) + 10)\\n    for a in arr:\\n        fac = factorize(a, primes, k)\\n        fac_complement = tuple((f, k - count) for f, count in fac)\\n        total += d[fac_complement]\\n        d[fac] += 1\\n\\n    return total\\n\\n\\ndef pp(input):\\n    # T = int(input())\\n    # for t in range(T):\\n    n, k = list(map(int, input().strip().split()))\\n    arr = list(map(int, input().strip().split()))\\n    print(solve(arr, k))\\n\\n\\nif \\\"paalto\\\" in os.getcwd():\\n    from string_source import string_source, codeforces_parse\\n\\n    pp(\\n        string_source(\\n            \\\"\\\"\\\"6 3\\n1 3 9 8 24 1\\\"\\\"\\\"\\n        )\\n    )\\nelse:\\n    pp(sys.stdin.readline)\\n\", \"from collections import defaultdict\\nimport sys as _sys\\n\\n\\ndef main():\\n    n, k = _read_ints()\\n    a = tuple(_read_ints())\\n    result = find_good_pairs_n(a, k)\\n    print(result)\\n\\n\\ndef _read_line():\\n    result = _sys.stdin.readline()\\n    assert result[-1] == \\\"\\\\n\\\"\\n    return result[:-1]\\n\\n\\ndef _read_ints():\\n    return list(map(int, _read_line().split()))\\n\\n\\ndef find_good_pairs_n(sequence, k):\\n    sequence = tuple(sequence)\\n    factors_seq = tuple(map(_find_prime_factors, sequence))\\n    \\n    factors_seq = [[(kv[0], kv[1] % k) for kv in list(factors.items())] for factors in factors_seq]\\n    factors_seq = [[kv for kv in factors if kv[1] > 0] for factors in factors_seq]\\n    factors_seq = list(map(sorted, factors_seq))\\n    factors_seq = tuple(map(tuple, factors_seq))\\n    \\n    counter = defaultdict(int)\\n    for factors in factors_seq:\\n        counter[factors] += 1\\n    \\n    result = 0\\n    for factors in factors_seq:\\n        necessary_factors = tuple((factor, k - amount) for factor, amount in factors)\\n        result += counter[necessary_factors]\\n        if factors == necessary_factors:\\n            result -= 1\\n    \\n    assert result % 2 == 0\\n    result //= 2\\n    return result\\n\\n\\ndef _find_prime_factors(x):\\n    result = dict()\\n    \\n    if x % 2 == 0:\\n        factor_2_n = 0\\n        while x & 1 == 0:\\n            x >>= 1\\n            factor_2_n += 1\\n        result[2] = factor_2_n\\n    \\n    factor = 3\\n    while x != 1 and factor * factor <= x:\\n        if x % factor == 0:\\n            factor_n = 0\\n            while x % factor == 0:\\n                x //= factor\\n                factor_n += 1\\n            result[factor] = factor_n\\n        factor += 2\\n\\n    if x != 1:\\n        result[x] = 1\\n\\n    return result\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"from collections import defaultdict\\n\\nclass Primes():\\n    def __init__(self, N):\\n        self.N = N\\n        self.prime = {i for i in range(2, self.N+1)}\\n        self.spf = [-1]*(N + 1)\\n        for i in range(2, self.N+1):\\n            if i in self.prime:\\n                self.spf[i] = i\\n                for j in range(i*2, self.N+1, i):\\n                    if j in self.prime:\\n                        self.spf[j] = i\\n                        self.prime.remove(j)\\n\\n    def fact(self,Number):\\n        v = Number\\n        d = defaultdict(int)\\n        while v > 1:\\n            x = self.spf[v]\\n            d[x] += 1\\n            v//=x\\n        return d\\n\\n\\nP = Primes(10**5)\\n\\nn,k = list(map(int,input().split()))\\na = list(map(int,input().split()))\\ncnt = [0]*(10**5 + 1)\\nfor v in a:\\n    cnt[v] += 1\\n\\nans = 0\\nfor v in a:\\n    cnt[v] -= 1\\n    d = P.fact(v)\\n    res = 1\\n    for num,order in list(d.items()):\\n        res *= pow(num,(k-order%k)%k)\\n    if res <= 10**5:\\n        for i in range(1,1000):\\n            if pow(i,k)*res > 10**5:\\n                break\\n            ans += cnt[pow(i,k)*res]\\nprint(ans)\\n\\n\\n\\n\"]",
        "difficulty": "interview",
        "input": "2 5\n49248 87211\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1225/D"
    },
    {
        "id": 1953,
        "task_id": 2235,
        "test_case_id": 1,
        "question": "A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.\n\nThe fare is constructed in the following manner. There are three types of tickets:   a ticket for one trip costs 20 byteland rubles,  a ticket for 90 minutes costs 50 byteland rubles,  a ticket for one day (1440 minutes) costs 120 byteland rubles. \n\nNote that a ticket for x minutes activated at time t can be used for trips started in time range from t to t + x - 1, inclusive. Assume that all trips take exactly one minute.\n\nTo simplify the choice for the passenger, the system automatically chooses the optimal tickets. After each trip starts, the system analyses all the previous trips and the current trip and chooses a set of tickets for these trips with a minimum total cost. Let the minimum total cost of tickets to cover all trips from the first to the current is a, and the total sum charged before is b. Then the system charges the passenger the sum a - b.\n\nYou have to write a program that, for given trips made by a passenger, calculates the sum the passenger is charged after each trip.\n\n\n-----Input-----\n\nThe first line of input contains integer number n (1 ≤ n ≤ 10^5) — the number of trips made by passenger.\n\nEach of the following n lines contains the time of trip t_{i} (0 ≤ t_{i} ≤ 10^9), measured in minutes from the time of starting the system. All t_{i} are different, given in ascending order, i. e. t_{i} + 1 > t_{i} holds for all 1 ≤ i < n.\n\n\n-----Output-----\n\nOutput n integers. For each trip, print the sum the passenger is charged after it.\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\n20\n20\n10\n\nInput\n10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n\nOutput\n20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n\n\n\n-----Note-----\n\nIn the first example, the system works as follows: for the first and second trips it is cheaper to pay for two one-trip tickets, so each time 20 rubles is charged, after the third trip the system understands that it would be cheaper to buy a ticket for 90 minutes. This ticket costs 50 rubles, and the passenger had already paid 40 rubles, so it is necessary to charge 10 rubles only.",
        "solutions": "[\"import sys\\nimport bisect\\ninput = sys.stdin.readline\\n\\ntrips = int(input())\\ndyn = [int(input()) for i in range(trips)]\\n\\ncmap = [0,20] + [0 for i in range(trips-1)]\\n\\nfor i in range(2,trips+1):\\n    cmap[i] = min(cmap[i-1] + 20,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-89)] + 50,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-1439)] + 120)\\n\\nfor i in range(1,trips+1):\\n    print(cmap[i]-cmap[i-1])\\n\\n\", \"n = int(input())\\n\\ntravel_times = list()\\ntravel_pay = list()\\n\\npay_ticket1 = 0\\ntime_ticket1 = 0\\n\\npay_ticket2 = 0\\ntime_ticket2 = 0\\n\\nfor travel_id in range(n):\\n    t = int(input())\\n    travel_times.append(t)\\n    \\n    pay2 = 20\\n    \\n    sum_time1 = t - travel_times[time_ticket1]\\n    sum_time2 = t - travel_times[time_ticket2]\\n\\n    if sum_time1 >= 90:\\n        pay_ticket1 -= travel_pay[time_ticket1]\\n        \\n        for id2 in range(time_ticket1+1, travel_id+1):\\n            if t - travel_times[id2] < 90:\\n                time_ticket1 = id2\\n                break\\n            else:\\n                pay_ticket1 -= travel_pay[id2]\\n\\n        sum_time1 = t - travel_times[time_ticket1]\\n\\n\\n    if sum_time2 >= 1440:\\n        pay_ticket2 -= travel_pay[time_ticket2]\\n        \\n        for id2 in range(time_ticket2+1, travel_id+1):\\n            if t - travel_times[id2] < 1440:\\n                time_ticket2 = id2\\n                break\\n            else:\\n                pay_ticket2 -= travel_pay[id2]\\n\\n        sum_time2 = t - travel_times[time_ticket2]\\n\\n    \\n\\n    if pay_ticket1 + pay2 > 50:\\n        pay2 = 50 - pay_ticket1\\n\\n    if pay_ticket2 + pay2 > 120:\\n        pay2 = 120 - pay_ticket2\\n\\n    \\n    pay_ticket1 += pay2\\n    pay_ticket2 += pay2\\n    \\n    travel_pay.append(pay2)\\n    \\nfor pay in travel_pay:\\n    print(pay)\", \"import bisect\\n\\ndef getIndex(a, x):\\n    \\n    for i in range(0, len(a)):\\n        if  a[i] > x:\\n            return i\\n    return 0\\n\\n\\nn = int(input())\\n\\ntimes = []\\ntotal = 0\\nfor i in range(0, n):\\n    time = int(input())\\n    times.append(time)\\n    total += time \\n    \\ncost = [0 for i in range(0, n + 1)]\\ncost[0] = 0\\ncost[1] = 20\\n\\nfor i in range(2, n + 1):\\n    cost[i] =  min(cost[i - 1] + 20, \\n        cost[bisect.bisect_left(times, times[i-1] - 89)] + 50, \\n        cost[bisect.bisect_left(times, times[i-1] - 1439)] + 120)\\n    \\n    # print(cost[getIndex(89, times, i - 1)] + 50)\\n# print(cost)\\n# print(times)\\nfor i in range(1, n + 1):\\n    print(cost[i] - cost[i - 1])\\n\", \"def main():\\n\\tN = int(input())\\n\\tS = [0]\\n\\tT = [0]\\n\\tkh = 0\\n\\tkd = 0\\n\\tfor n in range(1, N+1):\\n\\t\\tT.append(int(input()))\\n\\t\\tfor i in range(kh + 1, n):\\n\\t\\t\\t#print(T[n], T[i])\\n\\t\\t\\tif T[n] - T[i] < 90:\\n\\t\\t\\t\\tkh = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkh = i\\n\\t\\tfor i in range(kd + 1, n):\\n\\t\\t\\tif T[n] - T[i] < 1440:\\n\\t\\t\\t\\tkd = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkd = i\\n\\t\\t#print(n, kh, kd)\\n\\t\\t#print(20, S[n - 1], 50, S[kh], 120, S[kd])\\n\\t\\tS.append(min(20 + S[n - 1], 50 + S[kh], 120 + S[kd]))\\n\\t\\t#print(T)\\n\\t\\t#print(S)\\n\\t\\tprint(S[n] - S[n - 1])\\n\\nmain()\\n\\n# 1509134058412\\n\", \"n=int(input())\\nex1=0\\nex2=0\\nL=[]\\nf=[0]*(n+1)\\nfor i in range(n):\\n    L.append(int(input()))\\n    while (L[i] - L[ex1 ] >= 90):\\n        ex1+=1\\n    while (L[i] - L[ex2 ] >= 1440):\\n        ex2+=1\\n    f[i+1] = min(min(f[ex1] + 50, f[ex2] + 120), f[i] + 20)\\n    print(f[i+1] - f[i])\\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n    \\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    \\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n\", \"\\nn = int(input())\\na = [0,]\\nfor i in range(n):\\n\\tx = int(input())\\n\\ta.append(x)\\n\\ndp = [0] * (n + 1)\\ndp[0] = 0\\np90 = 1\\np1440 = 1\\nfor i in range(1, n + 1):\\n\\tdp[i] = dp[i - 1] + 20\\n\\twhile a[p90] + 90 <= a[i]:\\n\\t\\tp90 = p90 + 1\\n\\tdp[i] = min(dp[i], dp[p90 - 1] + 50)\\n\\twhile a[p1440] + 1440 <= a[i]:\\n\\t\\tp1440 = p1440 + 1\\n\\tdp[i] = min(dp[i], dp[p1440 - 1] + 120)\\nfor i in range(1, n + 1):\\n\\tprint(dp[i] - dp[i - 1])\", \"n=int(input())\\n\\ntrips=[]\\n\\nprix=[0]\\n\\nk=0\\n\\nj=0\\n\\nfor i in range (n):\\n\\n    trips.append(int(input()))\\n\\n    while trips[i]-trips[j]>=90 :\\n\\n        j+=1\\n\\n    while trips[i]-trips[k]>=1440:\\n\\n        k+=1\\n\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n\\n    print(prix[-1]-prix[-2])\\n\\n    \\n\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"import math\\nimport sys\\nfrom bisect import bisect_right, bisect_left, insort_right\\nfrom collections import Counter, defaultdict\\nfrom heapq import heappop, heappush\\nfrom itertools import accumulate, permutations, combinations\\nfrom sys import stdout\\n\\nR = lambda: map(int, input().split())\\nn = int(input())\\narr = []\\nfor _ in range(n):\\n    arr.append(int(input()))\\ncst = [math.inf] * n + [0]\\nfor i in range(n):\\n    cst[i] = min(cst[i - 1] + 20, cst[bisect_left(arr, arr[i] - 89) - 1] + 50, cst[bisect_left(arr, arr[i] - 1439) - 1] + 120)\\nfor i in range(n):\\n    print(cst[i] - cst[i - 1])\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\"]",
        "difficulty": "interview",
        "input": "3\n10\n20\n30\n",
        "output": "20\n20\n10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/756/B"
    },
    {
        "id": 1954,
        "task_id": 2235,
        "test_case_id": 2,
        "question": "A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.\n\nThe fare is constructed in the following manner. There are three types of tickets:   a ticket for one trip costs 20 byteland rubles,  a ticket for 90 minutes costs 50 byteland rubles,  a ticket for one day (1440 minutes) costs 120 byteland rubles. \n\nNote that a ticket for x minutes activated at time t can be used for trips started in time range from t to t + x - 1, inclusive. Assume that all trips take exactly one minute.\n\nTo simplify the choice for the passenger, the system automatically chooses the optimal tickets. After each trip starts, the system analyses all the previous trips and the current trip and chooses a set of tickets for these trips with a minimum total cost. Let the minimum total cost of tickets to cover all trips from the first to the current is a, and the total sum charged before is b. Then the system charges the passenger the sum a - b.\n\nYou have to write a program that, for given trips made by a passenger, calculates the sum the passenger is charged after each trip.\n\n\n-----Input-----\n\nThe first line of input contains integer number n (1 ≤ n ≤ 10^5) — the number of trips made by passenger.\n\nEach of the following n lines contains the time of trip t_{i} (0 ≤ t_{i} ≤ 10^9), measured in minutes from the time of starting the system. All t_{i} are different, given in ascending order, i. e. t_{i} + 1 > t_{i} holds for all 1 ≤ i < n.\n\n\n-----Output-----\n\nOutput n integers. For each trip, print the sum the passenger is charged after it.\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\n20\n20\n10\n\nInput\n10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n\nOutput\n20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n\n\n\n-----Note-----\n\nIn the first example, the system works as follows: for the first and second trips it is cheaper to pay for two one-trip tickets, so each time 20 rubles is charged, after the third trip the system understands that it would be cheaper to buy a ticket for 90 minutes. This ticket costs 50 rubles, and the passenger had already paid 40 rubles, so it is necessary to charge 10 rubles only.",
        "solutions": "[\"import sys\\nimport bisect\\ninput = sys.stdin.readline\\n\\ntrips = int(input())\\ndyn = [int(input()) for i in range(trips)]\\n\\ncmap = [0,20] + [0 for i in range(trips-1)]\\n\\nfor i in range(2,trips+1):\\n    cmap[i] = min(cmap[i-1] + 20,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-89)] + 50,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-1439)] + 120)\\n\\nfor i in range(1,trips+1):\\n    print(cmap[i]-cmap[i-1])\\n\\n\", \"n = int(input())\\n\\ntravel_times = list()\\ntravel_pay = list()\\n\\npay_ticket1 = 0\\ntime_ticket1 = 0\\n\\npay_ticket2 = 0\\ntime_ticket2 = 0\\n\\nfor travel_id in range(n):\\n    t = int(input())\\n    travel_times.append(t)\\n    \\n    pay2 = 20\\n    \\n    sum_time1 = t - travel_times[time_ticket1]\\n    sum_time2 = t - travel_times[time_ticket2]\\n\\n    if sum_time1 >= 90:\\n        pay_ticket1 -= travel_pay[time_ticket1]\\n        \\n        for id2 in range(time_ticket1+1, travel_id+1):\\n            if t - travel_times[id2] < 90:\\n                time_ticket1 = id2\\n                break\\n            else:\\n                pay_ticket1 -= travel_pay[id2]\\n\\n        sum_time1 = t - travel_times[time_ticket1]\\n\\n\\n    if sum_time2 >= 1440:\\n        pay_ticket2 -= travel_pay[time_ticket2]\\n        \\n        for id2 in range(time_ticket2+1, travel_id+1):\\n            if t - travel_times[id2] < 1440:\\n                time_ticket2 = id2\\n                break\\n            else:\\n                pay_ticket2 -= travel_pay[id2]\\n\\n        sum_time2 = t - travel_times[time_ticket2]\\n\\n    \\n\\n    if pay_ticket1 + pay2 > 50:\\n        pay2 = 50 - pay_ticket1\\n\\n    if pay_ticket2 + pay2 > 120:\\n        pay2 = 120 - pay_ticket2\\n\\n    \\n    pay_ticket1 += pay2\\n    pay_ticket2 += pay2\\n    \\n    travel_pay.append(pay2)\\n    \\nfor pay in travel_pay:\\n    print(pay)\", \"import bisect\\n\\ndef getIndex(a, x):\\n    \\n    for i in range(0, len(a)):\\n        if  a[i] > x:\\n            return i\\n    return 0\\n\\n\\nn = int(input())\\n\\ntimes = []\\ntotal = 0\\nfor i in range(0, n):\\n    time = int(input())\\n    times.append(time)\\n    total += time \\n    \\ncost = [0 for i in range(0, n + 1)]\\ncost[0] = 0\\ncost[1] = 20\\n\\nfor i in range(2, n + 1):\\n    cost[i] =  min(cost[i - 1] + 20, \\n        cost[bisect.bisect_left(times, times[i-1] - 89)] + 50, \\n        cost[bisect.bisect_left(times, times[i-1] - 1439)] + 120)\\n    \\n    # print(cost[getIndex(89, times, i - 1)] + 50)\\n# print(cost)\\n# print(times)\\nfor i in range(1, n + 1):\\n    print(cost[i] - cost[i - 1])\\n\", \"def main():\\n\\tN = int(input())\\n\\tS = [0]\\n\\tT = [0]\\n\\tkh = 0\\n\\tkd = 0\\n\\tfor n in range(1, N+1):\\n\\t\\tT.append(int(input()))\\n\\t\\tfor i in range(kh + 1, n):\\n\\t\\t\\t#print(T[n], T[i])\\n\\t\\t\\tif T[n] - T[i] < 90:\\n\\t\\t\\t\\tkh = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkh = i\\n\\t\\tfor i in range(kd + 1, n):\\n\\t\\t\\tif T[n] - T[i] < 1440:\\n\\t\\t\\t\\tkd = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkd = i\\n\\t\\t#print(n, kh, kd)\\n\\t\\t#print(20, S[n - 1], 50, S[kh], 120, S[kd])\\n\\t\\tS.append(min(20 + S[n - 1], 50 + S[kh], 120 + S[kd]))\\n\\t\\t#print(T)\\n\\t\\t#print(S)\\n\\t\\tprint(S[n] - S[n - 1])\\n\\nmain()\\n\\n# 1509134058412\\n\", \"n=int(input())\\nex1=0\\nex2=0\\nL=[]\\nf=[0]*(n+1)\\nfor i in range(n):\\n    L.append(int(input()))\\n    while (L[i] - L[ex1 ] >= 90):\\n        ex1+=1\\n    while (L[i] - L[ex2 ] >= 1440):\\n        ex2+=1\\n    f[i+1] = min(min(f[ex1] + 50, f[ex2] + 120), f[i] + 20)\\n    print(f[i+1] - f[i])\\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n    \\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    \\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n\", \"\\nn = int(input())\\na = [0,]\\nfor i in range(n):\\n\\tx = int(input())\\n\\ta.append(x)\\n\\ndp = [0] * (n + 1)\\ndp[0] = 0\\np90 = 1\\np1440 = 1\\nfor i in range(1, n + 1):\\n\\tdp[i] = dp[i - 1] + 20\\n\\twhile a[p90] + 90 <= a[i]:\\n\\t\\tp90 = p90 + 1\\n\\tdp[i] = min(dp[i], dp[p90 - 1] + 50)\\n\\twhile a[p1440] + 1440 <= a[i]:\\n\\t\\tp1440 = p1440 + 1\\n\\tdp[i] = min(dp[i], dp[p1440 - 1] + 120)\\nfor i in range(1, n + 1):\\n\\tprint(dp[i] - dp[i - 1])\", \"n=int(input())\\n\\ntrips=[]\\n\\nprix=[0]\\n\\nk=0\\n\\nj=0\\n\\nfor i in range (n):\\n\\n    trips.append(int(input()))\\n\\n    while trips[i]-trips[j]>=90 :\\n\\n        j+=1\\n\\n    while trips[i]-trips[k]>=1440:\\n\\n        k+=1\\n\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n\\n    print(prix[-1]-prix[-2])\\n\\n    \\n\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"import math\\nimport sys\\nfrom bisect import bisect_right, bisect_left, insort_right\\nfrom collections import Counter, defaultdict\\nfrom heapq import heappop, heappush\\nfrom itertools import accumulate, permutations, combinations\\nfrom sys import stdout\\n\\nR = lambda: map(int, input().split())\\nn = int(input())\\narr = []\\nfor _ in range(n):\\n    arr.append(int(input()))\\ncst = [math.inf] * n + [0]\\nfor i in range(n):\\n    cst[i] = min(cst[i - 1] + 20, cst[bisect_left(arr, arr[i] - 89) - 1] + 50, cst[bisect_left(arr, arr[i] - 1439) - 1] + 120)\\nfor i in range(n):\\n    print(cst[i] - cst[i - 1])\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\"]",
        "difficulty": "interview",
        "input": "10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n",
        "output": "20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/756/B"
    },
    {
        "id": 1955,
        "task_id": 2235,
        "test_case_id": 3,
        "question": "A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.\n\nThe fare is constructed in the following manner. There are three types of tickets:   a ticket for one trip costs 20 byteland rubles,  a ticket for 90 minutes costs 50 byteland rubles,  a ticket for one day (1440 minutes) costs 120 byteland rubles. \n\nNote that a ticket for x minutes activated at time t can be used for trips started in time range from t to t + x - 1, inclusive. Assume that all trips take exactly one minute.\n\nTo simplify the choice for the passenger, the system automatically chooses the optimal tickets. After each trip starts, the system analyses all the previous trips and the current trip and chooses a set of tickets for these trips with a minimum total cost. Let the minimum total cost of tickets to cover all trips from the first to the current is a, and the total sum charged before is b. Then the system charges the passenger the sum a - b.\n\nYou have to write a program that, for given trips made by a passenger, calculates the sum the passenger is charged after each trip.\n\n\n-----Input-----\n\nThe first line of input contains integer number n (1 ≤ n ≤ 10^5) — the number of trips made by passenger.\n\nEach of the following n lines contains the time of trip t_{i} (0 ≤ t_{i} ≤ 10^9), measured in minutes from the time of starting the system. All t_{i} are different, given in ascending order, i. e. t_{i} + 1 > t_{i} holds for all 1 ≤ i < n.\n\n\n-----Output-----\n\nOutput n integers. For each trip, print the sum the passenger is charged after it.\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\n20\n20\n10\n\nInput\n10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n\nOutput\n20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n\n\n\n-----Note-----\n\nIn the first example, the system works as follows: for the first and second trips it is cheaper to pay for two one-trip tickets, so each time 20 rubles is charged, after the third trip the system understands that it would be cheaper to buy a ticket for 90 minutes. This ticket costs 50 rubles, and the passenger had already paid 40 rubles, so it is necessary to charge 10 rubles only.",
        "solutions": "[\"import sys\\nimport bisect\\ninput = sys.stdin.readline\\n\\ntrips = int(input())\\ndyn = [int(input()) for i in range(trips)]\\n\\ncmap = [0,20] + [0 for i in range(trips-1)]\\n\\nfor i in range(2,trips+1):\\n    cmap[i] = min(cmap[i-1] + 20,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-89)] + 50,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-1439)] + 120)\\n\\nfor i in range(1,trips+1):\\n    print(cmap[i]-cmap[i-1])\\n\\n\", \"n = int(input())\\n\\ntravel_times = list()\\ntravel_pay = list()\\n\\npay_ticket1 = 0\\ntime_ticket1 = 0\\n\\npay_ticket2 = 0\\ntime_ticket2 = 0\\n\\nfor travel_id in range(n):\\n    t = int(input())\\n    travel_times.append(t)\\n    \\n    pay2 = 20\\n    \\n    sum_time1 = t - travel_times[time_ticket1]\\n    sum_time2 = t - travel_times[time_ticket2]\\n\\n    if sum_time1 >= 90:\\n        pay_ticket1 -= travel_pay[time_ticket1]\\n        \\n        for id2 in range(time_ticket1+1, travel_id+1):\\n            if t - travel_times[id2] < 90:\\n                time_ticket1 = id2\\n                break\\n            else:\\n                pay_ticket1 -= travel_pay[id2]\\n\\n        sum_time1 = t - travel_times[time_ticket1]\\n\\n\\n    if sum_time2 >= 1440:\\n        pay_ticket2 -= travel_pay[time_ticket2]\\n        \\n        for id2 in range(time_ticket2+1, travel_id+1):\\n            if t - travel_times[id2] < 1440:\\n                time_ticket2 = id2\\n                break\\n            else:\\n                pay_ticket2 -= travel_pay[id2]\\n\\n        sum_time2 = t - travel_times[time_ticket2]\\n\\n    \\n\\n    if pay_ticket1 + pay2 > 50:\\n        pay2 = 50 - pay_ticket1\\n\\n    if pay_ticket2 + pay2 > 120:\\n        pay2 = 120 - pay_ticket2\\n\\n    \\n    pay_ticket1 += pay2\\n    pay_ticket2 += pay2\\n    \\n    travel_pay.append(pay2)\\n    \\nfor pay in travel_pay:\\n    print(pay)\", \"import bisect\\n\\ndef getIndex(a, x):\\n    \\n    for i in range(0, len(a)):\\n        if  a[i] > x:\\n            return i\\n    return 0\\n\\n\\nn = int(input())\\n\\ntimes = []\\ntotal = 0\\nfor i in range(0, n):\\n    time = int(input())\\n    times.append(time)\\n    total += time \\n    \\ncost = [0 for i in range(0, n + 1)]\\ncost[0] = 0\\ncost[1] = 20\\n\\nfor i in range(2, n + 1):\\n    cost[i] =  min(cost[i - 1] + 20, \\n        cost[bisect.bisect_left(times, times[i-1] - 89)] + 50, \\n        cost[bisect.bisect_left(times, times[i-1] - 1439)] + 120)\\n    \\n    # print(cost[getIndex(89, times, i - 1)] + 50)\\n# print(cost)\\n# print(times)\\nfor i in range(1, n + 1):\\n    print(cost[i] - cost[i - 1])\\n\", \"def main():\\n\\tN = int(input())\\n\\tS = [0]\\n\\tT = [0]\\n\\tkh = 0\\n\\tkd = 0\\n\\tfor n in range(1, N+1):\\n\\t\\tT.append(int(input()))\\n\\t\\tfor i in range(kh + 1, n):\\n\\t\\t\\t#print(T[n], T[i])\\n\\t\\t\\tif T[n] - T[i] < 90:\\n\\t\\t\\t\\tkh = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkh = i\\n\\t\\tfor i in range(kd + 1, n):\\n\\t\\t\\tif T[n] - T[i] < 1440:\\n\\t\\t\\t\\tkd = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkd = i\\n\\t\\t#print(n, kh, kd)\\n\\t\\t#print(20, S[n - 1], 50, S[kh], 120, S[kd])\\n\\t\\tS.append(min(20 + S[n - 1], 50 + S[kh], 120 + S[kd]))\\n\\t\\t#print(T)\\n\\t\\t#print(S)\\n\\t\\tprint(S[n] - S[n - 1])\\n\\nmain()\\n\\n# 1509134058412\\n\", \"n=int(input())\\nex1=0\\nex2=0\\nL=[]\\nf=[0]*(n+1)\\nfor i in range(n):\\n    L.append(int(input()))\\n    while (L[i] - L[ex1 ] >= 90):\\n        ex1+=1\\n    while (L[i] - L[ex2 ] >= 1440):\\n        ex2+=1\\n    f[i+1] = min(min(f[ex1] + 50, f[ex2] + 120), f[i] + 20)\\n    print(f[i+1] - f[i])\\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n    \\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    \\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n\", \"\\nn = int(input())\\na = [0,]\\nfor i in range(n):\\n\\tx = int(input())\\n\\ta.append(x)\\n\\ndp = [0] * (n + 1)\\ndp[0] = 0\\np90 = 1\\np1440 = 1\\nfor i in range(1, n + 1):\\n\\tdp[i] = dp[i - 1] + 20\\n\\twhile a[p90] + 90 <= a[i]:\\n\\t\\tp90 = p90 + 1\\n\\tdp[i] = min(dp[i], dp[p90 - 1] + 50)\\n\\twhile a[p1440] + 1440 <= a[i]:\\n\\t\\tp1440 = p1440 + 1\\n\\tdp[i] = min(dp[i], dp[p1440 - 1] + 120)\\nfor i in range(1, n + 1):\\n\\tprint(dp[i] - dp[i - 1])\", \"n=int(input())\\n\\ntrips=[]\\n\\nprix=[0]\\n\\nk=0\\n\\nj=0\\n\\nfor i in range (n):\\n\\n    trips.append(int(input()))\\n\\n    while trips[i]-trips[j]>=90 :\\n\\n        j+=1\\n\\n    while trips[i]-trips[k]>=1440:\\n\\n        k+=1\\n\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n\\n    print(prix[-1]-prix[-2])\\n\\n    \\n\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"import math\\nimport sys\\nfrom bisect import bisect_right, bisect_left, insort_right\\nfrom collections import Counter, defaultdict\\nfrom heapq import heappop, heappush\\nfrom itertools import accumulate, permutations, combinations\\nfrom sys import stdout\\n\\nR = lambda: map(int, input().split())\\nn = int(input())\\narr = []\\nfor _ in range(n):\\n    arr.append(int(input()))\\ncst = [math.inf] * n + [0]\\nfor i in range(n):\\n    cst[i] = min(cst[i - 1] + 20, cst[bisect_left(arr, arr[i] - 89) - 1] + 50, cst[bisect_left(arr, arr[i] - 1439) - 1] + 120)\\nfor i in range(n):\\n    print(cst[i] - cst[i - 1])\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\"]",
        "difficulty": "interview",
        "input": "7\n100\n138\n279\n308\n396\n412\n821\n",
        "output": "20\n20\n20\n20\n20\n20\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/756/B"
    },
    {
        "id": 1956,
        "task_id": 2235,
        "test_case_id": 4,
        "question": "A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.\n\nThe fare is constructed in the following manner. There are three types of tickets:   a ticket for one trip costs 20 byteland rubles,  a ticket for 90 minutes costs 50 byteland rubles,  a ticket for one day (1440 minutes) costs 120 byteland rubles. \n\nNote that a ticket for x minutes activated at time t can be used for trips started in time range from t to t + x - 1, inclusive. Assume that all trips take exactly one minute.\n\nTo simplify the choice for the passenger, the system automatically chooses the optimal tickets. After each trip starts, the system analyses all the previous trips and the current trip and chooses a set of tickets for these trips with a minimum total cost. Let the minimum total cost of tickets to cover all trips from the first to the current is a, and the total sum charged before is b. Then the system charges the passenger the sum a - b.\n\nYou have to write a program that, for given trips made by a passenger, calculates the sum the passenger is charged after each trip.\n\n\n-----Input-----\n\nThe first line of input contains integer number n (1 ≤ n ≤ 10^5) — the number of trips made by passenger.\n\nEach of the following n lines contains the time of trip t_{i} (0 ≤ t_{i} ≤ 10^9), measured in minutes from the time of starting the system. All t_{i} are different, given in ascending order, i. e. t_{i} + 1 > t_{i} holds for all 1 ≤ i < n.\n\n\n-----Output-----\n\nOutput n integers. For each trip, print the sum the passenger is charged after it.\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\n20\n20\n10\n\nInput\n10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n\nOutput\n20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n\n\n\n-----Note-----\n\nIn the first example, the system works as follows: for the first and second trips it is cheaper to pay for two one-trip tickets, so each time 20 rubles is charged, after the third trip the system understands that it would be cheaper to buy a ticket for 90 minutes. This ticket costs 50 rubles, and the passenger had already paid 40 rubles, so it is necessary to charge 10 rubles only.",
        "solutions": "[\"import sys\\nimport bisect\\ninput = sys.stdin.readline\\n\\ntrips = int(input())\\ndyn = [int(input()) for i in range(trips)]\\n\\ncmap = [0,20] + [0 for i in range(trips-1)]\\n\\nfor i in range(2,trips+1):\\n    cmap[i] = min(cmap[i-1] + 20,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-89)] + 50,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-1439)] + 120)\\n\\nfor i in range(1,trips+1):\\n    print(cmap[i]-cmap[i-1])\\n\\n\", \"n = int(input())\\n\\ntravel_times = list()\\ntravel_pay = list()\\n\\npay_ticket1 = 0\\ntime_ticket1 = 0\\n\\npay_ticket2 = 0\\ntime_ticket2 = 0\\n\\nfor travel_id in range(n):\\n    t = int(input())\\n    travel_times.append(t)\\n    \\n    pay2 = 20\\n    \\n    sum_time1 = t - travel_times[time_ticket1]\\n    sum_time2 = t - travel_times[time_ticket2]\\n\\n    if sum_time1 >= 90:\\n        pay_ticket1 -= travel_pay[time_ticket1]\\n        \\n        for id2 in range(time_ticket1+1, travel_id+1):\\n            if t - travel_times[id2] < 90:\\n                time_ticket1 = id2\\n                break\\n            else:\\n                pay_ticket1 -= travel_pay[id2]\\n\\n        sum_time1 = t - travel_times[time_ticket1]\\n\\n\\n    if sum_time2 >= 1440:\\n        pay_ticket2 -= travel_pay[time_ticket2]\\n        \\n        for id2 in range(time_ticket2+1, travel_id+1):\\n            if t - travel_times[id2] < 1440:\\n                time_ticket2 = id2\\n                break\\n            else:\\n                pay_ticket2 -= travel_pay[id2]\\n\\n        sum_time2 = t - travel_times[time_ticket2]\\n\\n    \\n\\n    if pay_ticket1 + pay2 > 50:\\n        pay2 = 50 - pay_ticket1\\n\\n    if pay_ticket2 + pay2 > 120:\\n        pay2 = 120 - pay_ticket2\\n\\n    \\n    pay_ticket1 += pay2\\n    pay_ticket2 += pay2\\n    \\n    travel_pay.append(pay2)\\n    \\nfor pay in travel_pay:\\n    print(pay)\", \"import bisect\\n\\ndef getIndex(a, x):\\n    \\n    for i in range(0, len(a)):\\n        if  a[i] > x:\\n            return i\\n    return 0\\n\\n\\nn = int(input())\\n\\ntimes = []\\ntotal = 0\\nfor i in range(0, n):\\n    time = int(input())\\n    times.append(time)\\n    total += time \\n    \\ncost = [0 for i in range(0, n + 1)]\\ncost[0] = 0\\ncost[1] = 20\\n\\nfor i in range(2, n + 1):\\n    cost[i] =  min(cost[i - 1] + 20, \\n        cost[bisect.bisect_left(times, times[i-1] - 89)] + 50, \\n        cost[bisect.bisect_left(times, times[i-1] - 1439)] + 120)\\n    \\n    # print(cost[getIndex(89, times, i - 1)] + 50)\\n# print(cost)\\n# print(times)\\nfor i in range(1, n + 1):\\n    print(cost[i] - cost[i - 1])\\n\", \"def main():\\n\\tN = int(input())\\n\\tS = [0]\\n\\tT = [0]\\n\\tkh = 0\\n\\tkd = 0\\n\\tfor n in range(1, N+1):\\n\\t\\tT.append(int(input()))\\n\\t\\tfor i in range(kh + 1, n):\\n\\t\\t\\t#print(T[n], T[i])\\n\\t\\t\\tif T[n] - T[i] < 90:\\n\\t\\t\\t\\tkh = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkh = i\\n\\t\\tfor i in range(kd + 1, n):\\n\\t\\t\\tif T[n] - T[i] < 1440:\\n\\t\\t\\t\\tkd = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkd = i\\n\\t\\t#print(n, kh, kd)\\n\\t\\t#print(20, S[n - 1], 50, S[kh], 120, S[kd])\\n\\t\\tS.append(min(20 + S[n - 1], 50 + S[kh], 120 + S[kd]))\\n\\t\\t#print(T)\\n\\t\\t#print(S)\\n\\t\\tprint(S[n] - S[n - 1])\\n\\nmain()\\n\\n# 1509134058412\\n\", \"n=int(input())\\nex1=0\\nex2=0\\nL=[]\\nf=[0]*(n+1)\\nfor i in range(n):\\n    L.append(int(input()))\\n    while (L[i] - L[ex1 ] >= 90):\\n        ex1+=1\\n    while (L[i] - L[ex2 ] >= 1440):\\n        ex2+=1\\n    f[i+1] = min(min(f[ex1] + 50, f[ex2] + 120), f[i] + 20)\\n    print(f[i+1] - f[i])\\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n    \\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    \\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n\", \"\\nn = int(input())\\na = [0,]\\nfor i in range(n):\\n\\tx = int(input())\\n\\ta.append(x)\\n\\ndp = [0] * (n + 1)\\ndp[0] = 0\\np90 = 1\\np1440 = 1\\nfor i in range(1, n + 1):\\n\\tdp[i] = dp[i - 1] + 20\\n\\twhile a[p90] + 90 <= a[i]:\\n\\t\\tp90 = p90 + 1\\n\\tdp[i] = min(dp[i], dp[p90 - 1] + 50)\\n\\twhile a[p1440] + 1440 <= a[i]:\\n\\t\\tp1440 = p1440 + 1\\n\\tdp[i] = min(dp[i], dp[p1440 - 1] + 120)\\nfor i in range(1, n + 1):\\n\\tprint(dp[i] - dp[i - 1])\", \"n=int(input())\\n\\ntrips=[]\\n\\nprix=[0]\\n\\nk=0\\n\\nj=0\\n\\nfor i in range (n):\\n\\n    trips.append(int(input()))\\n\\n    while trips[i]-trips[j]>=90 :\\n\\n        j+=1\\n\\n    while trips[i]-trips[k]>=1440:\\n\\n        k+=1\\n\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n\\n    print(prix[-1]-prix[-2])\\n\\n    \\n\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"import math\\nimport sys\\nfrom bisect import bisect_right, bisect_left, insort_right\\nfrom collections import Counter, defaultdict\\nfrom heapq import heappop, heappush\\nfrom itertools import accumulate, permutations, combinations\\nfrom sys import stdout\\n\\nR = lambda: map(int, input().split())\\nn = int(input())\\narr = []\\nfor _ in range(n):\\n    arr.append(int(input()))\\ncst = [math.inf] * n + [0]\\nfor i in range(n):\\n    cst[i] = min(cst[i - 1] + 20, cst[bisect_left(arr, arr[i] - 89) - 1] + 50, cst[bisect_left(arr, arr[i] - 1439) - 1] + 120)\\nfor i in range(n):\\n    print(cst[i] - cst[i - 1])\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\"]",
        "difficulty": "interview",
        "input": "8\n0\n2\n51\n63\n69\n75\n80\n90\n",
        "output": "20\n20\n10\n0\n0\n0\n0\n20\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/756/B"
    },
    {
        "id": 1957,
        "task_id": 2235,
        "test_case_id": 5,
        "question": "A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.\n\nThe fare is constructed in the following manner. There are three types of tickets:   a ticket for one trip costs 20 byteland rubles,  a ticket for 90 minutes costs 50 byteland rubles,  a ticket for one day (1440 minutes) costs 120 byteland rubles. \n\nNote that a ticket for x minutes activated at time t can be used for trips started in time range from t to t + x - 1, inclusive. Assume that all trips take exactly one minute.\n\nTo simplify the choice for the passenger, the system automatically chooses the optimal tickets. After each trip starts, the system analyses all the previous trips and the current trip and chooses a set of tickets for these trips with a minimum total cost. Let the minimum total cost of tickets to cover all trips from the first to the current is a, and the total sum charged before is b. Then the system charges the passenger the sum a - b.\n\nYou have to write a program that, for given trips made by a passenger, calculates the sum the passenger is charged after each trip.\n\n\n-----Input-----\n\nThe first line of input contains integer number n (1 ≤ n ≤ 10^5) — the number of trips made by passenger.\n\nEach of the following n lines contains the time of trip t_{i} (0 ≤ t_{i} ≤ 10^9), measured in minutes from the time of starting the system. All t_{i} are different, given in ascending order, i. e. t_{i} + 1 > t_{i} holds for all 1 ≤ i < n.\n\n\n-----Output-----\n\nOutput n integers. For each trip, print the sum the passenger is charged after it.\n\n\n-----Examples-----\nInput\n3\n10\n20\n30\n\nOutput\n20\n20\n10\n\nInput\n10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n\nOutput\n20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n\n\n\n-----Note-----\n\nIn the first example, the system works as follows: for the first and second trips it is cheaper to pay for two one-trip tickets, so each time 20 rubles is charged, after the third trip the system understands that it would be cheaper to buy a ticket for 90 minutes. This ticket costs 50 rubles, and the passenger had already paid 40 rubles, so it is necessary to charge 10 rubles only.",
        "solutions": "[\"import sys\\nimport bisect\\ninput = sys.stdin.readline\\n\\ntrips = int(input())\\ndyn = [int(input()) for i in range(trips)]\\n\\ncmap = [0,20] + [0 for i in range(trips-1)]\\n\\nfor i in range(2,trips+1):\\n    cmap[i] = min(cmap[i-1] + 20,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-89)] + 50,\\n                  cmap[bisect.bisect_left(dyn,dyn[i-1]-1439)] + 120)\\n\\nfor i in range(1,trips+1):\\n    print(cmap[i]-cmap[i-1])\\n\\n\", \"n = int(input())\\n\\ntravel_times = list()\\ntravel_pay = list()\\n\\npay_ticket1 = 0\\ntime_ticket1 = 0\\n\\npay_ticket2 = 0\\ntime_ticket2 = 0\\n\\nfor travel_id in range(n):\\n    t = int(input())\\n    travel_times.append(t)\\n    \\n    pay2 = 20\\n    \\n    sum_time1 = t - travel_times[time_ticket1]\\n    sum_time2 = t - travel_times[time_ticket2]\\n\\n    if sum_time1 >= 90:\\n        pay_ticket1 -= travel_pay[time_ticket1]\\n        \\n        for id2 in range(time_ticket1+1, travel_id+1):\\n            if t - travel_times[id2] < 90:\\n                time_ticket1 = id2\\n                break\\n            else:\\n                pay_ticket1 -= travel_pay[id2]\\n\\n        sum_time1 = t - travel_times[time_ticket1]\\n\\n\\n    if sum_time2 >= 1440:\\n        pay_ticket2 -= travel_pay[time_ticket2]\\n        \\n        for id2 in range(time_ticket2+1, travel_id+1):\\n            if t - travel_times[id2] < 1440:\\n                time_ticket2 = id2\\n                break\\n            else:\\n                pay_ticket2 -= travel_pay[id2]\\n\\n        sum_time2 = t - travel_times[time_ticket2]\\n\\n    \\n\\n    if pay_ticket1 + pay2 > 50:\\n        pay2 = 50 - pay_ticket1\\n\\n    if pay_ticket2 + pay2 > 120:\\n        pay2 = 120 - pay_ticket2\\n\\n    \\n    pay_ticket1 += pay2\\n    pay_ticket2 += pay2\\n    \\n    travel_pay.append(pay2)\\n    \\nfor pay in travel_pay:\\n    print(pay)\", \"import bisect\\n\\ndef getIndex(a, x):\\n    \\n    for i in range(0, len(a)):\\n        if  a[i] > x:\\n            return i\\n    return 0\\n\\n\\nn = int(input())\\n\\ntimes = []\\ntotal = 0\\nfor i in range(0, n):\\n    time = int(input())\\n    times.append(time)\\n    total += time \\n    \\ncost = [0 for i in range(0, n + 1)]\\ncost[0] = 0\\ncost[1] = 20\\n\\nfor i in range(2, n + 1):\\n    cost[i] =  min(cost[i - 1] + 20, \\n        cost[bisect.bisect_left(times, times[i-1] - 89)] + 50, \\n        cost[bisect.bisect_left(times, times[i-1] - 1439)] + 120)\\n    \\n    # print(cost[getIndex(89, times, i - 1)] + 50)\\n# print(cost)\\n# print(times)\\nfor i in range(1, n + 1):\\n    print(cost[i] - cost[i - 1])\\n\", \"def main():\\n\\tN = int(input())\\n\\tS = [0]\\n\\tT = [0]\\n\\tkh = 0\\n\\tkd = 0\\n\\tfor n in range(1, N+1):\\n\\t\\tT.append(int(input()))\\n\\t\\tfor i in range(kh + 1, n):\\n\\t\\t\\t#print(T[n], T[i])\\n\\t\\t\\tif T[n] - T[i] < 90:\\n\\t\\t\\t\\tkh = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkh = i\\n\\t\\tfor i in range(kd + 1, n):\\n\\t\\t\\tif T[n] - T[i] < 1440:\\n\\t\\t\\t\\tkd = i - 1\\n\\t\\t\\t\\tbreak\\n\\t\\t\\telse:\\n\\t\\t\\t\\tkd = i\\n\\t\\t#print(n, kh, kd)\\n\\t\\t#print(20, S[n - 1], 50, S[kh], 120, S[kd])\\n\\t\\tS.append(min(20 + S[n - 1], 50 + S[kh], 120 + S[kd]))\\n\\t\\t#print(T)\\n\\t\\t#print(S)\\n\\t\\tprint(S[n] - S[n - 1])\\n\\nmain()\\n\\n# 1509134058412\\n\", \"n=int(input())\\nex1=0\\nex2=0\\nL=[]\\nf=[0]*(n+1)\\nfor i in range(n):\\n    L.append(int(input()))\\n    while (L[i] - L[ex1 ] >= 90):\\n        ex1+=1\\n    while (L[i] - L[ex2 ] >= 1440):\\n        ex2+=1\\n    f[i+1] = min(min(f[ex1] + 50, f[ex2] + 120), f[i] + 20)\\n    print(f[i+1] - f[i])\\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n    \\n\", \"n=int(input())\\ntrips=[]\\nprix=[0]\\nk=0\\nj=0\\nfor i in range (n):\\n    \\n    trips.append(int(input()))\\n    while trips[i]-trips[j]>=90 :\\n        j+=1\\n    while trips[i]-trips[k]>=1440:\\n        k+=1\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n    print(prix[-1]-prix[-2])\\n\", \"\\nn = int(input())\\na = [0,]\\nfor i in range(n):\\n\\tx = int(input())\\n\\ta.append(x)\\n\\ndp = [0] * (n + 1)\\ndp[0] = 0\\np90 = 1\\np1440 = 1\\nfor i in range(1, n + 1):\\n\\tdp[i] = dp[i - 1] + 20\\n\\twhile a[p90] + 90 <= a[i]:\\n\\t\\tp90 = p90 + 1\\n\\tdp[i] = min(dp[i], dp[p90 - 1] + 50)\\n\\twhile a[p1440] + 1440 <= a[i]:\\n\\t\\tp1440 = p1440 + 1\\n\\tdp[i] = min(dp[i], dp[p1440 - 1] + 120)\\nfor i in range(1, n + 1):\\n\\tprint(dp[i] - dp[i - 1])\", \"n=int(input())\\n\\ntrips=[]\\n\\nprix=[0]\\n\\nk=0\\n\\nj=0\\n\\nfor i in range (n):\\n\\n    trips.append(int(input()))\\n\\n    while trips[i]-trips[j]>=90 :\\n\\n        j+=1\\n\\n    while trips[i]-trips[k]>=1440:\\n\\n        k+=1\\n\\n    prix.append(min(min(prix[k]+120,prix[j]+50),prix[-1]+20))\\n\\n    print(prix[-1]-prix[-2])\\n\\n    \\n\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"import math\\nimport sys\\nfrom bisect import bisect_right, bisect_left, insort_right\\nfrom collections import Counter, defaultdict\\nfrom heapq import heappop, heappush\\nfrom itertools import accumulate, permutations, combinations\\nfrom sys import stdout\\n\\nR = lambda: map(int, input().split())\\nn = int(input())\\narr = []\\nfor _ in range(n):\\n    arr.append(int(input()))\\ncst = [math.inf] * n + [0]\\nfor i in range(n):\\n    cst[i] = min(cst[i - 1] + 20, cst[bisect_left(arr, arr[i] - 89) - 1] + 50, cst[bisect_left(arr, arr[i] - 1439) - 1] + 120)\\nfor i in range(n):\\n    print(cst[i] - cst[i - 1])\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\", \"from bisect import bisect_left as bl\\nfrom bisect import bisect_right as br\\nfrom heapq import heappush,heappop,heapify\\nimport math\\nfrom collections import *\\nfrom functools import reduce,cmp_to_key\\nimport sys\\ninput = sys.stdin.readline\\n\\nfrom itertools import accumulate\\nfrom functools import lru_cache\\n\\nM = mod = 998244353\\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split()]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\n\\nn = val()\\nl = []\\n\\nfor i in range(n):l.append(val())\\n\\nl.sort()\\n\\nl1 = [0]\\nl2 = [-float('inf')]\\n\\nfor i in l:\\n    ind2 = br(l2, i - 90) - 1\\n    ind1 = br(l2, i - 1) - 1\\n    ind3 = br(l2, i - 1440) - 1\\n    # print(ind1, ind2, ind3)\\n    l2.append(i)\\n    l1.append(min(l1[ind1] + 20, l1[ind2] + 50, l1[ind3] + 120))\\n    # print(l1, l2)\\nl2[0] = 0\\n# print(l2)\\nfor i in range(1, n + 1):\\n    print(l1[i] - l1[i - 1])\\nprint()\\n\"]",
        "difficulty": "interview",
        "input": "8\n0\n3\n5\n6\n7\n8\n9\n10\n",
        "output": "20\n20\n10\n0\n0\n0\n0\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/756/B"
    },
    {
        "id": 1958,
        "task_id": 2249,
        "test_case_id": 2,
        "question": "Since Sonya is interested in robotics too, she decided to construct robots that will read and recognize numbers.\n\nSonya has drawn $n$ numbers in a row, $a_i$ is located in the $i$-th position. She also has put a robot at each end of the row (to the left of the first number and to the right of the last number). Sonya will give a number to each robot (they can be either same or different) and run them. When a robot is running, it is moving toward to another robot, reading numbers in the row. When a robot is reading a number that is equal to the number that was given to that robot, it will turn off and stay in the same position.\n\nSonya does not want robots to break, so she will give such numbers that robots will stop before they meet. That is, the girl wants them to stop at different positions so that the first robot is to the left of the second one.\n\nFor example, if the numbers $[1, 5, 4, 1, 3]$ are written, and Sonya gives the number $1$ to the first robot and the number $4$ to the second one, the first robot will stop in the $1$-st position while the second one in the $3$-rd position. In that case, robots will not meet each other. As a result, robots will not be broken. But if Sonya gives the number $4$ to the first robot and the number $5$ to the second one, they will meet since the first robot will stop in the $3$-rd position while the second one is in the $2$-nd position.\n\nSonya understands that it does not make sense to give a number that is not written in the row because a robot will not find this number and will meet the other robot.\n\nSonya is now interested in finding the number of different pairs that she can give to robots so that they will not meet. In other words, she wants to know the number of pairs ($p$, $q$), where she will give $p$ to the first robot and $q$ to the second one. Pairs ($p_i$, $q_i$) and ($p_j$, $q_j$) are different if $p_i\\neq p_j$ or $q_i\\neq q_j$.\n\nUnfortunately, Sonya is busy fixing robots that broke after a failed launch. That is why she is asking you to find the number of pairs that she can give to robots so that they will not meet.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n\\leq 10^5$) — the number of numbers in a row.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1\\leq a_i\\leq 10^5$) — the numbers in a row.\n\n\n-----Output-----\n\nPrint one number — the number of possible pairs that Sonya can give to robots so that they will not meet.\n\n\n-----Examples-----\nInput\n5\n1 5 4 1 3\n\nOutput\n9\n\nInput\n7\n1 2 1 1 1 3 2\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example, Sonya can give pairs ($1$, $1$), ($1$, $3$), ($1$, $4$), ($1$, $5$), ($4$, $1$), ($4$, $3$), ($5$, $1$), ($5$, $3$), and ($5$, $4$).\n\nIn the second example, Sonya can give pairs ($1$, $1$), ($1$, $2$), ($1$, $3$), ($2$, $1$), ($2$, $2$), ($2$, $3$), and ($3$, $2$).",
        "solutions": "[\"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\nans = 0\\ncnt = [0] * (10 ** 5 + 10)\\ncur = set()\\nfor ai in a:\\n    cnt[ai] = len(cur)\\n    cur.add(ai)\\nans = sum(cnt)\\nprint(ans)\", \"def main():\\n    #string     input()\\n    #strList    input().split()\\n    n = int(input())\\n    #integers   map(int, input().split())\\n    a = list(map(int, input().split()))\\n    uniques = [0] * (n - 1) + [1]\\n    bools = [True] * 100001\\n    bools2 = [True] * 100001\\n    bools[a[-1]] = False\\n    for i in range(n - 2, 0, -1):\\n        temp = 0\\n        if bools[a[i]]:\\n            bools[a[i]] = False\\n            temp = 1\\n        uniques[i] = uniques[i + 1] + temp\\n    ret = 0\\n    for i in range(n - 1):\\n        if bools2[a[i]]:\\n            bools2[a[i]] = False\\n            ret += uniques[i + 1]\\n    print(ret)\\n    return 0\\nmain()\\n\", \"n = int(input())\\na = [int(x) for x in input().strip().split()]\\n\\nf = dict()\\nb = dict()\\nfor i in range(len(a)):\\n    if a[i] not in f:\\n        f[a[i]] = i\\n    if a[n-1-i] not in b:\\n        b[a[n-1-i]] = n-1-i\\n\\nf = sorted([v, k] for k, v in list(f.items()))\\nb = sorted([v, k] for k, v in list(b.items()))\\n\\nans = 0\\nbi = 0\\nfor i, v in f:\\n    while bi < len(b) and i >= b[bi][0]:\\n        bi += 1\\n    ans += len(b) - bi\\n\\nprint(ans)\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\n\\nMAX_NUM = 100010\\nmet_forw = [False] * MAX_NUM\\nmet_backw = [False] * MAX_NUM\\nunique_n_backw = [0] * n\\n\\nfor i in range(n - 1, -1, -1):\\n    if i < n - 1:\\n        unique_n_backw[i] = unique_n_backw[i + 1]\\n    if not met_backw[a[i]]:\\n        met_backw[a[i]] = True\\n        unique_n_backw[i] += 1\\n\\nanswer = 0\\nfor i in range(n - 1):\\n    if not met_forw[a[i]]:\\n        met_forw[a[i]] = True\\n        answer += unique_n_backw[i + 1]\\n\\nprint(answer)\\n\", \"n = int(input())\\nl = [int(el) for el in input().split()]\\ncol = 0\\na = [0] * 100001\\ns = set()\\nfor i in range(n):\\n    if a[l[i]] == 0:\\n        col += len(s)\\n        a[l[i]] += len(s)\\n        s.add(l[i])\\n    else:\\n        col += len(s) - a[l[i]]\\n        a[l[i]] = len(s)\\n        s.add(l[i])\\nprint(col)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nb=set()\\nc=[]\\ns=0\\nfor i in a:\\n\\tif not i in b:\\n\\t\\ts+=1\\n\\t\\tb.add(i)\\n\\tc.append(s)\\nb=set()\\nans=0\\nfor i in range(n-1,0,-1):\\n\\tif not a[i] in b:\\n\\t\\tans+=c[i-1]\\n\\t\\tb.add(a[i])\\nprint(ans)\", \"import sys\\nimport os\\n\\ndef extract(a):\\n    d = dict()\\n    r = []\\n    for e in a:\\n        if not e in d:\\n            r.append(1)\\n            d[e] = d\\n        else:\\n            r.append(0)\\n\\n    return r\\n\\ndef sonyaAndRobots(n, a):\\n    t1 = extract(a)\\n    t2 = list(reversed(extract(reversed(a))))\\n\\n    for i in range(n - 1):\\n        t1[i + 1] += t1[i]\\n\\n    result = 0\\n    for i in range(n - 1):\\n        result += t1[i] * t2[i + 1]\\n\\n    return result\\n\\ndef main():\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n    print(sonyaAndRobots(n, a))\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nright = list()\\ns = set()\\n\\nfor el in a[::-1]:\\n    s.add(el)\\n    right.append(len(s))\\n\\nright = right[::-1]\\n\\ns = set()\\nans = 0\\n\\nfor i, el in enumerate(a[:-1]):\\n    if el not in s:\\n        ans += right[i + 1]\\n\\n    s.add(el)\\n\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\ndic={}\\ndic2={}\\nansar=[]\\nfor i in range(n):\\n\\tdic[arr[i]]=0\\n\\tdic2[arr[i]]=0\\n\\tansar.append(0)\\ncount=0\\nfor i in range(n-1,0,-1):\\n\\tif dic[arr[i]]==0:\\n\\t\\tcount+=1\\n\\t\\t\\n\\t\\tdic[arr[i]]=1\\n\\tansar[i-1]=count\\t\\n#print(ansar)\\nanswer=0\\nfor i in range(n-1):\\n\\tif dic2[arr[i]]==0:\\n\\t\\tanswer+=ansar[i]\\n\\t\\tdic2[arr[i]]=1\\nprint(answer)\\t\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\ndic = {}\\nfor i in range(len(a) - 1):\\n    if a[i] not in dic:\\n        dic[a[i]] = 1\\n    else:\\n        dic[a[i]] += 1\\n\\nbeen = set([])\\ncnt = 0\\nfor i in range(len(a) - 1, 0, -1):\\n    if a[i] not in been:\\n        cnt += len(dic)\\n        been.add(a[i])\\n    dic[a[i - 1]] -= 1\\n    if (dic[a[i - 1]] == 0):\\n        del dic[a[i - 1]]\\nprint(cnt)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nb=a[:]\\ns=set()\\nfor i in range(n):\\n    if(a[i] in s):\\n        a[i]=0\\n    else:\\n        s.add(a[i])\\ns=set()\\nc=[0]*n\\nc[n-1]=1\\nfor i in range(n-1,-1,-1):\\n    if(b[i] in s):\\n        b[i]=0\\n        c[i]=c[i+1]\\n    else:\\n        s.add(b[i])\\n        if(i<n-1):\\n            c[i]=c[i+1]+1\\nans=0\\nfor i in range(n-1):\\n    if(a[i]):\\n        ans+=c[i+1]\\nprint(ans)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns = set()\\nd = dict()\\nc = [0] * n\\nfor i in range(n-1, -1, -1):\\n    c[i] = len(s)\\n    s.add(a[i])\\n    d[a[i]] = i\\nans = 0\\nfor k in list(d.keys()):\\n    pos = d[k]\\n    ans += c[pos]\\nprint(ans)\\n\\n\", \"from collections import defaultdict\\nn = int(input())\\narr = list(map(int,input().split()))\\nlist1 = [False]*(10**5+1)\\nd = defaultdict(int)\\ncount = 0 \\nfor i in range(n):\\n\\td[arr[i]] += 1\\nfor i in range(n-1):\\n\\td[arr[i]] -= 1\\n\\tif(d[arr[i]] == 0):\\n\\t\\tdel(d[arr[i]])\\n\\tif list1[arr[i]] == False:\\n\\t\\tcount += len(list(d.items()))\\n\\t\\tlist1[arr[i]] = True\\n\\n\\nprint(count)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\n\\na = list(map(int, input().split()))\\n\\ncounts = defaultdict(int)\\n\\nfor x in a:\\n    counts[x] += 1\\n\\nkeys = set()\\nc = len(counts)\\nans = 0\\n\\nfor x in a[:-1]:\\n    if x not in keys:\\n        keys.add(x)\\n        counts[x] -= 1\\n        if counts[x] == 0:\\n            c -= 1\\n        ans += c\\n    else:\\n        counts[x] -= 1\\n        if counts[x] == 0:\\n            c -= 1\\nprint(ans)\", \"\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = tuple(map(int, input().split()))\\n\\tseen = set()\\n\\tcount = 0\\n\\tdistinct = [0]\\n\\tfor x in reversed(a):\\n\\t\\tif x in seen:\\n\\t\\t\\tdistinct.append(distinct[-1])\\n\\t\\t\\tcontinue\\n\\t\\tseen.add(x)\\n\\t\\tdistinct.append(distinct[-1]+1)\\n\\tdistinct.pop()\\n\\tseen.clear()\\n\\t#print(tuple(reversed(distinct)))\\n\\tfor x, distinct_right in zip(a, reversed(distinct)):\\n\\t\\t#print(x, distinct_right)\\n\\t\\tif x in seen:\\n\\t\\t\\tcontinue\\n\\t\\tseen.add(x)\\n\\t\\tcount += distinct_right\\n\\n\\tprint(count)\\nmain()\", \"n = int(input())\\nA = list(map(int, input().split()))\\nleft = [0 for _ in range(10**5 + 1)]\\nright = [0 for _ in range(10**5 + 1)]\\nr_non0 = 0\\nfor a in A:\\n    if right[a] == 0:\\n        r_non0 += 1\\n    right[a] += 1\\nans = 0\\nfor i in range(n):\\n    left[A[i]] += 1\\n    right[A[i]] -= 1\\n    if right[A[i]] == 0:\\n        r_non0 -= 1\\n    if left[A[i]] == 1:\\n        ans += r_non0\\nprint(ans)\", \"n = int(input())\\npositions = input().split()\\ns1 = set()\\nl1 = [1] * (n - 1)\\ns2 = set()\\nl2 = []\\ncount = 0\\nfor i in range(n - 1):\\n    if positions[i] in s1:l1[i] = 0\\n    s1.add(positions[i])\\nfor i in range(n - 1):\\n    s2.add(positions[-1 - i])\\n    l2.append(len(s2))\\nfor i in range(n - 1):\\n    count+=l1[i] * l2[-1 - i]\\nprint(count)\", \"from collections import defaultdict\\n\\nn = int(input())\\na = [int(i) for i in input().split()]\\n\\ndone = set()\\nd = defaultdict(int)\\n\\nfor i in a:\\n    d[i] += 1\\n\\nc = len(list(d.keys()))\\ntotal = 0\\nfor i in (a):\\n    d[i] -= 1\\n    if d[i] == 0:\\n        c -= 1\\n\\n    if i not in done:\\n        total += c\\n        done.add(i)\\n\\n\\nprint(total)\\n\\n\\n\", \"n = int(input())\\na = input().split(\\\" \\\")\\nfor i in range(n):\\n    a[i] = int(a[i])\\nlu = {}\\nfor i in range(n):\\n    lu[a[i]] = []\\nfor i in range(n):\\n    lu[a[i]].append(i)\\nmins = []\\nmaxes = []\\nfor val in lu.values():\\n    mins.append(min(val))\\n    maxes.append(max(val))\\nkey_num = len(lu.keys())\\nmins.sort()\\nmaxes.sort()\\n# print(mins)\\n# print(maxes)\\nind = 0\\npairs = 0\\ncounter = key_num\\nfor i in range(len(mins)):\\n    while maxes[ind] <= mins[i]:\\n        if ind == len(maxes) - 1:\\n            counter = 0\\n            break\\n        else:\\n            ind += 1\\n            counter -= 1\\n    pairs += counter\\n    # print(counter)\\nprint(pairs)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmaxl=max(l)+1\\ndp=[]\\nfor i in range(maxl):\\n    dp.append([-1,-1])\\nfor i in range(n):\\n    dp[l[i]][1]=i\\nfor i in range(n-1,-1,-1):\\n    dp[l[i]][0]=i\\nll=[]\\nlr=[]\\nfor i in range(n):\\n    ll.append(0)\\n    lr.append(0)\\ncnt = 0\\nfor i in range(maxl):\\n    if(dp[i][0]!=-1):\\n        ll[dp[i][0]]=1\\n        lr[dp[i][1]]=1\\n        cnt+=1\\nans = 0\\n\\nfor i in range(n):\\n    if(lr[i]==1):\\n        cnt-=1\\n    if(ll[i]==1):\\n        ans+=cnt\\nprint(ans)\", \"n = int(input())\\nA = list(map(int, input().split()))\\nres_set = set()\\ntmp_set = set()\\nNumList = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    tmp_set.add(A[i])\\n    NumList[i] = len(tmp_set)\\nans = 0\\nfor i in range(n - 1):\\n    if not (A[i] in res_set):\\n        res_set.add(A[i])\\n        ans += NumList[i + 1]\\n#print(NumList)\\n#print(res_set)\\nprint(ans)\\n\", \"n=int(input())\\ns=list(map(int,input().split()))\\ndist=[]\\np=[0 for i in range(100005)]\\ndiff=0\\nfor i in range(n-1,-1,-1):\\n    if p[s[i]]==0:\\n        p[s[i]]=1\\n        diff+=1\\n    else:\\n        p[s[i]]+=1\\n    dist+=[diff]\\nvis=[0 for i in range(100005)]\\nans=0\\nfor i in range(n-1):\\n    if vis[s[i]]==0:\\n        ans+=dist[n-i-2]\\n        vis[s[i]]=1\\nprint(ans)\", \"n=int(input())\\nnums = list(map(int, input().split()))\\nleft = {}\\n\\nfor i in range(n):\\n    if nums[i] in list(left.keys()):\\n        left[nums[i]] += 1\\n    else:\\n        left[nums[i]] = 1\\n\\ncount = 0\\ndone = set()\\nfor i in nums:\\n    left[i] -= 1\\n    if left[i] == 0:\\n        del left[i]\\n    if i not in done:\\n        count += len(list(left.keys()))\\n        done.add(i)\\n\\nprint(count)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor i in range(n):\\n    if d.get(a[i]) == None:\\n        d[a[i]] = 1\\n    else:\\n        d[a[i]] += 1\\ncount = 0\\nused = set()\\nfor i in range(n):\\n    d[a[i]] -= 1\\n    if d[a[i]] == 0:\\n        del d[a[i]]\\n    if a[i] not in used:\\n        count += len(d)\\n    used.add(a[i])\\nprint(count)\\n\"]",
        "difficulty": "interview",
        "input": "7\n1 2 1 1 1 3 2\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1004/C"
    },
    {
        "id": 1959,
        "task_id": 2249,
        "test_case_id": 3,
        "question": "Since Sonya is interested in robotics too, she decided to construct robots that will read and recognize numbers.\n\nSonya has drawn $n$ numbers in a row, $a_i$ is located in the $i$-th position. She also has put a robot at each end of the row (to the left of the first number and to the right of the last number). Sonya will give a number to each robot (they can be either same or different) and run them. When a robot is running, it is moving toward to another robot, reading numbers in the row. When a robot is reading a number that is equal to the number that was given to that robot, it will turn off and stay in the same position.\n\nSonya does not want robots to break, so she will give such numbers that robots will stop before they meet. That is, the girl wants them to stop at different positions so that the first robot is to the left of the second one.\n\nFor example, if the numbers $[1, 5, 4, 1, 3]$ are written, and Sonya gives the number $1$ to the first robot and the number $4$ to the second one, the first robot will stop in the $1$-st position while the second one in the $3$-rd position. In that case, robots will not meet each other. As a result, robots will not be broken. But if Sonya gives the number $4$ to the first robot and the number $5$ to the second one, they will meet since the first robot will stop in the $3$-rd position while the second one is in the $2$-nd position.\n\nSonya understands that it does not make sense to give a number that is not written in the row because a robot will not find this number and will meet the other robot.\n\nSonya is now interested in finding the number of different pairs that she can give to robots so that they will not meet. In other words, she wants to know the number of pairs ($p$, $q$), where she will give $p$ to the first robot and $q$ to the second one. Pairs ($p_i$, $q_i$) and ($p_j$, $q_j$) are different if $p_i\\neq p_j$ or $q_i\\neq q_j$.\n\nUnfortunately, Sonya is busy fixing robots that broke after a failed launch. That is why she is asking you to find the number of pairs that she can give to robots so that they will not meet.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1\\leq n\\leq 10^5$) — the number of numbers in a row.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1\\leq a_i\\leq 10^5$) — the numbers in a row.\n\n\n-----Output-----\n\nPrint one number — the number of possible pairs that Sonya can give to robots so that they will not meet.\n\n\n-----Examples-----\nInput\n5\n1 5 4 1 3\n\nOutput\n9\n\nInput\n7\n1 2 1 1 1 3 2\n\nOutput\n7\n\n\n\n-----Note-----\n\nIn the first example, Sonya can give pairs ($1$, $1$), ($1$, $3$), ($1$, $4$), ($1$, $5$), ($4$, $1$), ($4$, $3$), ($5$, $1$), ($5$, $3$), and ($5$, $4$).\n\nIn the second example, Sonya can give pairs ($1$, $1$), ($1$, $2$), ($1$, $3$), ($2$, $1$), ($2$, $2$), ($2$, $3$), and ($3$, $2$).",
        "solutions": "[\"def ii():\\n    return int(input())\\ndef mi():\\n    return map(int, input().split())\\ndef li():\\n    return list(mi())\\n\\nn = ii()\\na = li()\\nans = 0\\ncnt = [0] * (10 ** 5 + 10)\\ncur = set()\\nfor ai in a:\\n    cnt[ai] = len(cur)\\n    cur.add(ai)\\nans = sum(cnt)\\nprint(ans)\", \"def main():\\n    #string     input()\\n    #strList    input().split()\\n    n = int(input())\\n    #integers   map(int, input().split())\\n    a = list(map(int, input().split()))\\n    uniques = [0] * (n - 1) + [1]\\n    bools = [True] * 100001\\n    bools2 = [True] * 100001\\n    bools[a[-1]] = False\\n    for i in range(n - 2, 0, -1):\\n        temp = 0\\n        if bools[a[i]]:\\n            bools[a[i]] = False\\n            temp = 1\\n        uniques[i] = uniques[i + 1] + temp\\n    ret = 0\\n    for i in range(n - 1):\\n        if bools2[a[i]]:\\n            bools2[a[i]] = False\\n            ret += uniques[i + 1]\\n    print(ret)\\n    return 0\\nmain()\\n\", \"n = int(input())\\na = [int(x) for x in input().strip().split()]\\n\\nf = dict()\\nb = dict()\\nfor i in range(len(a)):\\n    if a[i] not in f:\\n        f[a[i]] = i\\n    if a[n-1-i] not in b:\\n        b[a[n-1-i]] = n-1-i\\n\\nf = sorted([v, k] for k, v in list(f.items()))\\nb = sorted([v, k] for k, v in list(b.items()))\\n\\nans = 0\\nbi = 0\\nfor i, v in f:\\n    while bi < len(b) and i >= b[bi][0]:\\n        bi += 1\\n    ans += len(b) - bi\\n\\nprint(ans)\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\n\\nMAX_NUM = 100010\\nmet_forw = [False] * MAX_NUM\\nmet_backw = [False] * MAX_NUM\\nunique_n_backw = [0] * n\\n\\nfor i in range(n - 1, -1, -1):\\n    if i < n - 1:\\n        unique_n_backw[i] = unique_n_backw[i + 1]\\n    if not met_backw[a[i]]:\\n        met_backw[a[i]] = True\\n        unique_n_backw[i] += 1\\n\\nanswer = 0\\nfor i in range(n - 1):\\n    if not met_forw[a[i]]:\\n        met_forw[a[i]] = True\\n        answer += unique_n_backw[i + 1]\\n\\nprint(answer)\\n\", \"n = int(input())\\nl = [int(el) for el in input().split()]\\ncol = 0\\na = [0] * 100001\\ns = set()\\nfor i in range(n):\\n    if a[l[i]] == 0:\\n        col += len(s)\\n        a[l[i]] += len(s)\\n        s.add(l[i])\\n    else:\\n        col += len(s) - a[l[i]]\\n        a[l[i]] = len(s)\\n        s.add(l[i])\\nprint(col)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nb=set()\\nc=[]\\ns=0\\nfor i in a:\\n\\tif not i in b:\\n\\t\\ts+=1\\n\\t\\tb.add(i)\\n\\tc.append(s)\\nb=set()\\nans=0\\nfor i in range(n-1,0,-1):\\n\\tif not a[i] in b:\\n\\t\\tans+=c[i-1]\\n\\t\\tb.add(a[i])\\nprint(ans)\", \"import sys\\nimport os\\n\\ndef extract(a):\\n    d = dict()\\n    r = []\\n    for e in a:\\n        if not e in d:\\n            r.append(1)\\n            d[e] = d\\n        else:\\n            r.append(0)\\n\\n    return r\\n\\ndef sonyaAndRobots(n, a):\\n    t1 = extract(a)\\n    t2 = list(reversed(extract(reversed(a))))\\n\\n    for i in range(n - 1):\\n        t1[i + 1] += t1[i]\\n\\n    result = 0\\n    for i in range(n - 1):\\n        result += t1[i] * t2[i + 1]\\n\\n    return result\\n\\ndef main():\\n    n = int(input())\\n    a = [int(x) for x in input().split()]\\n    print(sonyaAndRobots(n, a))\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nright = list()\\ns = set()\\n\\nfor el in a[::-1]:\\n    s.add(el)\\n    right.append(len(s))\\n\\nright = right[::-1]\\n\\ns = set()\\nans = 0\\n\\nfor i, el in enumerate(a[:-1]):\\n    if el not in s:\\n        ans += right[i + 1]\\n\\n    s.add(el)\\n\\nprint(ans)\\n\", \"n=int(input())\\narr=list(map(int,input().split()))\\ndic={}\\ndic2={}\\nansar=[]\\nfor i in range(n):\\n\\tdic[arr[i]]=0\\n\\tdic2[arr[i]]=0\\n\\tansar.append(0)\\ncount=0\\nfor i in range(n-1,0,-1):\\n\\tif dic[arr[i]]==0:\\n\\t\\tcount+=1\\n\\t\\t\\n\\t\\tdic[arr[i]]=1\\n\\tansar[i-1]=count\\t\\n#print(ansar)\\nanswer=0\\nfor i in range(n-1):\\n\\tif dic2[arr[i]]==0:\\n\\t\\tanswer+=ansar[i]\\n\\t\\tdic2[arr[i]]=1\\nprint(answer)\\t\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\ndic = {}\\nfor i in range(len(a) - 1):\\n    if a[i] not in dic:\\n        dic[a[i]] = 1\\n    else:\\n        dic[a[i]] += 1\\n\\nbeen = set([])\\ncnt = 0\\nfor i in range(len(a) - 1, 0, -1):\\n    if a[i] not in been:\\n        cnt += len(dic)\\n        been.add(a[i])\\n    dic[a[i - 1]] -= 1\\n    if (dic[a[i - 1]] == 0):\\n        del dic[a[i - 1]]\\nprint(cnt)\\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nb=a[:]\\ns=set()\\nfor i in range(n):\\n    if(a[i] in s):\\n        a[i]=0\\n    else:\\n        s.add(a[i])\\ns=set()\\nc=[0]*n\\nc[n-1]=1\\nfor i in range(n-1,-1,-1):\\n    if(b[i] in s):\\n        b[i]=0\\n        c[i]=c[i+1]\\n    else:\\n        s.add(b[i])\\n        if(i<n-1):\\n            c[i]=c[i+1]+1\\nans=0\\nfor i in range(n-1):\\n    if(a[i]):\\n        ans+=c[i+1]\\nprint(ans)\", \"n = int(input())\\na = [int(x) for x in input().split()]\\ns = set()\\nd = dict()\\nc = [0] * n\\nfor i in range(n-1, -1, -1):\\n    c[i] = len(s)\\n    s.add(a[i])\\n    d[a[i]] = i\\nans = 0\\nfor k in list(d.keys()):\\n    pos = d[k]\\n    ans += c[pos]\\nprint(ans)\\n\\n\", \"from collections import defaultdict\\nn = int(input())\\narr = list(map(int,input().split()))\\nlist1 = [False]*(10**5+1)\\nd = defaultdict(int)\\ncount = 0 \\nfor i in range(n):\\n\\td[arr[i]] += 1\\nfor i in range(n-1):\\n\\td[arr[i]] -= 1\\n\\tif(d[arr[i]] == 0):\\n\\t\\tdel(d[arr[i]])\\n\\tif list1[arr[i]] == False:\\n\\t\\tcount += len(list(d.items()))\\n\\t\\tlist1[arr[i]] = True\\n\\n\\nprint(count)\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\n\\na = list(map(int, input().split()))\\n\\ncounts = defaultdict(int)\\n\\nfor x in a:\\n    counts[x] += 1\\n\\nkeys = set()\\nc = len(counts)\\nans = 0\\n\\nfor x in a[:-1]:\\n    if x not in keys:\\n        keys.add(x)\\n        counts[x] -= 1\\n        if counts[x] == 0:\\n            c -= 1\\n        ans += c\\n    else:\\n        counts[x] -= 1\\n        if counts[x] == 0:\\n            c -= 1\\nprint(ans)\", \"\\n\\ndef main():\\n\\tn = int(input())\\n\\ta = tuple(map(int, input().split()))\\n\\tseen = set()\\n\\tcount = 0\\n\\tdistinct = [0]\\n\\tfor x in reversed(a):\\n\\t\\tif x in seen:\\n\\t\\t\\tdistinct.append(distinct[-1])\\n\\t\\t\\tcontinue\\n\\t\\tseen.add(x)\\n\\t\\tdistinct.append(distinct[-1]+1)\\n\\tdistinct.pop()\\n\\tseen.clear()\\n\\t#print(tuple(reversed(distinct)))\\n\\tfor x, distinct_right in zip(a, reversed(distinct)):\\n\\t\\t#print(x, distinct_right)\\n\\t\\tif x in seen:\\n\\t\\t\\tcontinue\\n\\t\\tseen.add(x)\\n\\t\\tcount += distinct_right\\n\\n\\tprint(count)\\nmain()\", \"n = int(input())\\nA = list(map(int, input().split()))\\nleft = [0 for _ in range(10**5 + 1)]\\nright = [0 for _ in range(10**5 + 1)]\\nr_non0 = 0\\nfor a in A:\\n    if right[a] == 0:\\n        r_non0 += 1\\n    right[a] += 1\\nans = 0\\nfor i in range(n):\\n    left[A[i]] += 1\\n    right[A[i]] -= 1\\n    if right[A[i]] == 0:\\n        r_non0 -= 1\\n    if left[A[i]] == 1:\\n        ans += r_non0\\nprint(ans)\", \"n = int(input())\\npositions = input().split()\\ns1 = set()\\nl1 = [1] * (n - 1)\\ns2 = set()\\nl2 = []\\ncount = 0\\nfor i in range(n - 1):\\n    if positions[i] in s1:l1[i] = 0\\n    s1.add(positions[i])\\nfor i in range(n - 1):\\n    s2.add(positions[-1 - i])\\n    l2.append(len(s2))\\nfor i in range(n - 1):\\n    count+=l1[i] * l2[-1 - i]\\nprint(count)\", \"from collections import defaultdict\\n\\nn = int(input())\\na = [int(i) for i in input().split()]\\n\\ndone = set()\\nd = defaultdict(int)\\n\\nfor i in a:\\n    d[i] += 1\\n\\nc = len(list(d.keys()))\\ntotal = 0\\nfor i in (a):\\n    d[i] -= 1\\n    if d[i] == 0:\\n        c -= 1\\n\\n    if i not in done:\\n        total += c\\n        done.add(i)\\n\\n\\nprint(total)\\n\\n\\n\", \"n = int(input())\\na = input().split(\\\" \\\")\\nfor i in range(n):\\n    a[i] = int(a[i])\\nlu = {}\\nfor i in range(n):\\n    lu[a[i]] = []\\nfor i in range(n):\\n    lu[a[i]].append(i)\\nmins = []\\nmaxes = []\\nfor val in lu.values():\\n    mins.append(min(val))\\n    maxes.append(max(val))\\nkey_num = len(lu.keys())\\nmins.sort()\\nmaxes.sort()\\n# print(mins)\\n# print(maxes)\\nind = 0\\npairs = 0\\ncounter = key_num\\nfor i in range(len(mins)):\\n    while maxes[ind] <= mins[i]:\\n        if ind == len(maxes) - 1:\\n            counter = 0\\n            break\\n        else:\\n            ind += 1\\n            counter -= 1\\n    pairs += counter\\n    # print(counter)\\nprint(pairs)\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmaxl=max(l)+1\\ndp=[]\\nfor i in range(maxl):\\n    dp.append([-1,-1])\\nfor i in range(n):\\n    dp[l[i]][1]=i\\nfor i in range(n-1,-1,-1):\\n    dp[l[i]][0]=i\\nll=[]\\nlr=[]\\nfor i in range(n):\\n    ll.append(0)\\n    lr.append(0)\\ncnt = 0\\nfor i in range(maxl):\\n    if(dp[i][0]!=-1):\\n        ll[dp[i][0]]=1\\n        lr[dp[i][1]]=1\\n        cnt+=1\\nans = 0\\n\\nfor i in range(n):\\n    if(lr[i]==1):\\n        cnt-=1\\n    if(ll[i]==1):\\n        ans+=cnt\\nprint(ans)\", \"n = int(input())\\nA = list(map(int, input().split()))\\nres_set = set()\\ntmp_set = set()\\nNumList = [0 for i in range(n)]\\nfor i in range(n - 1, -1, -1):\\n    tmp_set.add(A[i])\\n    NumList[i] = len(tmp_set)\\nans = 0\\nfor i in range(n - 1):\\n    if not (A[i] in res_set):\\n        res_set.add(A[i])\\n        ans += NumList[i + 1]\\n#print(NumList)\\n#print(res_set)\\nprint(ans)\\n\", \"n=int(input())\\ns=list(map(int,input().split()))\\ndist=[]\\np=[0 for i in range(100005)]\\ndiff=0\\nfor i in range(n-1,-1,-1):\\n    if p[s[i]]==0:\\n        p[s[i]]=1\\n        diff+=1\\n    else:\\n        p[s[i]]+=1\\n    dist+=[diff]\\nvis=[0 for i in range(100005)]\\nans=0\\nfor i in range(n-1):\\n    if vis[s[i]]==0:\\n        ans+=dist[n-i-2]\\n        vis[s[i]]=1\\nprint(ans)\", \"n=int(input())\\nnums = list(map(int, input().split()))\\nleft = {}\\n\\nfor i in range(n):\\n    if nums[i] in list(left.keys()):\\n        left[nums[i]] += 1\\n    else:\\n        left[nums[i]] = 1\\n\\ncount = 0\\ndone = set()\\nfor i in nums:\\n    left[i] -= 1\\n    if left[i] == 0:\\n        del left[i]\\n    if i not in done:\\n        count += len(list(left.keys()))\\n        done.add(i)\\n\\nprint(count)\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nd = {}\\nfor i in range(n):\\n    if d.get(a[i]) == None:\\n        d[a[i]] = 1\\n    else:\\n        d[a[i]] += 1\\ncount = 0\\nused = set()\\nfor i in range(n):\\n    d[a[i]] -= 1\\n    if d[a[i]] == 0:\\n        del d[a[i]]\\n    if a[i] not in used:\\n        count += len(d)\\n    used.add(a[i])\\nprint(count)\\n\"]",
        "difficulty": "interview",
        "input": "10\n2 2 4 4 3 1 1 2 3 2\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1004/C"
    },
    {
        "id": 1960,
        "task_id": 2321,
        "test_case_id": 2,
        "question": "You have a string $s$ of length $n$ consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character <, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).\n\nFor example, if we choose character > in string > > < >, the string will become to > > >. And if we choose character < in string > <, the string will become to <.\n\nThe string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings >, > > are good. \n\nBefore applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $n - 1$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $s$ so that it becomes good.\n\n\n-----Input-----\n\nThe first line contains one integer $t$ ($1 \\le t \\le 100$) – the number of test cases. Each test case is represented by two lines.\n\nThe first line of $i$-th test case contains one integer $n$ ($1 \\le n \\le 100$) – the length of string $s$.\n\nThe second line of $i$-th test case contains string $s$, consisting of only characters > and <.\n\n\n-----Output-----\n\nFor each test case print one line.\n\nFor $i$-th test case print the minimum number of characters to be deleted from string $s$ so that it becomes good.\n\n\n-----Example-----\nInput\n3\n2\n<>\n3\n><<\n1\n>\n\nOutput\n1\n0\n0\n\n\n\n-----Note-----\n\nIn the first test case we can delete any character in string <>.\n\nIn the second test case we don't need to delete any characters. The string > < < is good, because we can perform the following sequence of operations: > < < $\\rightarrow$ < < $\\rightarrow$ <.",
        "solutions": "[\"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\nT_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    s = input()\\n    r = 0\\n    for i in range(N):\\n        if s[i] =='>':\\n            r = i\\n            break\\n    r1 = 0\\n    for i in range(N-1, -1, -1):\\n        if s[i]=='<':\\n            r1 = N-1-i\\n            break\\n    print(min(r,r1))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nfor _ in range(ii()):\\n    n = ii()\\n    s = input().strip()\\n    c1 = c2 = 0\\n    for c in s:\\n        if c == '<':\\n            c1 += 1\\n        else:\\n            break\\n    for c in s[::-1]:\\n        if c == '>':\\n            c2 += 1\\n        else:\\n            break\\n    print(min(c1, c2))\", \"t = int(input())\\nfor _ in range(t):\\n    input()\\n    s = input()\\n    pref_len = 0\\n    for c in s:\\n        if c != '<':\\n            break\\n        pref_len += 1\\n    suf_len = 0\\n    for c in reversed(s):\\n        if c != '>':\\n            break\\n        suf_len += 1\\n    print(min(suf_len, pref_len))\\n\", \"t = int(input())\\nfor i in range(t):\\n    n = int(input())\\n    s = input()\\n    a, b = 999999999, 9999999999\\n    if '>' in s:\\n        a = s.index('>')\\n    if '<' in s:\\n        b = n - 1 - s.rindex('<')\\n    print(min(a, b))\\n\", \"for i in range(int(input())):\\n    x = int(input())\\n    y = input()\\n    print(min(y.index(\\\">\\\")if \\\">\\\"in y else 10000000, y[::-1].index(\\\"<\\\") if \\\"<\\\" in y else 100000000))\", \"t = int(input())\\nfor i in range(t):\\n    n = int(input())\\n    s = input()\\n    num = s.find(\\\">\\\")\\n    num2 = s.rfind(\\\"<\\\")\\n    if num == -1 or num2 == -1:\\n        print(0)\\n    else:\\n        print(min(num,n - 1 - num2))\\n\", \"t=int(input())\\nfor _ in range(t):\\n         n=int(input())\\n         s=input()\\n         ans1=n\\n         ans2=n\\n         for i in range(n):\\n                  if(s[i]=='>'):\\n                           ans1=i\\n                           break\\n         for i in range(n):\\n                  if(s[i]=='<'):\\n                           ans2=n-i-1\\n         print(min(ans1,ans2))\", \"Q = int(input())\\n\\nfor _ in range(Q):\\n    N = int(input())\\n    s = input()\\n    mi = N - 1\\n    for i in range(N):\\n        if s[i] == \\\">\\\":\\n            mi = i\\n            break\\n    for i in range(N):\\n        if s[N-1-i] == \\\"<\\\":\\n            mi = min(mi, i)\\n            break\\n\\n    print(mi)\\n\", \"# stdin=open('input.txt')\\n\\n# def input():\\n# \\treturn stdin.readline()[:-1]\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nfor t in range(int(input())):\\n\\tn = int(input())\\n\\ta = input()\\n\\n\\tcount1 = 0\\n\\tcount2 = 0\\n\\tfor i in a:\\n\\t\\tif i == '<':\\n\\t\\t\\tcount1 += 1\\n\\t\\telse:\\n\\t\\t\\tbreak\\n\\n\\ta = a[::-1]\\n\\n\\tfor i in a:\\n\\t\\tif i == '>':\\n\\t\\t\\tcount2 += 1\\n\\t\\telse:\\n\\t\\t\\tbreak\\n\\n\\tprint(min(count1, count2))\\n\\n#CODE ENDS HERE....................\\n\\n\\n\", \"rs = lambda : int(input())\\nri = lambda : map(int, input().split())\\nrli = lambda : list(map(int, input().split()))\\n\\nn = int(input())\\nfor i in range(n):\\n    k = int(input())\\n    s = input()\\n    ans = k-1\\n    ans1 = 0\\n    while ans1 < k and s[ans1] == '<':\\n        ans1+=1\\n    ans2 = 0\\n    while k-1-ans2 >= 0 and s[k-1-ans2] == '>':\\n        ans2+=1\\n    ans = min([ans, ans2, ans1])\\n    print(ans)\", \"for _ in range(int(input())):\\n    n = int(input())\\n    s = input()\\n    k = 0\\n    for i in range(n-1,-1,-1):\\n        if s[i] is '<':\\n            k = n-1-i\\n            break\\n    \\n    for i in range(n):\\n        if s[i] is '>':\\n            k = min(k,i)\\n            break\\n    print(k)\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\n\\n\\n\\nn=nn()\\n\\nfor i in range(n):\\n\\tl=nn()\\n\\n\\ts=li()\\n\\n\\tleftmin=0\\n\\trightmin=0\\n\\n\\t\\n\\t\\n\\twhile leftmin<len(s) and s[leftmin]=='<':\\n\\t\\tleftmin+=1\\n\\n\\twhile rightmin<len(s) and s[~rightmin]=='>':\\n\\t\\trightmin+=1\\n\\n\\tprint(min(leftmin,rightmin))\\n\\n\\n\", \"for _ in range(int(input())):\\n    n = int(input())\\n    s = input()\\n    ans = 0\\n    \\n    for i in range(n):\\n        if s[i] is '>':\\n            ans = i\\n            break\\n    \\n    \\n    \\n    for i in range(n-1,-1,-1):\\n        if s[i] is '<':\\n            ans = min(n-1-i,ans)\\n            break\\n    \\n    print(ans)\", \"t = int(input())\\nfor _ in range(t):\\n    input()\\n    s = input()\\n    cl = 0\\n    for c in s:\\n        if c == '>':\\n            break\\n        cl += 1\\n    cr = 0\\n    for c in s[::-1]:\\n        if c == '<':\\n            break\\n        cr += 1\\n    print(min(cl,cr))\\n\", \"t = int(input())\\n\\nfor _ in range(t):\\n    n = int(input())\\n    s = input()\\n    if \\\">\\\" in s:\\n        left = s.index(\\\">\\\")\\n    else:\\n        left = n+1\\n    if \\\"<\\\" in s:\\n        right = s[::-1].index(\\\"<\\\")\\n    else:\\n        right = n+1\\n    print (min(left,right))\", \"t = int(input())\\n\\nfor test in range(0,t):\\n\\n    n = int(input())\\n    s = input()\\n\\n    prefix_len=0\\n    suffix_len=0\\n\\n    for i in range(0,n):\\n\\n        ##print(i)\\n\\n        if s[i]=='<':\\n            prefix_len+=1\\n\\n        else:\\n            break\\n\\n    for i in range(n-1,-1,-1):\\n\\n        ##print(i)\\n\\n        if s[i]=='>':\\n            suffix_len+=1\\n\\n        else:\\n            break\\n\\n    print(min(suffix_len,prefix_len))\\n\", \"t = int(input())\\nfor i in range(t):\\n    n =int(input())\\n    s=input()\\n    if s[0] == '>' or s[-1]=='<':\\n        print(0)\\n    else:\\n        q=0\\n        w=0\\n        for j in s:\\n            if j=='<':\\n                q+=1\\n            else:\\n                break\\n        for j in range(len(s)-1, -1, -1):\\n            if s[j]=='>':\\n                w+=1\\n            else:\\n                break\\n        print(min(q, w))\\n\", \"t=int(input())\\nwhile t:\\n\\tt-=1\\n\\tn=int(input())\\n\\ts=input()\\n\\tl=0\\n\\twhile l<n and s[l]!='>':\\n\\t\\tl+=1\\n\\tr=n-1\\n\\twhile r>=0 and s[r]!='<':\\n\\t\\tr-=1\\n\\tprint(min(min(l,n-1-r),n-1))\", \"for t in range(int(input())):\\n\\tn = int(input())\\n\\two = input().strip()\\n\\tii, jj = 0, 0\\n\\ti, j = 0, n-1\\n\\twhile i < n and wo[i] == '<':\\n\\t\\tii += 1\\n\\t\\ti += 1\\n\\twhile j >= 0 and wo[j] == '>':\\n\\t\\tj-=1\\n\\t\\tjj += 1\\n\\tprint(min(ii, jj))\\n\", \"def solve():\\n    n=int(input())\\n    s=input()\\n    if s.count('<')==0:\\n        return 0\\n    if s.count('>')==0:\\n        return 0\\n    if s[0] == '>':\\n        return 0\\n    if s[-1] == '<':\\n        return 0\\n    s1=0\\n    s2=0\\n    for i in range(n):\\n        if s[i]=='<':\\n            s1+=1\\n        else:\\n            break\\n    for i in range(n-1,-1,-1):\\n        if s[i]=='>':\\n            s2+=1\\n        else:\\n            break\\n    return min(s1,s2)\\n\\nt=int(input())\\nfor i in range(t):\\n    print(solve())\\n\", \"from collections import defaultdict\\nfrom functools import reduce\\n\\nmi = lambda: [int(i) for i in input().split()]\\nflat = lambda l: reduce(lambda a, b: a + b, l)\\n\\nt = mi()[0]\\n\\nfor _ in range(t):\\n    n = mi()[0]\\n    s = input()\\n\\n    # print(min(s.find('>'), (len(s) - s.rfind('<') - 1)))\\n    print(min(len(s) - len(s.lstrip('<')), len(s) - len(s.rstrip('>'))))\\n\", \"n = int(input())\\nfor i in range(n):\\n    m = int(input())\\n    s = input()\\n    num1 = 0\\n    num2 = 0\\n    j1 = 0\\n    j2 = m - 1\\n    while j1 < m and s[j1] == '<':\\n        num1 += 1\\n        j1 += 1\\n    while j2 >= 0 and s[j2] == '>':\\n        num2 += 1\\n        j2 -= 1\\n    print(min(num1, num2))\", \"for _ in range(int(input())):\\n    n=int(input())\\n    s=list(input())\\n    x,y=-1,-1\\n    for i in range(n):\\n        if s[i]=='>':\\n            x=i\\n            break\\n    for i in range(n-1,-1,-1):\\n        if s[i]=='<':\\n            y=n-1-i\\n            break\\n    if x==-1 or y==-1:\\n        print(0)\\n    else:\\n        print(min(x,y))\"]",
        "difficulty": "interview",
        "input": "13\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n",
        "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1140/B"
    },
    {
        "id": 1961,
        "task_id": 2321,
        "test_case_id": 3,
        "question": "You have a string $s$ of length $n$ consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character <, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).\n\nFor example, if we choose character > in string > > < >, the string will become to > > >. And if we choose character < in string > <, the string will become to <.\n\nThe string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings >, > > are good. \n\nBefore applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $n - 1$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $s$ so that it becomes good.\n\n\n-----Input-----\n\nThe first line contains one integer $t$ ($1 \\le t \\le 100$) – the number of test cases. Each test case is represented by two lines.\n\nThe first line of $i$-th test case contains one integer $n$ ($1 \\le n \\le 100$) – the length of string $s$.\n\nThe second line of $i$-th test case contains string $s$, consisting of only characters > and <.\n\n\n-----Output-----\n\nFor each test case print one line.\n\nFor $i$-th test case print the minimum number of characters to be deleted from string $s$ so that it becomes good.\n\n\n-----Example-----\nInput\n3\n2\n<>\n3\n><<\n1\n>\n\nOutput\n1\n0\n0\n\n\n\n-----Note-----\n\nIn the first test case we can delete any character in string <>.\n\nIn the second test case we don't need to delete any characters. The string > < < is good, because we can perform the following sequence of operations: > < < $\\rightarrow$ < < $\\rightarrow$ <.",
        "solutions": "[\"#      \\nimport collections, atexit, math, sys, bisect \\n\\nsys.setrecursionlimit(1000000)\\n\\nisdebug = False\\ntry :\\n    #raise ModuleNotFoundError\\n    import pylint\\n    import numpy\\n    def dprint(*args, **kwargs):\\n        #print(*args, **kwargs, file=sys.stderr)\\n        # in python 3.4 **kwargs is invalid???\\n        print(*args,  file=sys.stderr)\\n    dprint('debug mode')\\n    isdebug = True\\nexcept Exception:\\n    def dprint(*args, **kwargs):\\n        pass\\n\\n\\ndef red_inout():\\n    inId = 0\\n    outId = 0\\n    if not isdebug:\\n        inId = 0\\n        outId = 0\\n    if inId>0:\\n        dprint('use input', inId)\\n        try:\\n            f = open('input'+ str(inId) + '.txt', 'r')\\n            sys.stdin = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid input file')\\n    if outId>0:\\n        dprint('use output', outId)\\n        try:\\n            f = open('stdout'+ str(outId) + '.txt', 'w')\\n            sys.stdout = f #\\u6807\\u51c6\\u8f93\\u51fa\\u91cd\\u5b9a\\u5411\\u81f3\\u6587\\u4ef6\\n        except Exception:\\n            dprint('invalid output file')\\n            \\n        atexit.register(lambda :sys.stdout.close())     #idle \\u4e2d\\u4e0d\\u4f1a\\u6267\\u884c atexit\\n\\nif isdebug and len(sys.argv) == 1:\\n    red_inout()\\n\\ndef getIntList():\\n    return list(map(int, input().split()))            \\n\\ndef solve(): \\n    pass\\n    \\nT_ = 1    \\nT_, = getIntList()\\n\\nfor iii_ in range(T_):\\n    #solve()\\n    N,  = getIntList()\\n    #print(N)\\n    s = input()\\n    r = 0\\n    for i in range(N):\\n        if s[i] =='>':\\n            r = i\\n            break\\n    r1 = 0\\n    for i in range(N-1, -1, -1):\\n        if s[i]=='<':\\n            r1 = N-1-i\\n            break\\n    print(min(r,r1))\\n\", \"ii = lambda: int(input())\\nmi = lambda: map(int, input().split())\\nli = lambda: list(mi())\\n\\nfor _ in range(ii()):\\n    n = ii()\\n    s = input().strip()\\n    c1 = c2 = 0\\n    for c in s:\\n        if c == '<':\\n            c1 += 1\\n        else:\\n            break\\n    for c in s[::-1]:\\n        if c == '>':\\n            c2 += 1\\n        else:\\n            break\\n    print(min(c1, c2))\", \"t = int(input())\\nfor _ in range(t):\\n    input()\\n    s = input()\\n    pref_len = 0\\n    for c in s:\\n        if c != '<':\\n            break\\n        pref_len += 1\\n    suf_len = 0\\n    for c in reversed(s):\\n        if c != '>':\\n            break\\n        suf_len += 1\\n    print(min(suf_len, pref_len))\\n\", \"t = int(input())\\nfor i in range(t):\\n    n = int(input())\\n    s = input()\\n    a, b = 999999999, 9999999999\\n    if '>' in s:\\n        a = s.index('>')\\n    if '<' in s:\\n        b = n - 1 - s.rindex('<')\\n    print(min(a, b))\\n\", \"for i in range(int(input())):\\n    x = int(input())\\n    y = input()\\n    print(min(y.index(\\\">\\\")if \\\">\\\"in y else 10000000, y[::-1].index(\\\"<\\\") if \\\"<\\\" in y else 100000000))\", \"t = int(input())\\nfor i in range(t):\\n    n = int(input())\\n    s = input()\\n    num = s.find(\\\">\\\")\\n    num2 = s.rfind(\\\"<\\\")\\n    if num == -1 or num2 == -1:\\n        print(0)\\n    else:\\n        print(min(num,n - 1 - num2))\\n\", \"t=int(input())\\nfor _ in range(t):\\n         n=int(input())\\n         s=input()\\n         ans1=n\\n         ans2=n\\n         for i in range(n):\\n                  if(s[i]=='>'):\\n                           ans1=i\\n                           break\\n         for i in range(n):\\n                  if(s[i]=='<'):\\n                           ans2=n-i-1\\n         print(min(ans1,ans2))\", \"Q = int(input())\\n\\nfor _ in range(Q):\\n    N = int(input())\\n    s = input()\\n    mi = N - 1\\n    for i in range(N):\\n        if s[i] == \\\">\\\":\\n            mi = i\\n            break\\n    for i in range(N):\\n        if s[N-1-i] == \\\"<\\\":\\n            mi = min(mi, i)\\n            break\\n\\n    print(mi)\\n\", \"# stdin=open('input.txt')\\n\\n# def input():\\n# \\treturn stdin.readline()[:-1]\\n\\n# a, b = map(int, input().split())\\n\\n# l = list(map(int, input().split()))\\n\\n\\n# CODE BEGINS HERE.................\\n\\nfor t in range(int(input())):\\n\\tn = int(input())\\n\\ta = input()\\n\\n\\tcount1 = 0\\n\\tcount2 = 0\\n\\tfor i in a:\\n\\t\\tif i == '<':\\n\\t\\t\\tcount1 += 1\\n\\t\\telse:\\n\\t\\t\\tbreak\\n\\n\\ta = a[::-1]\\n\\n\\tfor i in a:\\n\\t\\tif i == '>':\\n\\t\\t\\tcount2 += 1\\n\\t\\telse:\\n\\t\\t\\tbreak\\n\\n\\tprint(min(count1, count2))\\n\\n#CODE ENDS HERE....................\\n\\n\\n\", \"rs = lambda : int(input())\\nri = lambda : map(int, input().split())\\nrli = lambda : list(map(int, input().split()))\\n\\nn = int(input())\\nfor i in range(n):\\n    k = int(input())\\n    s = input()\\n    ans = k-1\\n    ans1 = 0\\n    while ans1 < k and s[ans1] == '<':\\n        ans1+=1\\n    ans2 = 0\\n    while k-1-ans2 >= 0 and s[k-1-ans2] == '>':\\n        ans2+=1\\n    ans = min([ans, ans2, ans1])\\n    print(ans)\", \"for _ in range(int(input())):\\n    n = int(input())\\n    s = input()\\n    k = 0\\n    for i in range(n-1,-1,-1):\\n        if s[i] is '<':\\n            k = n-1-i\\n            break\\n    \\n    for i in range(n):\\n        if s[i] is '>':\\n            k = min(k,i)\\n            break\\n    print(k)\", \"from collections import defaultdict as dd\\nimport math\\ndef nn():\\n\\treturn int(input())\\n\\ndef li():\\n\\treturn list(input())\\n\\ndef mi():\\n\\treturn list(map(int, input().split()))\\n\\ndef lm():\\n\\treturn list(map(int, input().split()))\\n\\n\\n\\n\\n\\n\\nn=nn()\\n\\nfor i in range(n):\\n\\tl=nn()\\n\\n\\ts=li()\\n\\n\\tleftmin=0\\n\\trightmin=0\\n\\n\\t\\n\\t\\n\\twhile leftmin<len(s) and s[leftmin]=='<':\\n\\t\\tleftmin+=1\\n\\n\\twhile rightmin<len(s) and s[~rightmin]=='>':\\n\\t\\trightmin+=1\\n\\n\\tprint(min(leftmin,rightmin))\\n\\n\\n\", \"for _ in range(int(input())):\\n    n = int(input())\\n    s = input()\\n    ans = 0\\n    \\n    for i in range(n):\\n        if s[i] is '>':\\n            ans = i\\n            break\\n    \\n    \\n    \\n    for i in range(n-1,-1,-1):\\n        if s[i] is '<':\\n            ans = min(n-1-i,ans)\\n            break\\n    \\n    print(ans)\", \"t = int(input())\\nfor _ in range(t):\\n    input()\\n    s = input()\\n    cl = 0\\n    for c in s:\\n        if c == '>':\\n            break\\n        cl += 1\\n    cr = 0\\n    for c in s[::-1]:\\n        if c == '<':\\n            break\\n        cr += 1\\n    print(min(cl,cr))\\n\", \"t = int(input())\\n\\nfor _ in range(t):\\n    n = int(input())\\n    s = input()\\n    if \\\">\\\" in s:\\n        left = s.index(\\\">\\\")\\n    else:\\n        left = n+1\\n    if \\\"<\\\" in s:\\n        right = s[::-1].index(\\\"<\\\")\\n    else:\\n        right = n+1\\n    print (min(left,right))\", \"t = int(input())\\n\\nfor test in range(0,t):\\n\\n    n = int(input())\\n    s = input()\\n\\n    prefix_len=0\\n    suffix_len=0\\n\\n    for i in range(0,n):\\n\\n        ##print(i)\\n\\n        if s[i]=='<':\\n            prefix_len+=1\\n\\n        else:\\n            break\\n\\n    for i in range(n-1,-1,-1):\\n\\n        ##print(i)\\n\\n        if s[i]=='>':\\n            suffix_len+=1\\n\\n        else:\\n            break\\n\\n    print(min(suffix_len,prefix_len))\\n\", \"t = int(input())\\nfor i in range(t):\\n    n =int(input())\\n    s=input()\\n    if s[0] == '>' or s[-1]=='<':\\n        print(0)\\n    else:\\n        q=0\\n        w=0\\n        for j in s:\\n            if j=='<':\\n                q+=1\\n            else:\\n                break\\n        for j in range(len(s)-1, -1, -1):\\n            if s[j]=='>':\\n                w+=1\\n            else:\\n                break\\n        print(min(q, w))\\n\", \"t=int(input())\\nwhile t:\\n\\tt-=1\\n\\tn=int(input())\\n\\ts=input()\\n\\tl=0\\n\\twhile l<n and s[l]!='>':\\n\\t\\tl+=1\\n\\tr=n-1\\n\\twhile r>=0 and s[r]!='<':\\n\\t\\tr-=1\\n\\tprint(min(min(l,n-1-r),n-1))\", \"for t in range(int(input())):\\n\\tn = int(input())\\n\\two = input().strip()\\n\\tii, jj = 0, 0\\n\\ti, j = 0, n-1\\n\\twhile i < n and wo[i] == '<':\\n\\t\\tii += 1\\n\\t\\ti += 1\\n\\twhile j >= 0 and wo[j] == '>':\\n\\t\\tj-=1\\n\\t\\tjj += 1\\n\\tprint(min(ii, jj))\\n\", \"def solve():\\n    n=int(input())\\n    s=input()\\n    if s.count('<')==0:\\n        return 0\\n    if s.count('>')==0:\\n        return 0\\n    if s[0] == '>':\\n        return 0\\n    if s[-1] == '<':\\n        return 0\\n    s1=0\\n    s2=0\\n    for i in range(n):\\n        if s[i]=='<':\\n            s1+=1\\n        else:\\n            break\\n    for i in range(n-1,-1,-1):\\n        if s[i]=='>':\\n            s2+=1\\n        else:\\n            break\\n    return min(s1,s2)\\n\\nt=int(input())\\nfor i in range(t):\\n    print(solve())\\n\", \"from collections import defaultdict\\nfrom functools import reduce\\n\\nmi = lambda: [int(i) for i in input().split()]\\nflat = lambda l: reduce(lambda a, b: a + b, l)\\n\\nt = mi()[0]\\n\\nfor _ in range(t):\\n    n = mi()[0]\\n    s = input()\\n\\n    # print(min(s.find('>'), (len(s) - s.rfind('<') - 1)))\\n    print(min(len(s) - len(s.lstrip('<')), len(s) - len(s.rstrip('>'))))\\n\", \"n = int(input())\\nfor i in range(n):\\n    m = int(input())\\n    s = input()\\n    num1 = 0\\n    num2 = 0\\n    j1 = 0\\n    j2 = m - 1\\n    while j1 < m and s[j1] == '<':\\n        num1 += 1\\n        j1 += 1\\n    while j2 >= 0 and s[j2] == '>':\\n        num2 += 1\\n        j2 -= 1\\n    print(min(num1, num2))\", \"for _ in range(int(input())):\\n    n=int(input())\\n    s=list(input())\\n    x,y=-1,-1\\n    for i in range(n):\\n        if s[i]=='>':\\n            x=i\\n            break\\n    for i in range(n-1,-1,-1):\\n        if s[i]=='<':\\n            y=n-1-i\\n            break\\n    if x==-1 or y==-1:\\n        print(0)\\n    else:\\n        print(min(x,y))\"]",
        "difficulty": "interview",
        "input": "14\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n<\n",
        "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1140/B"
    },
    {
        "id": 1962,
        "task_id": 2361,
        "test_case_id": 2,
        "question": "The game of Berland poker is played with a deck of $n$ cards, $m$ of which are jokers. $k$ players play this game ($n$ is divisible by $k$).\n\nAt the beginning of the game, each player takes $\\frac{n}{k}$ cards from the deck (so each card is taken by exactly one player). The player who has the maximum number of jokers is the winner, and he gets the number of points equal to $x - y$, where $x$ is the number of jokers in the winner's hand, and $y$ is the maximum number of jokers among all other players. If there are two or more players with maximum number of jokers, all of them are winners and they get $0$ points.\n\nHere are some examples:  $n = 8$, $m = 3$, $k = 2$. If one player gets $3$ jokers and $1$ plain card, and another player gets $0$ jokers and $4$ plain cards, then the first player is the winner and gets $3 - 0 = 3$ points;  $n = 4$, $m = 2$, $k = 4$. Two players get plain cards, and the other two players get jokers, so both of them are winners and get $0$ points;  $n = 9$, $m = 6$, $k = 3$. If the first player gets $3$ jokers, the second player gets $1$ joker and $2$ plain cards, and the third player gets $2$ jokers and $1$ plain card, then the first player is the winner, and he gets $3 - 2 = 1$ point;  $n = 42$, $m = 0$, $k = 7$. Since there are no jokers, everyone gets $0$ jokers, everyone is a winner, and everyone gets $0$ points. \n\nGiven $n$, $m$ and $k$, calculate the maximum number of points a player can get for winning the game.\n\n\n-----Input-----\n\nThe first line of the input contains one integer $t$ ($1 \\le t \\le 500$) — the number of test cases.\n\nThen the test cases follow. Each test case contains three integers $n$, $m$ and $k$ ($2 \\le n \\le 50$, $0 \\le m \\le n$, $2 \\le k \\le n$, $k$ is a divisors of $n$).\n\n\n-----Output-----\n\nFor each test case, print one integer — the maximum number of points a player can get for winning the game.\n\n\n-----Example-----\nInput\n4\n8 3 2\n4 2 4\n9 6 3\n42 0 7\n\nOutput\n3\n0\n1\n0\n\n\n\n-----Note-----\n\nTest cases of the example are described in the statement.",
        "solutions": "[\"q = int(input())\\nfor _ in range(q):\\n\\tn,m,k = map(int,input().split())\\n\\tplayer = n//k\\n\\tjok_pla = min(n//k, m)\\n\\tjok_re = m-jok_pla\\n\\tmaksi = (jok_re +k-2)//(k-1)\\n\\tprint(jok_pla-maksi)\", \"\\nfor _ in range(int(input())):\\n    n, m, k = map(int, input().split())\\n    # n = int(input())\\n    # arr = list(map(int, input().split()))\\n    x = min(m, n // k)\\n    m -= x\\n    y = (m + (k - 1) - 1) // (k - 1)\\n    print(x - y)\", \"def ceil(a, b):\\n    return a // b + bool(a % b)\\n\\n\\ndef solve(n, m, k):\\n    c = n // k\\n    j1 = min(c, m)\\n    m -= j1\\n    return j1 - ceil(m, k - 1)\\n\\n\\nfor _ in range(int(input())):\\n    n, m, k = list(map(int, input().split()))\\n    print(solve(n, m, k))\\n\", \"import sys\\ninput = sys.stdin.readline\\nfor f in range(int(input())):\\n    n,m,k=map(int,input().split())\\n    c=n//k\\n    if m<=c:\\n        print(m)\\n    else:\\n        print(c-(m-c+k-2)//(k-1))\", \"t = int(input())\\n\\nfor _ in range(t):\\n    n, m, k = [int(x) for x in input().split()]\\n    np1 = min(m, n//k)\\n    m -= np1\\n    # the remainder divided over k - 1 players (rounded up)\\n    np2 = (m + k - 2)//(k-1)\\n    print(np1 - np2)\\n\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nt = read_int()\\nfor case_num in range(t):\\n    n, m, k = read_ints()\\n    hi = min(m, n // k)\\n    rest = (m - hi - 1) // (k - 1) + 1\\n    print(hi - rest)\\n\", \"t=int(input())\\n\\nfor i in range(t):\\n\\tn,m,k=map(int,input().split())\\n\\ta=min(m,n//k)\\n\\tm-=a\\n\\tb=(m+k-2)//(k-1)\\n\\tprint(a-b)\", \"for _ in range(int(input())):\\n    n, m, k = map(int, input().split())\\n    cards = n // k\\n    x = min(m, cards)\\n    y = __import__('math').ceil((m - x) / (k-1))\\n    print(x - y)\", \"import sys\\n\\ninput = sys.stdin.readline\\nflush = sys.stdout.flush\\n\\nfor _ in range(int(input())):\\n    n, m, k = list(map(int, input().split()))\\n    if m >= n // k:\\n        a = n // k\\n        m -= a\\n        b = m // (k - 1) + 1 - (m % (k - 1) == 0)\\n        print(a - b)\\n        continue\\n    else:\\n        print(m)\\n\", \"t = int(input())\\nfor _ in range(t):\\n\\tn, m, k = map(int, input().split())\\n\\thand_size = n // k\\n\\tmy_hand = min(hand_size, m)\\n\\tm -= my_hand\\n\\n\\tif m % (k-1) == 0:\\n\\t\\tnext_hand = m // (k-1)\\n\\telse:\\n\\t\\tnext_hand = m // (k-1) + 1\\n\\n\\tprint(my_hand - next_hand)\", \"for gfhua in range(int(input())):\\n    n,m,k = list(map(int,input().split()))\\n    mk = min(m, n // k)\\n    m -= mk\\n    if m == 0:\\n        print(mk)\\n    else:\\n        print(mk -(m + k - 2) // (k - 1))\\n        \\n\", \"def ceil(a, b):\\n    if (a % b == 0):\\n        return a // b\\n    else:\\n        return a // b + 1\\n\\nt = int(input())\\nfor case in range(t):\\n    n, m, k = list(map(int, input().split()))\\n    taken = min(m, n//k)\\n    remaining = m - taken\\n    print(taken - ceil(remaining, k-1))\\n\", \"import sys\\n\\nreadline = sys.stdin.readline\\nreadlines = sys.stdin.readlines\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\ndef solve():\\n    n, m, k = nm()\\n    if n // k >= m:\\n        print(m)\\n        return\\n    else:\\n        m -= n // k\\n        print(n // k - (m-1)//(k-1) - 1)\\n    return\\n\\n\\n# solve()\\n\\nT = ni()\\nfor _ in range(T):\\n    solve()\\n\", \"for _ in range(int(input())):\\n    n, m, k = list(map(int, input().split()))\\n    cardsPerPlayer = n // k\\n    x = min(cardsPerPlayer, m)\\n    m -= x\\n    print(x - (m+k-2) // (k-1))\\n\", \"from collections import *\\nfrom bisect import *\\nfrom math import *\\nfrom heapq import *\\nimport sys\\ninput=sys.stdin.readline\\nt=int(input())\\nwhile(t):\\n    t-=1\\n    n,m,k=list(map(int,input().split()))\\n    x=n//k\\n    if(x>=m):\\n        print(m)\\n        continue\\n    else:\\n        s=x\\n        re=m-x\\n        d=ceil(re/(k-1))\\n        print(x-d)\\n    \\n\", \"from math import sqrt\\n\\nt = int(input())\\nfor q in range(0, t):\\n    n, m, k = list(map(int, input().split()))\\n    if m <= n // k:\\n        print(m)\\n    else:\\n        if (m - (n // k)) % (k - 1) == 0:\\n            print(n // k - (m - (n // k)) // (k - 1))\\n        else:\\n            print(n // k - (m - (n // k)) // (k - 1) - 1)\\n\", \"def solve():\\n    n, m, k = map(int, input().split())\\n    c = n // k\\n    if m < c:\\n        print(m)\\n    else:\\n        print(c - (m - c + k - 2) // (k - 1))\\n\\n\\nfor i in range(int(input())):\\n    solve()\", \"from math import ceil\\n\\nt = int(input())\\nfor _ in range(t):\\n    n, m, k = map(int, input().split())\\n    a = min(n//k, m)\\n    \\n    print(a - ceil((m-a)/(k-1)))\", \"import sys, random, math\\nfrom bisect import bisect_left, bisect_right\\ninput = sys.stdin.readline\\n\\ndef main():\\n    inf = 10 ** 20\\n\\n    t = int(input())\\n#    t, a, b = map(int, input().split())\\n#    t = 1\\n    \\n    for _ in range(1, t+1):\\n    #    print(\\\"Case #{}: \\\".format(_), end = '')\\n        \\n        n, m, k = map(int, input().split())\\n        each = n // k\\n        best = min(each, m)\\n        m -= min(each, m)\\n        sec = m // (k-1)\\n        if(m % (k-1)):\\n            sec += 1\\n        print(best - sec)\\n        \\n        \\nmain()\", \"import sys\\ninput = sys.stdin.readline\\n\\nQ = int(input())\\nQuery = [list(map(int, input().split())) for _ in range(Q)]\\n\\nfor n, m, k in Query:\\n    p = n//k\\n    if p >= m:\\n        ans = m\\n    else:\\n        ans = max(p - (m-p+k-2)//(k-1) ,0)\\n    print(ans)\"]",
        "difficulty": "interview",
        "input": "1\n48 20 4\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1359/A"
    },
    {
        "id": 1963,
        "task_id": 2361,
        "test_case_id": 3,
        "question": "The game of Berland poker is played with a deck of $n$ cards, $m$ of which are jokers. $k$ players play this game ($n$ is divisible by $k$).\n\nAt the beginning of the game, each player takes $\\frac{n}{k}$ cards from the deck (so each card is taken by exactly one player). The player who has the maximum number of jokers is the winner, and he gets the number of points equal to $x - y$, where $x$ is the number of jokers in the winner's hand, and $y$ is the maximum number of jokers among all other players. If there are two or more players with maximum number of jokers, all of them are winners and they get $0$ points.\n\nHere are some examples:  $n = 8$, $m = 3$, $k = 2$. If one player gets $3$ jokers and $1$ plain card, and another player gets $0$ jokers and $4$ plain cards, then the first player is the winner and gets $3 - 0 = 3$ points;  $n = 4$, $m = 2$, $k = 4$. Two players get plain cards, and the other two players get jokers, so both of them are winners and get $0$ points;  $n = 9$, $m = 6$, $k = 3$. If the first player gets $3$ jokers, the second player gets $1$ joker and $2$ plain cards, and the third player gets $2$ jokers and $1$ plain card, then the first player is the winner, and he gets $3 - 2 = 1$ point;  $n = 42$, $m = 0$, $k = 7$. Since there are no jokers, everyone gets $0$ jokers, everyone is a winner, and everyone gets $0$ points. \n\nGiven $n$, $m$ and $k$, calculate the maximum number of points a player can get for winning the game.\n\n\n-----Input-----\n\nThe first line of the input contains one integer $t$ ($1 \\le t \\le 500$) — the number of test cases.\n\nThen the test cases follow. Each test case contains three integers $n$, $m$ and $k$ ($2 \\le n \\le 50$, $0 \\le m \\le n$, $2 \\le k \\le n$, $k$ is a divisors of $n$).\n\n\n-----Output-----\n\nFor each test case, print one integer — the maximum number of points a player can get for winning the game.\n\n\n-----Example-----\nInput\n4\n8 3 2\n4 2 4\n9 6 3\n42 0 7\n\nOutput\n3\n0\n1\n0\n\n\n\n-----Note-----\n\nTest cases of the example are described in the statement.",
        "solutions": "[\"q = int(input())\\nfor _ in range(q):\\n\\tn,m,k = map(int,input().split())\\n\\tplayer = n//k\\n\\tjok_pla = min(n//k, m)\\n\\tjok_re = m-jok_pla\\n\\tmaksi = (jok_re +k-2)//(k-1)\\n\\tprint(jok_pla-maksi)\", \"\\nfor _ in range(int(input())):\\n    n, m, k = map(int, input().split())\\n    # n = int(input())\\n    # arr = list(map(int, input().split()))\\n    x = min(m, n // k)\\n    m -= x\\n    y = (m + (k - 1) - 1) // (k - 1)\\n    print(x - y)\", \"def ceil(a, b):\\n    return a // b + bool(a % b)\\n\\n\\ndef solve(n, m, k):\\n    c = n // k\\n    j1 = min(c, m)\\n    m -= j1\\n    return j1 - ceil(m, k - 1)\\n\\n\\nfor _ in range(int(input())):\\n    n, m, k = list(map(int, input().split()))\\n    print(solve(n, m, k))\\n\", \"import sys\\ninput = sys.stdin.readline\\nfor f in range(int(input())):\\n    n,m,k=map(int,input().split())\\n    c=n//k\\n    if m<=c:\\n        print(m)\\n    else:\\n        print(c-(m-c+k-2)//(k-1))\", \"t = int(input())\\n\\nfor _ in range(t):\\n    n, m, k = [int(x) for x in input().split()]\\n    np1 = min(m, n//k)\\n    m -= np1\\n    # the remainder divided over k - 1 players (rounded up)\\n    np2 = (m + k - 2)//(k-1)\\n    print(np1 - np2)\\n\", \"def read_int():\\n    return int(input())\\n\\n\\ndef read_ints():\\n    return list(map(int, input().split(' ')))\\n\\n\\nt = read_int()\\nfor case_num in range(t):\\n    n, m, k = read_ints()\\n    hi = min(m, n // k)\\n    rest = (m - hi - 1) // (k - 1) + 1\\n    print(hi - rest)\\n\", \"t=int(input())\\n\\nfor i in range(t):\\n\\tn,m,k=map(int,input().split())\\n\\ta=min(m,n//k)\\n\\tm-=a\\n\\tb=(m+k-2)//(k-1)\\n\\tprint(a-b)\", \"for _ in range(int(input())):\\n    n, m, k = map(int, input().split())\\n    cards = n // k\\n    x = min(m, cards)\\n    y = __import__('math').ceil((m - x) / (k-1))\\n    print(x - y)\", \"import sys\\n\\ninput = sys.stdin.readline\\nflush = sys.stdout.flush\\n\\nfor _ in range(int(input())):\\n    n, m, k = list(map(int, input().split()))\\n    if m >= n // k:\\n        a = n // k\\n        m -= a\\n        b = m // (k - 1) + 1 - (m % (k - 1) == 0)\\n        print(a - b)\\n        continue\\n    else:\\n        print(m)\\n\", \"t = int(input())\\nfor _ in range(t):\\n\\tn, m, k = map(int, input().split())\\n\\thand_size = n // k\\n\\tmy_hand = min(hand_size, m)\\n\\tm -= my_hand\\n\\n\\tif m % (k-1) == 0:\\n\\t\\tnext_hand = m // (k-1)\\n\\telse:\\n\\t\\tnext_hand = m // (k-1) + 1\\n\\n\\tprint(my_hand - next_hand)\", \"for gfhua in range(int(input())):\\n    n,m,k = list(map(int,input().split()))\\n    mk = min(m, n // k)\\n    m -= mk\\n    if m == 0:\\n        print(mk)\\n    else:\\n        print(mk -(m + k - 2) // (k - 1))\\n        \\n\", \"def ceil(a, b):\\n    if (a % b == 0):\\n        return a // b\\n    else:\\n        return a // b + 1\\n\\nt = int(input())\\nfor case in range(t):\\n    n, m, k = list(map(int, input().split()))\\n    taken = min(m, n//k)\\n    remaining = m - taken\\n    print(taken - ceil(remaining, k-1))\\n\", \"import sys\\n\\nreadline = sys.stdin.readline\\nreadlines = sys.stdin.readlines\\nns = lambda: readline().rstrip()\\nni = lambda: int(readline().rstrip())\\nnm = lambda: map(int, readline().split())\\nnl = lambda: list(map(int, readline().split()))\\nprn = lambda x: print(*x, sep='\\\\n')\\n\\ndef solve():\\n    n, m, k = nm()\\n    if n // k >= m:\\n        print(m)\\n        return\\n    else:\\n        m -= n // k\\n        print(n // k - (m-1)//(k-1) - 1)\\n    return\\n\\n\\n# solve()\\n\\nT = ni()\\nfor _ in range(T):\\n    solve()\\n\", \"for _ in range(int(input())):\\n    n, m, k = list(map(int, input().split()))\\n    cardsPerPlayer = n // k\\n    x = min(cardsPerPlayer, m)\\n    m -= x\\n    print(x - (m+k-2) // (k-1))\\n\", \"from collections import *\\nfrom bisect import *\\nfrom math import *\\nfrom heapq import *\\nimport sys\\ninput=sys.stdin.readline\\nt=int(input())\\nwhile(t):\\n    t-=1\\n    n,m,k=list(map(int,input().split()))\\n    x=n//k\\n    if(x>=m):\\n        print(m)\\n        continue\\n    else:\\n        s=x\\n        re=m-x\\n        d=ceil(re/(k-1))\\n        print(x-d)\\n    \\n\", \"from math import sqrt\\n\\nt = int(input())\\nfor q in range(0, t):\\n    n, m, k = list(map(int, input().split()))\\n    if m <= n // k:\\n        print(m)\\n    else:\\n        if (m - (n // k)) % (k - 1) == 0:\\n            print(n // k - (m - (n // k)) // (k - 1))\\n        else:\\n            print(n // k - (m - (n // k)) // (k - 1) - 1)\\n\", \"def solve():\\n    n, m, k = map(int, input().split())\\n    c = n // k\\n    if m < c:\\n        print(m)\\n    else:\\n        print(c - (m - c + k - 2) // (k - 1))\\n\\n\\nfor i in range(int(input())):\\n    solve()\", \"from math import ceil\\n\\nt = int(input())\\nfor _ in range(t):\\n    n, m, k = map(int, input().split())\\n    a = min(n//k, m)\\n    \\n    print(a - ceil((m-a)/(k-1)))\", \"import sys, random, math\\nfrom bisect import bisect_left, bisect_right\\ninput = sys.stdin.readline\\n\\ndef main():\\n    inf = 10 ** 20\\n\\n    t = int(input())\\n#    t, a, b = map(int, input().split())\\n#    t = 1\\n    \\n    for _ in range(1, t+1):\\n    #    print(\\\"Case #{}: \\\".format(_), end = '')\\n        \\n        n, m, k = map(int, input().split())\\n        each = n // k\\n        best = min(each, m)\\n        m -= min(each, m)\\n        sec = m // (k-1)\\n        if(m % (k-1)):\\n            sec += 1\\n        print(best - sec)\\n        \\n        \\nmain()\", \"import sys\\ninput = sys.stdin.readline\\n\\nQ = int(input())\\nQuery = [list(map(int, input().split())) for _ in range(Q)]\\n\\nfor n, m, k in Query:\\n    p = n//k\\n    if p >= m:\\n        ans = m\\n    else:\\n        ans = max(p - (m-p+k-2)//(k-1) ,0)\\n    print(ans)\"]",
        "difficulty": "interview",
        "input": "1\n49 7 7\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1359/A"
    },
    {
        "id": 1964,
        "task_id": 2476,
        "test_case_id": 1,
        "question": "Takahashi has N cards. The i-th of these cards has an integer A_i written on it.\nTakahashi will choose an integer K, and then repeat the following operation some number of times:\n - Choose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)\nFor each K = 1,2, \\ldots, N, find the maximum number of times Takahashi can do the operation.\n\n-----Constraints-----\n -  1 \\le N \\le 3 \\times 10^5 \n -  1 \\le A_i \\le N \n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\nA_1 A_2 \\ldots A_N\n\n-----Output-----\nPrint N integers.\nThe t-th (1 \\le t \\le N) of them should be the answer for the case K=t.\n\n-----Sample Input-----\n3\n2 1 2\n\n-----Sample Output-----\n3\n1\n0\n\nFor K = 1, we can do the operation as follows:\n - Choose the first card to eat.\n - Choose the second card to eat.\n - Choose the third card to eat.\nFor K = 2, we can do the operation as follows:\n - Choose the first and second cards to eat.\nFor K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.",
        "solutions": "[\"N = int(input())\\nA = list(map(int,input().split()))\\nfrom collections import Counter\\nfrom bisect import bisect\\nvs = list(Counter(A).values())\\nvs.sort()\\ncums = [0]\\nfor v in vs:\\n    cums.append(cums[-1] + v)\\n\\ndef is_ok(k,m):\\n    j = bisect(vs,m)\\n    z = cums[j] + m*(len(vs)-j)\\n    return z >= m*k\\n\\nans = []\\nfor k in range(1,N+1):\\n    if k > len(vs):\\n        ans.append(0)\\n    else:\\n        ok = 0\\n        ng = N//k + 1\\n        while ng-ok > 1:\\n            m = (ok+ng)//2\\n            if is_ok(k,m):\\n                ok = m\\n            else:\\n                ng = m\\n        ans.append(ok)\\n\\nprint(*ans, sep='\\\\n')\", \"from collections import Counter\\nimport bisect\\nN=int(input())\\nA=list(map(int,input().split()))\\nC=list(Counter(A).values())\\nC.sort()\\nL=len(C)\\n\\n# C\\u306e\\u3046\\u3061x\\u4ee5\\u4e0a\\u306e\\u3082\\u306e\\u306e\\u500b\\u6570D[x]\\u3092\\u8a08\\u7b97(x=0,...,N)\\nD=[L-bisect.bisect_left(C,x) for x in range(N+1)]\\nS=[0]\\nfor n in range(1,N+1):\\n    S.append(S[-1]+D[n])\\n\\n# T[x]=S[x]/x(x=1,...,N)\\u3068\\u3057\\u3066K\\u3092bisect_right\\u3067\\u633f\\u5165\\u3057\\u305f\\u6642\\u306eindex\\u304c\\u7b54\\u3048\\nT=[x/S[x] for x in range(1,N+1)]\\nfor K in range(1,N+1):\\n    print(bisect.bisect_right(T,1/K))\", \"from collections import Counter\\nfrom bisect import bisect_left\\nfrom itertools import accumulate\\n\\n# https://betrue12.hateblo.jp/entry/2019/10/20/001106\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\na = list(Counter(A).values())\\na.sort()\\nb = list(accumulate(a))\\nlength = len(a)\\n\\nfor i in range(1, N + 1):\\n    if i == 1:\\n        print(b[-1])\\n    elif len(a) < i:\\n        print(0)\\n    else:\\n        n = b[-1] // i\\n        for j in reversed(range(1, n + 1)):\\n            t = bisect_left(a, j)\\n            if j * i <= b[t - 1] + (length - t) * j:\\n                print(j)\\n                break\", \"from collections import Counter\\nfrom itertools import accumulate\\nn = int(input())\\nA = tuple(map(int, input().split()))\\nC = Counter(A)\\nD = [0]*(n+1)\\nfor v in C.values():\\n  D[v] += 1\\nE = tuple(accumulate(k*d for k, d in enumerate(D)))\\nD = tuple(accumulate(D))\\nF = [0]*(n+1)\\nfor x in range(1, n+1):\\n  temp = (E[x] + x*(D[n]-D[x])) // x\\n  F[x] = temp\\nfor k in range(1, n+1):\\n  ok = 0\\n  ng = n+1\\n  while ng-ok > 1:\\n    mid = (ok+ng)//2\\n    if k <= F[mid]:\\n      ok = mid\\n    else:\\n      ng = mid\\n  print(ok)\", \"from collections import Counter\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nc = Counter(a)\\nd = Counter(c.values())\\n\\ndx = [0 for _ in range(n+1)]\\nfor i in range(1, n+1):\\n\\tdx[i] = dx[i-1] + i*d[i]\\n\\nxdx = [0 for _ in range(n+2)]\\nxdx[n] = d[n]\\nfor i in range(n-1, 0, -1):\\n\\txdx[i] = xdx[i+1] + d[i]\\n\\nres = [0] + [(dx[i] + i*xdx[i+1]) // i for i in range(1, n+1)]\\nans = [0 for _ in range(n)]\\ncur = n\\nfor i in range(n):\\n\\twhile cur > 0 and res[cur] < i+1:\\n\\t\\tcur -= 1\\n\\tif cur > 0:\\n\\t\\tans[i] = cur\\nprint(*ans, sep=\\\"\\\\n\\\")\", \"N = int(input())\\nA = list(map(int, input().split()))\\nC = [0]*N\\nfor a in A:\\n    C[a - 1] += 1\\nD = [0]*(N + 1)\\nfor c in C:\\n    D[c] += 1\\n\\nDk_accum = [0]*(N + 1)\\nfor i in range(1, N + 1):\\n    Dk_accum[i] = Dk_accum[i - 1] + i*D[i]\\n    \\nD_sum = sum(D)\\nD_accum = [0]*(N + 2)\\nD_accum[0] = D_sum\\nfor i in range(1, N + 1):\\n    D_accum[i] = D_accum[i - 1] - D[i - 1]\\n    \\nF = [0]*(N + 1)\\nfor i in range(1, N + 1):\\n    F[i] = (Dk_accum[i]//i + D_accum[i + 1])\\n\\ni = N\\nfor K in range(1, N + 1):\\n    while i > 0 and K > F[i]:\\n        i -= 1\\n    print(i)\\n\", \"# coding: utf-8\\n# Your code here!\\ndef f(m,k):#\\u6700\\u521d\\u306em\\u500b, k\\u305a\\u3064\\n    if m == 0: return 0\\n    if m < k: return 0\\n#    if (m,k) in memo:\\n#        return memo[(m,k)]\\n    z = 0\\n    if acc[m]//k >= c[m]:\\n        return acc[m]//k\\n    else:\\n        return f(m-1,k-1)\\n\\n\\nimport sys\\n#sys.setrecursionlimit(10**6)\\nreadline = sys.stdin.readline \\n\\nfrom itertools import accumulate\\n\\nn = int(input())\\na = [int(i) for i in readline().split()]\\n\\nres = [0]*(n+1)\\nfor i in a: res[i] += 1\\n\\nc = [0]\\nfor i in res:\\n    if i > 0: c.append(i)\\nc.sort()#reverse=True)\\n\\nl = len(c)-1\\n#print(c)\\nacc = list(accumulate(c))\\n\\n#print(acc,c)\\nres = [n]+[acc[m]//c[m] for m in range(1,l+1)]\\n\\n\\n#print(l,res)\\n\\n\\nm = l\\nfor k in range(1,n+1):\\n    k -= l-m\\n    if res[m] >= k:\\n        print((acc[m]//k))\\n    else:\\n#        print(k,m)\\n        while res[m] < k:\\n            m -= 1\\n            k -= 1\\n        print((acc[m]//(k)))\\n\\n\\n\\n\\n\\n\", \"import sys\\ninput = sys.stdin.readline\\nfrom collections import Counter\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nC = sorted(list(Counter(A).values()), reverse=True)\\nL = len(C)\\nB = []\\n\\nnum = C[0]\\nfor i, c in enumerate(C):\\n    for _ in range(num-c):\\n        B.append(i)\\n    num = c\\nfor _ in range(num):\\n    B.append(L)\\n\\nans = [N]\\nfor n in range(2, N+1):\\n    if n > L:\\n        ans.append(0)\\n        continue\\n    count = 0\\n    stack = []\\n    for b in B:\\n        tmp = b\\n        while stack:\\n            if tmp >= n:\\n                last = stack.pop()\\n                tmp = tmp + last - n\\n                count += 1\\n            else:\\n                break\\n        count += tmp//n\\n        stack.append(tmp%n)\\n    ans.append(count)\\n\\nprint(*ans, sep='\\\\n')\", \"from collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nc = list(Counter(a).values())\\nc.sort()\\n\\nans = n\\ncnt = 0\\nfor i in range(n):\\n    m = i + 1 - cnt\\n    while c and c[-1] > ans // m:\\n        ans -= c.pop()\\n        cnt += 1\\n        m -= 1\\n    print(ans // m)\", \"import os\\nimport sys\\n\\nimport numpy as np\\n\\nif os.getenv(\\\"LOCAL\\\"):\\n    sys.stdin = open(\\\"_in.txt\\\", \\\"r\\\")\\n\\nsys.setrecursionlimit(2147483647)\\nINF = float(\\\"inf\\\")\\nIINF = 10 ** 18\\nMOD = 10 ** 9 + 7\\n\\n# \\u89e3\\u8aacAC\\n# https://twitter.com/maspy_stars/status/1185552225474498560\\nN = int(sys.stdin.readline())\\nA = list(map(int, sys.stdin.readline().split()))\\n\\nC = list(np.bincount(A).tolist())\\nC.sort()\\ndeleted = 0\\nS = N\\n\\n\\ndef solve(k):\\n    nonlocal S, deleted\\n\\n    k -= deleted\\n    while k > 0 and C[-1] > S // k:\\n        S -= C.pop()\\n        deleted += 1\\n        k -= 1\\n    if k > 0:\\n        return S // k\\n    return 0\\n\\n\\nfor k in range(1, N + 1):\\n    print((solve(k)))\\n\", \"N = int(input())\\n \\nA = list(map(int,input().split()))\\n \\ndic = {}\\n \\nfor a in A:\\n \\n    if a not in dic:\\n        dic[a] = 1\\n    else:\\n        dic[a] += 1\\n \\nB = []\\nfor i in dic:\\n    B.append(dic[i])\\n \\nB.sort()\\n \\nB_sub = B.copy()\\n \\nfor i in range(len(B)-1):\\n    B_sub[i+1] += B_sub[i] \\n \\naind = N + 1\\nnind = len(B) - 1\\n \\n#print (B,B_sub)\\n \\nfor i in range(N):\\n \\n    i += 1\\n \\n    while True:\\n \\n        while nind > 0 and B[nind] > aind - 1:\\n \\n          nind -= 1\\n \\n        if i > len(B):\\n            print (0)\\n            break\\n \\n        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:\\n            print (aind - 1)\\n            break\\n \\n        aind -= 1\", \"import collections\\nimport numpy as np\\n\\n# \\u30ea\\u30b9\\u30c8arr\\u304b\\u3089x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u3092\\u53d6\\u308a\\u51fa\\u3059\\u6642\\u306e\\u6700\\u5927\\u306e\\u9577\\u3055\\n# \\u767a\\u60f3: x\\u500b\\u53d6\\u308a\\u51fa\\u3059\\u6642\\u3001\\u3042\\u308b\\u6587\\u5b57\\u3092x\\u500b\\u3088\\u308a\\u591a\\u304f\\u53d6\\u308a\\u51fa\\u3057\\u3066\\u5217\\u306b\\u542b\\u3080\\u3053\\u3068\\u306f\\u306a\\u3044\\n#       \\u4e00\\u65b9\\u3042\\u308b\\u6587\\u5b57\\u3092\\u305d\\u306e\\u6587\\u5b57\\u304c\\u3042\\u308b\\u6570\\u3088\\u308a\\u3082\\u53d6\\u308a\\u51fa\\u3057\\u3066\\u4f7f\\u3046\\u3053\\u3068\\u3082\\u3067\\u304d\\u306a\\u3044\\n#       \\u3064\\u307e\\u308a\\u3001min(arr.count(a), x)\\u3067\\u3001x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u306b\\u4f7f\\u3048\\u308ba\\u306e\\u6570\\u304c\\u308f\\u304b\\u308b\\n#       \\u3055\\u3089\\u306b\\u3001sum(min(arr.count(a),x))\\u3067\\u3001x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u306b\\u4f7f\\u3048\\u308b\\u6587\\u5b57\\u306e\\u6570\\u304c\\u308f\\u304b\\u308b\\n#       \\u3088\\u3063\\u3066\\u3001sum(min(arr.count(a),x))//x\\u3067\\u3001x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u306e\\u9577\\u3055\\u304c\\u308f\\u304b\\u308b\\n#       \\u767a\\u5c55\\u7684\\u306b\\u3001longest(arr,x)\\u307e\\u3067\\u306e\\u8a08\\u7b97\\u72b6\\u6cc1\\u304b\\u3089longest(arr,x+1)\\u304c\\u8a08\\u7b97\\u3067\\u304d\\u308b\\n# def longest(arr, x):    # legacy\\n#     return sum(min(arr.count(a), x) for a in arr) // x\\n\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\ncounter = collections.Counter(a)        #O(n)\\nnums = list(counter.values())           #O(n)\\nnum_counter = collections.Counter(nums) #O(n)\\nlastest_add = np.count_nonzero(nums)    #O(n)\\nbuilding, longests = [0], [0]\\nfor i in range(1, n+1):                 #O(n)\\n    appended = building[-1] + lastest_add   #O(1)\\n    building.append(appended)               #O(1)\\n    longests.append(appended // i)          #O(1)\\n    lastest_add -= num_counter[i]           #O(1)\\n\\n\\nlastest_longest = 0\\nk_most = []\\nfor i, x in enumerate(reversed(longests)):\\n    while x > lastest_longest:\\n        lastest_longest += 1\\n        k_most.append(n-i)\\n\\nk_most.extend([0]*(n-len(k_most)))      # zero padding\\n\\nfor longests_num in k_most:\\n    print(longests_num)\\n\\n# print('----------------')\\n# for k in range(1, n+1):\\n#     maxindexes = list(i for i, x in enumerate(longests) if x >= k)\\n#     if maxindexes:\\n#         print(maxindexes[-1])\\n#     else:\\n#         print(0)\\n\", \"import bisect\\n\\nn = int(input())\\nA = list(map(int, input().split()))\\ncounts = [0]*(n)\\nfor a in A:\\n    counts[a-1] += 1\\ncounts.sort()\\n\\ncumsum = []\\nnum = 0\\nfor count in counts:\\n    num += count\\n    cumsum.append(num)\\n\\nanswers = [0]*(n)\\nfor i in range(1, n+1):\\n    idx = bisect.bisect_right(counts, i)\\n    left = cumsum[idx-1]\\n    right = (n-idx)*i\\n    K = (right+left)//i\\n    answers[K-1] = i\\n\\nnow = 0\\nfor i in range(n-1, -1, -1):\\n    if answers[i] == 0:\\n        answers[i] = now\\n    now = answers[i]\\n\\nfor ans in answers:\\n    print(ans)\", \"def main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    C = [0] * (N+1)\\n    Cnt_A = [0] * (N+1)\\n    for a in A:\\n        Cnt_A[a] += 1\\n        cnt = Cnt_A[a]\\n        C[cnt] += 1\\n    cum_C = []\\n    cu = 0\\n    for c in C:\\n        cu += c\\n        cum_C.append(cu)\\n    Ans = []\\n    for k in range(1, N+1):\\n        # K = k \\u306e\\u3068\\u304d\\u3001 n \\u7d44\\u4ee5\\u4e0a\\u4f5c\\u308c\\u308b <=> \\u4f7f\\u3048\\u308b\\u30ab\\u30fc\\u30c9\\u304c nk \\u679a\\u4ee5\\u4e0a\\n        # n \\u7d44\\u4ee5\\u4e0a\\u4f5c\\u308c\\u308b <=> \\u540c\\u3058\\u30ab\\u30fc\\u30c9\\u306f n \\u679a\\u4ee5\\u4e0b\\n        # \\u540c\\u3058\\u30ab\\u30fc\\u30c9\\u306f n \\u679a\\u4ee5\\u4e0b\\u3067\\u5168\\u4f53\\u3068\\u3057\\u3066 nk \\u679a\\u4ee5\\u4e0a\\u7528\\u610f\\u3067\\u304d\\u308b\\u304b\\uff1f\\n        ok, ng = 0, N//k+1\\n        while ok + 1 < ng:\\n            n = ok+ng>>1\\n            if cum_C[n] >= n*k:\\n                ok = n\\n            else:\\n                ng = n\\n        Ans.append(ok)\\n    print((\\\"\\\\n\\\".join(map(str, Ans))))\\n\\nmain()\\n\", \"n = int(input())\\narr = list(map(int,input().split()))\\n\\nfrom collections import Counter\\nc = Counter(arr)\\nc = list(c.values())\\nc.sort()\\ns = n\\n\\nsol = []\\nremoved = 0\\nfor k in range(1,n+1):\\n    rest = k - removed\\n    while c and c[-1] > s//rest:\\n        s -= c[-1]\\n        c.pop()\\n        rest -= 1\\n        removed += 1\\n    sol.append(s//rest)\\n\\nprint(\\\"\\\\n\\\".join(map(str,sol)))\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\nC = [0] * N\\nD = [0] * (N + 1)\\nfor a in A:\\n    C[a - 1] += 1\\n    D[C[a - 1]] += 1\\n\\nS = [0] * (N + 1)\\nfor i in range(N):\\n    S[i + 1] = S[i] + D[i + 1]\\n\\nans = N\\nfor K in range(1, N + 1):\\n    while ans > 0 and S[ans] < K * ans:\\n        ans -= 1\\n    print(ans)\", \"#!/usr/bin/env python3\\nimport sys\\nimport collections\\n\\ndef solve(N: int, A: \\\"List[int]\\\"):\\n    counter = sorted(list(collections.Counter(A).values()),reverse=True)\\n    c_index = 0\\n    k=0\\n    for i in range(1,N+1):\\n        k+=1\\n        if len(counter)<i:\\n            print((0))\\n            continue\\n        while counter[c_index]*k > N and c_index<len(counter)-1:\\n            N-=counter[c_index]\\n            c_index+=1\\n            k-=1\\n        print((N//k))\\n    return\\n\\ndef main():\\n    def iterate_tokens():\\n        for line in sys.stdin:\\n            for word in line.split():\\n                yield word\\n    tokens = iterate_tokens()\\n    N = int(next(tokens))  # type: int\\n    A = [int(next(tokens)) for _ in range(N)]  # type: \\\"List[int]\\\"\\n    solve(N, A)\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\nimport time,random\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\ndef pe(s): return print(str(s), file=sys.stderr)\\ndef JA(a, sep): return sep.join(map(str, a))\\ndef JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)\\n\\n\\ndef main():\\n    n = I()\\n    c = sorted(collections.Counter(LI()).values(), reverse=True) + [0]\\n    ci = 0\\n    t = n\\n    r = [0]\\n    for i in range(n,0,-1):\\n        while c[ci] > i:\\n            ci += 1\\n        t -= ci\\n        r.append(t // i)\\n\\n    rr = []\\n    r.reverse()\\n    ri = 0\\n    for i in range(n,0,-1):\\n        while r[ri] >= i:\\n            ri += 1\\n        rr.append(ri)\\n\\n    rr.reverse()\\n\\n    return JA(rr,\\\"\\\\n\\\")\\n\\n\\nprint(main())\\n\\n\\n\", \"from collections import Counter\\nN = int(input())\\nC = sorted(list(Counter(list(map(int, input().split()))).values()))\\n\\nrest = N\\nremoved = 0\\nfor K in range(1, N + 1):\\n    d = K - removed\\n    while C and C[- 1] > rest//d:\\n        rest -= C[- 1]\\n        C.pop()\\n        removed += 1\\n        d -= 1\\n    print((rest//d))\\n\", \"# F - Distinct Numbers\\nfrom bisect import bisect_left\\n\\ndef isOK(c, k, N, L, cum_sum):\\n    i = bisect_left(L, c)\\n    s = c * (N - i) + cum_sum[i];\\n    return (s >= c * k)\\n\\nN = int(input())\\nD = list(map(int, input().split()))\\nfreq = [0] * N\\nfor d in D:\\n    freq[d - 1] += 1\\n    \\nfreq.sort()\\ncum_sum = [0] * (N + 1)\\nfor i in range(N):\\n    cum_sum[i + 1] = cum_sum[i] + freq[i]\\n    \\nfor k in range(1, N + 1):\\n    l = 0\\n    r = int(N / k) + 1\\n    while l + 1 < r:\\n        c = int((l + r) / 2)\\n        ok = isOK(c, k, N, freq, cum_sum)\\n        if ok:\\n            l = c\\n        else:\\n            r = c\\n    print(l)\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nfrom collections import Counter\\nfrom itertools import accumulate\\nfrom math import floor\\nfrom bisect import bisect_left\\n\\n\\ndef main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n\\n    c = Counter(a)\\n    c = list(c.values())\\n\\n    d = Counter(c)\\n    d_li = [0] * (n + 1)\\n    for k, v in list(d.items()):\\n        d_li[k] = v\\n\\n    dk_acm = list(accumulate(d_li))\\n\\n    kdk_acm = [0]\\n    for k, e in enumerate(d_li[1:], 1):\\n        kdk_acm.append(kdk_acm[-1] + k * e)\\n\\n    def f(x):\\n        kdk_sm = kdk_acm[x]\\n        dk_sm = dk_acm[n] - dk_acm[x]\\n\\n        return floor((kdk_sm + x * dk_sm) / x)\\n\\n    fs = [float(\\\"inf\\\")] + [f(x) for x in range(1, n + 1)]\\n    fs = fs[::-1]\\n\\n    for k in range(1, n + 1):\\n        print((n - bisect_left(fs, k)))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys \\nimport collections as cl\\n\\n\\nN=int(input())\\nA=list(map(int,sys.stdin.readline().split()))\\nc=cl.Counter(A)\\nNumberTupleList=c.most_common()\\nNumberList=[x[1] for x in NumberTupleList[::-1]]\\nLengthOfNumberList=len(NumberList)\\nFormulaList=[0 for i in range(N)]\\nflag=0\\nS=sum(NumberList)\\nfor x in range(1,N+1):\\n    while flag<LengthOfNumberList and NumberList[flag]<=x:\\n        flag+=1\\n    if flag<LengthOfNumberList:\\n        FormulaList[x-1]=(sum(NumberList[:flag])+x*(LengthOfNumberList-flag))/x\\n    else:\\n        FormulaList[x-1]=S/x\\npin=N-1\\nfor K in range(1,N+1):\\n    while pin>=0 and K>FormulaList[pin]:\\n        pin-=1\\n    print((pin+1))\\n\\n\", \"from bisect import bisect_left\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nlst = [0] * (N + 1)\\nfor a in A:\\n    lst[a - 1] += 1\\nlst.sort() #\\u983b\\u5ea6\\u5217\\n\\ns = [0] * (N + 1)\\nfor i in range(N):\\n    s[i + 1] = s[i] + lst[i + 1]\\n\\n# print (lst)\\n# print (s)\\n\\ndef check(x, k):\\n    i = bisect_left(lst, x) - 1\\n    total = x * (N - i) + s[i]\\n    return total >= x * k\\n\\n\\nfor k in range(1, N + 1):\\n    l = 0 #OK\\n    r = N // k + 1 #NG\\n    while l + 1 < r:\\n        c = (l + r) // 2\\n        if check(c, k):\\n            l = c\\n        else:\\n            r = c\\n    print (l)\\n\", \"import os\\nimport sys\\n\\nimport numpy as np\\n\\nif os.getenv(\\\"LOCAL\\\"):\\n    sys.stdin = open(\\\"_in.txt\\\", \\\"r\\\")\\n\\nsys.setrecursionlimit(2147483647)\\nINF = float(\\\"inf\\\")\\nIINF = 10 ** 18\\nMOD = 10 ** 9 + 7\\n\\n# \\u89e3\\u8aacAC\\n# https://img.atcoder.jp/abc143/editorial.pdf\\nN = int(sys.stdin.readline())\\nA = list(map(int, sys.stdin.readline().split()))\\n\\nA = np.array(A, dtype=int)\\nC = np.bincount(A, minlength=N + 2)\\nD = np.bincount(C, minlength=N + 2)\\n\\nld = (D * np.arange(len(D))).cumsum()\\nud = D[::-1].cumsum()[::-1]\\n\\nX = np.arange(1, N + 1, dtype=int)\\n# L[x]: x \\u56de\\u53d6\\u308c\\u308b\\u3068\\u304d\\u306e\\u6700\\u5927\\u306e\\u9577\\u3055 k\\nL = np.zeros(N + 1, dtype=int)\\nL[X] = (ld[X] + X * ud[X + 1]) // X\\n\\ni = len(L) - 1\\nfor k in range(1, N + 1):\\n    while i > 0 and L[i] < k:\\n        i -= 1\\n    print(i)\\n\", \"from collections import Counter\\nN = int(input())\\n#C = sorted(list(Counter(map(int, input().split())).values()))\\nC = list(Counter(map(int, input().split())).values())\\nC.sort()\\n\\nrest = N\\nremoved = 0\\nfor K in range(1, N + 1):\\n    d = K - removed\\n    while C and C[- 1] > rest//d:\\n        rest -= C[- 1]\\n        C.pop()\\n        removed += 1\\n        d -= 1\\n    print(rest//d)\", \"import sys\\nstdin = sys.stdin\\n\\nni = lambda: int(ns())\\nna = lambda: list(map(int, stdin.readline().split()))\\nnn = lambda: list(stdin.readline().split())\\nns = lambda: stdin.readline().rstrip()\\n\\nimport bisect\\nfrom collections import Counter\\n\\nn = ni()\\na = na()\\n\\nc = sorted(Counter(a).values())\\ncc = [0]\\nm = len(c)\\nfor i in c:\\n    cc.append(cc[-1]+i)\\n\\ndef is_ok(k,arg):\\n    b = bisect.bisect_right(c,arg)\\n    p = cc[b] + (m-b)*arg\\n    return True if p >= arg*k else False\\n\\nfor k in range(1,n+1):\\n    if k > m:\\n        print((0))\\n        continue\\n    #\\u306b\\u3076\\u305f\\u3093\\n    ok,ng = -1,n//k+1\\n    while (abs(ok - ng) > 1):\\n        mid = (ok + ng) // 2\\n        if is_ok(k,mid):\\n            ok = mid\\n        else:\\n            ng = mid\\n    \\n    print(ok)\\n\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\na=[int(j) for j in input().split()]\\nfrom collections import Counter\\nc=Counter(a)\\nl=c.most_common()\\nll=[]\\nfor i,j in l:\\n    ll.append(j)\\nll.sort()\\ns=sum(ll)\\nrem=0\\nfor k in range(1,n+1):\\n    rest=k-rem\\n    while ll and ll[-1]>s//rest:\\n        s-=ll[-1]\\n        ll.pop()\\n        rem+=1\\n        rest-=1\\n    print((s//rest))\\n\\n\\n\\n\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nN=int(input())\\nA=list(map(int,input().split()))\\n\\nfrom collections import Counter\\nfrom itertools import accumulate\\nimport bisect\\n\\nC=Counter(A)\\n\\nLIST=sorted(C.values())\\nLEN=len(LIST)\\nSUM=[0]+list(accumulate(LIST))\\nMIN=0\\nMAX=SUM[-1]\\n\\nfor k in range(1,N+1):\\n    MIN=0\\n    while MIN!=MAX:\\n        mid=(MIN+MAX+1)//2\\n        x=bisect.bisect_right(LIST,mid)\\n\\n        if SUM[x]+(LEN-x)*mid>=mid*k:\\n            MIN=mid\\n        else:\\n            MAX=mid-1\\n\\n    print(MIN)\\n\", \"from bisect import bisect_left\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nlst = [0] * (N + 1)\\nfor a in A:\\n    lst[a - 1] += 1\\nlst.sort() #\\u983b\\u5ea6\\u5217\\n\\ns = [0] * (N + 1)\\nfor i in range(N):\\n    s[i + 1] = s[i] + lst[i + 1]\\n\\n# print (lst)\\n# print (s)\\n\\ndef check(x, k):\\n    i = bisect_left(lst, x) - 1\\n    total = x * (N - i) + s[i]\\n    return total >= x * k\\n\\nans = N\\nfor k in range(1, N + 1):\\n    while True:\\n        if check(ans, k):\\n            break\\n        ans -= 1\\n    print (ans)\\n\", \"# -*- coding: utf-8 -*-\\nfrom collections import Counter\\nfrom itertools import accumulate\\n\\nN = int(input())\\nA = list(map(int,input().split()))\\n\\nB = list(Counter(A).values())\\n\\nC = [0] * N \\nfor i in B:\\n    C[i-1] += 1\\n\\nF = list(accumulate(C))\\n\\nS = [0] * N\\nf = [0] * N\\nS[0] = f[0] = sum(C) \\nfor i in range(2, N+1):\\n    S[i-1] = (S[i-2] + C[i-1] + S[0] - F[i-1] ) \\n    f[i-1] = S[i-1] / i\\n\\nf.sort()\\nn = 0     \\nK = 1\\n    \\nwhile K != N+1:\\n    if K <= f[n]:\\n        print(N-n)\\n        K += 1\\n    else:\\n        n += 1\\n    if n == N:\\n        for i in range(N-K+1):\\n            print(0)\\n        K = N+1    \", \"import itertools\\nimport collections\\nN = int(input())\\nA = [int(_) for _ in input().split()]\\nc = sorted(collections.Counter(A).values())\\nacc = list(itertools.accumulate([0] + c))\\nn = len(acc) - 1\\nj = 0\\nfor i in range(1, n + 1):\\n    r = 0\\n    while i - j > 0:\\n        if (i - j) * c[-1 - j] <= acc[-1 - j]:\\n            r = acc[-1 - j] // (i - j)\\n            break\\n        else:\\n            j += 1\\n    print(r)\\nfor _ in range(N - n):\\n    print((0))\\n\", \"from collections import Counter\\nimport bisect\\n\\n\\ndef main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    count_list = list(Counter(A).values())\\n    count_list.sort()\\n    cumsum_count = [0] * len(count_list)\\n    cumsum_count[0] = count_list[0]\\n    for i in range(1, len(count_list)):\\n        cumsum_count[i] = cumsum_count[i - 1] + count_list[i]\\n    ans_list = [0] * N\\n    n_max = N\\n    for k in range(1, len(count_list) + 1):\\n        # \\u6700\\u5927\\u3067\\u3082 N // k \\u56de\\u307e\\u3067\\u3002\\n        # \\u5404\\u30ab\\u30fc\\u30c9 n_max \\u679a\\u307e\\u3067\\u4f7f\\u3063\\u3066 k * n_max \\u306e\\u9577\\u65b9\\u5f62\\u9818\\u57df\\u3092\\u5168\\u90e8\\u57cb\\u3081\\u5c3d\\u304f\\u305b\\u308b\\u304b\\u3092\\u8abf\\u3079\\u308b\\u3002\\n        # \\u57cb\\u3081\\u5c3d\\u304f\\u305b\\u308b\\u6700\\u5c0f\\u306e n_max \\u304c\\u7b54\\u3048\\u3002\\n        n_max = min(n_max, N // k)\\n        s = 0\\n        while True:\\n            # n_max \\u679a\\u4ee5\\u4e0a\\u3042\\u308b\\u30ab\\u30fc\\u30c9\\u306f n_max \\u679a\\u56fa\\u5b9a\\n            index = bisect.bisect_left(count_list, n_max)\\n            s = n_max * (len(count_list) - index)\\n            # \\u305d\\u308c\\u672a\\u6e80\\u306e\\u30ab\\u30fc\\u30c9\\u306f\\u305d\\u306e\\u307e\\u307e\\u5168\\u90e8\\u4f7f\\u3046\\n            if index > 0:\\n                s += cumsum_count[index - 1]\\n            if s >= k * n_max or n_max == 0:\\n                break\\n            n_max -= 1\\n        ans_list[k - 1] = n_max\\n    for ans in ans_list:\\n        print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n = int(input())\\nA = list(map(int,input().split()))\\nB = [0]*(n+1)\\nC = [0]*(n+1)\\nfor a in A:\\n    B[a] += 1\\n    C[B[a]] += 1\\n\\nX = [0]\\nfor i in range(1,n+1):\\n    X.append(X[i-1] + C[i])\\nfor j in range(1,n+1):\\n    X[j] = X[j] // j\\n\\nind = n\\nk = 1\\nwhile k<=n:\\n    if ind<0:\\n        for _ in range(n-k+1):\\n            print(0)\\n        break\\n    if k<=X[ind]:\\n        print(ind)\\n        k += 1\\n    else:\\n        ind -= 1\", \"from itertools import accumulate\\n\\nN, *A = map(int, open(0).read().split())\\n\\nC = [0] * (N + 1)\\nD = [0] * (N + 1)\\nfor a in A:\\n    C[a] += 1\\n    D[C[a]] += 1\\n\\nT = [0] + [s // i for i, s in enumerate(accumulate(D[1:]), 1)]\\n\\nans = []\\nx = N\\nfor k in range(1, N + 1):\\n    while 0 < x and T[x] < k:\\n        x -= 1\\n    ans.append(x)\\n\\nprint(\\\"\\\\n\\\".join(map(str, ans)))\", \"from collections import Counter\\nfrom bisect import bisect_left\\nfrom itertools import accumulate\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\na = list(Counter(A).values())\\na.sort()\\nb = list(accumulate(a + [0]))\\ns = sum(a)\\nlength = len(a)\\n\\nfor i in range(1, N + 1):\\n    if i == 1:\\n        print(s)\\n    elif len(a) < i:\\n        print(0)\\n    else:\\n        n = s // i\\n        for j in reversed(range(1, n + 1)):\\n            t = bisect_left(a, j)\\n            if j * i <= b[t - 1] + (length - t) * j:\\n                print(j)\\n                break\", \"def main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    # C[x]: \\u66f8\\u304b\\u308c\\u3066\\u3044\\u308b\\u6574\\u6570\\u304cx\\u3067\\u3042\\u308b\\u30ab\\u30fc\\u30c9\\u306e\\u679a\\u6570\\n    C = [0] * (N + 1)\\n    D = [0] * (N + 1)\\n    for a in A:\\n        C[a] += 1\\n        D[C[a]] += 1\\n\\n    # A\\u304b\\u3089K(1<=K<=N)\\u679a\\u305a\\u3064\\u30ab\\u30fc\\u30c9\\u3092\\u629c\\u3044\\u3066\\u3063\\u305f\\u3068\\u304d\\u306b\\u3001\\n    # x\\u56de\\u4ee5\\u4e0a\\u629c\\u304f\\u3053\\u3068\\u304c\\u3067\\u304d\\u308b\\u304b\\u5224\\u5b9a\\u3059\\u308b\\u3002\\n    # \\u629c\\u304f\\u3053\\u3068\\u304c\\u3067\\u304d\\u308b\\u3068\\u5224\\u5b9a\\u3055\\u308c\\u305fx\\u306e\\u6700\\u5927\\u5024\\u304c\\u7b54\\u3048\\u306b\\u306a\\u308b\\u3002\\n\\n    # \\u4f8b\\u3048\\u3070\\u3001A = [1 1 1 1 1 2 2 3] \\u3068\\u3059\\u308b\\u3002\\n    # -> C = [5 2 1 0 0 0 0 0]\\n    # \\u3053\\u3053\\u304b\\u30892\\u679a\\u305a\\u3064\\u30ab\\u30fc\\u30c9\\u3092\\u629c\\u3051\\u308b\\u56de\\u6570\\u3092\\u8003\\u3048\\u308b\\u3068\\u304d\\u3001\\n    # \\u300c3\\u56de\\u629c\\u304f\\u300d\\u3068\\u3059\\u308b\\u3068\\u3001\\u6570\\u5b57\\u306e1\\u306f\\u3001\\u3069\\u3046\\u3084\\u3063\\u3066\\u30822\\u500b\\u306f\\u7d76\\u5bfe\\u4f59\\u308b\\n    # \\u305d\\u3053\\u3067\\u3001\\u7d76\\u5bfe\\u4f59\\u308b\\u90e8\\u5206\\u3092\\u6368\\u3066\\u3066C\\u3092\\u4f5c\\u308a\\u76f4\\u3059(=E\\u3068\\u3059\\u308b)\\u3068\\u3001\\n    # E = [3 2 1 0 0 0 0 0]\\n    # \\u3053\\u3053\\u304b\\u30892\\u679a\\u305a\\u30643\\u56de\\u629c\\u3051\\u308b\\u304b\\u5224\\u5b9a\\u3059\\u308b\\u306a\\u3089\\u3001\\n    # sum(E) >= 2 * 3 = 6\\n    # \\u3067\\u3042\\u308b\\u304b\\u898b\\u308c\\u3070\\u3088\\u3044\\u3002\\u4eca\\u56de\\u306e\\u5834\\u5408\\u3061\\u3087\\u3046\\u30696\\u306a\\u306e\\u3067\\u30012\\u679a\\u305a\\u30643\\u56de\\u306f\\u629c\\u3051\\u308b\\u3002\\n    \\n    # 3\\u679a\\u305a\\u30642\\u56de\\u306c\\u3051\\u308b\\u304b\\u8abf\\u3079\\u308b\\u5834\\u5408\\u3001\\n    # E = [2 2 1] \\u3068\\u306a\\u308a\\u3001sum(E) = 5 < 3 * 2 = 6 \\u306a\\u306e\\u3067\\u3001\\u629c\\u3051\\u306a\\u3044\\u3053\\u3068\\u304c\\u5206\\u304b\\u308b\\n\\n    # \\u3088\\u3063\\u3066\\u3001\\n    # sum(min(C[i], x)) >= K * x \\u3067\\u3042\\u308c\\u3070\\u629c\\u304f\\u3053\\u3068\\u304c\\u3067\\u304d\\u308b\\n    # S(x) = sum(min(C[i], x)) \\u3068\\u3059\\u308b\\u3068\\u3001\\n    # S(x) = S(x-1) + [C\\u306e\\u4e2d\\u3067C[i] >= x \\u3067\\u3042\\u308b\\u3082\\u306e\\u306e\\u500b\\u6570]\\n    # \\u3068\\u306a\\u308b\\u3053\\u3068\\u304b\\u3089\\u3001C\\u306e\\u4e2d\\u3067C[i] >= x \\u3067\\u3042\\u308b\\u3082\\u306e\\u306e\\u500b\\u6570 = D(x) \\u3068\\u3059\\u308b\\u3068\\u3001\\n    # S(x) = sum_(1~x) D(i) \\u3068\\u306a\\u308b\\u3002\\n    # \\u3064\\u307e\\u308a\\u3001S(x)\\u306f\\u3001D(x) \\u3092\\u6700\\u521d\\u306b\\u5168\\u90e8\\u8a08\\u7b97\\u3057\\u3066\\u304a\\u3044\\u3066\\u3001\\u7d2f\\u7a4d\\u548c\\u3092\\u3068\\u308b\\u3053\\u3068\\u3067\\u9ad8\\u901f\\u306b\\u8a08\\u7b97\\u3067\\u304d\\u308b\\u3002\\n\\n    # S(x) >= K * x \\u3068\\u306a\\u308bx\\u306e\\u6700\\u5927\\u5024\\u3092\\u3001k\\u30921\\u304b\\u3089N\\u307e\\u3067\\u52d5\\u304b\\u3057\\u3066\\u898b\\u3064\\u3051\\u308c\\u3070\\u3088\\u3044\\u3002\\n    # \\u3053\\u3053\\u3067\\u3001x\\u3092\\u5de6\\u8fba\\u306b\\u3082\\u3063\\u3066\\u3044\\u3063\\u3066\\u3001\\n    # S(x) / x >= K\\u3068\\u306a\\u308bx\\u306e\\u6700\\u5927\\u5024\\u3092\\u898b\\u3064\\u3051\\u308b\\u3088\\u3046\\u306b\\u3059\\u308b\\u3002\\n    # \\u307e\\u305f\\u3001S(x) / x = f(x) \\u3068\\u304a\\u304f\\u3002\\n\\n    # \\u6700\\u5927\\u5024\\u3092\\u898b\\u3064\\u3051\\u308b\\u305f\\u3081\\u306b2\\u5206\\u63a2\\u7d22\\u3057\\u3066\\u3082\\u3044\\u3044\\u304c\\u3001\\n    # K\\u304c\\u5897\\u3048\\u308b\\u3068\\u3001\\u7b54\\u3048\\u306f\\u4ee5\\u524d\\u306e\\u5024\\u4ee5\\u4e0b\\u306b\\u306a\\u308b\\u306f\\u305a\\u306a\\u306e\\u3067\\u3001\\n    # K+1\\u306e\\u3068\\u304d\\u3001K\\u3067\\u306e\\u7b54\\u3048\\u306e\\u4f4d\\u7f6e\\u304b\\u30890\\u3078\\u3068\\u63a2\\u7d22\\u3057\\u3066\\u3044\\u3051\\u3070\\u3001O(N)\\u3067\\u7b54\\u3048\\u304c\\u898b\\u3064\\u304b\\u308b\\n    S = [0] * (N + 1)\\n    f = [0] * (N + 1)\\n    for x in range(1, N+1):\\n        S[x] = S[x-1] + D[x]\\n        f[x] = S[x] // x\\n\\n    ans = []\\n    prev_ans = N\\n    for K in range(1, N+1):\\n        a = prev_ans\\n        while True:\\n            if f[a] >= K or a == 0:\\n                break\\n            a -= 1\\n        ans.append(a)\\n        prev_ans = a\\n\\n    print(*ans, sep='\\\\n')\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"def main():\\n    from sys import stdin\\n    input = stdin.readline\\n    from collections import Counter as ct\\n    from bisect import bisect_left as bl\\n\\n    n = int(input())\\n    max_a = sorted(ct(list(map(int, input().split()))).values())\\n    now_a = [i for i in max_a]\\n    m = len(max_a)\\n    cnt = m\\n    ans = 0\\n    ans_list = [0]*(n-m)\\n\\n    for use in range(m, 1, -1):\\n        rest = ans\\n        nex = now_a[0]\\n        while rest:\\n            val = nex\\n            start = bl(now_a, val+1)\\n            nex += 1\\n            q = max(-1, start-1-rest, bl(max_a, now_a[start-1]+1)-1)\\n            for i in range(start-1, q, -1):\\n                now_a[i] += 1\\n            if now_a[start-1] == 1:\\n                cnt += start-1-q\\n            rest -= start-1-q\\n            if start != m:\\n                nex = now_a[start]\\n        while cnt >= use:\\n            ans += 1\\n            rest = use\\n            nex = now_a[-1]\\n            end = m\\n            while rest:\\n                val = nex\\n                start = bl(now_a, val)\\n                if start != 0:\\n                    nex = now_a[start-1]\\n                end = min(end, bl(now_a, val+1), start+rest)\\n                for i in range(start, end):\\n                    now_a[i] -= 1\\n                if now_a[start] == 0:\\n                    cnt -= end-start\\n                rest -= end-start\\n                end = start\\n        ans_list.append(ans)\\n    print(n)\\n    for i in ans_list[::-1]:\\n        print(i)\\n\\n\\nmain()\", \"N = int(input())\\nA = list(map(int,input().split()))\\nC = [0] * (N + 1)\\nfor a in A:\\n    C[a] += 1\\nD = [0] * (N + 1)\\nfor c in C:\\n    D[c] += 1\\nP = [0] * (N + 1)\\nQ = [0] * (N + 1)\\nfor i in range(1, N+1):\\n    P[i] = P[i-1] + i * D[i]\\n    Q[i] = Q[i-1] + D[i]\\nF = [0] * (N + 1)\\nfor i in range(1, N+1):\\n    F[i] = int((P[i] + i * (Q[N] - Q[i])) / i)\\nindex = N\\nfor i in range(1, N+1):\\n    while True:\\n        if index == 0:\\n            print(0)\\n            break\\n        if F[index] >= i:\\n            print(index)\\n            break\\n        else:\\n            index -= 1\", \"from collections import defaultdict\\nfrom bisect import bisect\\nN = int(input())\\nA = list(map(int,input().split()))\\n\\nd = defaultdict(lambda:0)\\n\\nfor i in range(N):\\n    d[A[i]] += 1\\n\\nC = [0]*(N+1)\\n\\nfor i in d:\\n    C[d[i]] += 1\\n\\nC1 = [0]*(N+1)\\nC2 = [0]*(N+1)\\n\\nfor i in range(N):\\n    C1[i+1] = C1[i] + (i+1)*C[i+1]\\n    C2[i+1] = C2[i] + C[i+1]\\n\\nl = [0]*N\\nfor n in range(N):\\n    l[n] = C1[n+1]//(n+1)+C2[N]-C2[n+1]\\n    l[n] *= -1\\n\\n\\nfor i in range(N):\\n    print(bisect(l,-(i+1)))\", \"\\nN = int(input())\\n\\nA = list(map(int,input().split()))\\n\\ndic = {}\\n\\nfor a in A:\\n\\n    if a not in dic:\\n        dic[a] = 1\\n    else:\\n        dic[a] += 1\\n\\nB = []\\nfor i in dic:\\n    B.append(dic[i])\\n\\nB.sort()\\n\\nB_sub = B.copy()\\n\\nfor i in range(len(B)-1):\\n    B_sub[i+1] += B_sub[i] \\n\\naind = N + 1\\nnind = len(B) - 1\\n\\n#print (B,B_sub)\\n\\nfor i in range(N):\\n\\n    i += 1\\n\\n    while True:\\n\\n        while nind > 0 and B[nind] > aind - 1:\\n\\n          nind -= 1\\n\\n        if i > len(B):\\n            print((0))\\n            break\\n\\n        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:\\n            print((aind - 1))\\n            break\\n\\n        aind -= 1\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\nnum = [0 for _ in range(N)]\\nfor a in A:\\n    num[a-1] += 1\\nnum.sort()\\ncum = [0 for _ in range(N)]\\ncum[0] = num[0]\\nfor i in range(1, N):\\n    cum[i] = cum[i-1] + num[i]\\n\\nindex = N - 1\\nans = N\\nfor k in range(1, N+1):\\n    while ans > 0:\\n        tmp_index = index\\n        while tmp_index >= 0 and num[tmp_index] > ans:\\n            tmp_index -= 1\\n        decided = N - tmp_index - 1\\n        rest_total = 0 if tmp_index < 0 else cum[tmp_index]\\n        if rest_total >= ans * (k - decided):\\n            index = tmp_index\\n            break\\n        ans -= 1\\n    print(ans)\", \"import sys\\nfrom collections import Counter\\n\\nsys.setrecursionlimit(10 ** 6)\\ninput = sys.stdin.readline\\n\\ndef main():\\n    n = int(input())\\n    aa = list(map(int, input().split()))\\n    aa = list(Counter(aa).values())\\n    aa.sort()\\n    cs = [0]\\n    s = 0\\n    for a in aa:\\n        s += a\\n        cs += [s]\\n    # print(aa)\\n    # print(cs)\\n    ans = n + 1\\n    i = len(aa)\\n    for k in range(1, n + 1):\\n        while 1:\\n            while i > 0 and aa[i - 1] >= ans:\\n                i -= 1\\n            s = cs[i] + ans * (len(aa) - i)\\n            if s >= ans * k:\\n                break\\n            else:\\n                ans -= 1\\n        print(ans)\\n\\nmain()\\n\", \"N=int(input())\\nA=list(map(int,input().split()))\\n\\nc = [0] * (N + 1)\\nDx = [0] * (N + 1)\\nfor a in A:\\n    c[a] += 1 #c\\u306f\\u3001a\\u3068\\u3044\\u3046\\u6570\\u304c\\u51fa\\u305f\\u56de\\u6570\\u3092\\u8a18\\u9332\\n    Dx[c[a]]+=1\\n    #Dx\\u306f\\u3001\\u305d\\u306e\\u56de\\u6570\\u306e\\u3068\\u3053\\u308d\\u306b\\u7a2e\\u985e\\u3092\\u8a18\\u9332\\u3002\\u8ce2\\u3044\\u3002\\n\\nSx=[0]#\\u521d\\u9805\\u306f0\\nfor j in range(1,N+1):\\n    Sx.append(Sx[j-1]+Dx[j])\\n#\\u89e3\\u6cd52\\u3092\\u771f\\u4f3c\\u3057\\u3066\\u307f\\u308b\\u3002\\nfor h in range(1,N+1):\\n    Sx[h]=Sx[h]/h\\n\\nx=N\\nk=1\\nwhile k<N+1:\\n    if x<0:\\n        for _ in range(N-k+1):\\n            print((0))\\n        return\\n    if k<=Sx[x]:\\n        print(x)\\n        k+=1\\n    else:\\n        x-=1\\n\", \"from collections import Counter\\n\\nN = int(input())\\nAs = list(map(int, input().split()))\\n\\ncntA = Counter(As)\\ncntCntA = Counter(list(cntA.values()))\\n\\naccDs = [cntCntA[0]]\\nfor i in range(1, N+1):\\n    accDs.append(accDs[-1] + cntCntA[i])\\n\\naccKDs = [0]\\nfor i in range(1, N+1):\\n    accKDs.append(accKDs[-1] + i*cntCntA[i])\\n\\nfXs = [0]\\nfor X in range(1, N+1):\\n    fXs.append((accKDs[X] + X*(accDs[N]-accDs[X])) // X)\\n\\nanss = [0] * (N+1)\\nfor X, fX in enumerate(fXs):\\n    anss[fX] = X\\n\\nfor i in reversed(list(range(N))):\\n    if anss[i] == 0:\\n        anss[i] = anss[i+1]\\n\\nprint(('\\\\n'.join(map(str, anss[1:]))))\\n\", \"from bisect import bisect_left\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nlst = [0] * (N)\\nfor a in A:\\n    lst[a - 1] += 1\\nlst.sort() #\\u983b\\u5ea6\\u5217\\n\\ns = [0] * (N + 1)\\nfor i in range(N):\\n    s[i + 1] = s[i] + lst[i]\\n\\n# print (lst)\\n# print (s)\\n\\n# def check(x, k):\\n#     i = bisect_left(lst, x) - 1\\n#     total = x * (N - i) + s[i]\\n#     return total >= x * k\\n\\n\\nans = N\\ni = N\\nfor k in range(1, N + 1):\\n    while True:\\n        while  i >= 1 and lst[i - 1] >= ans:\\n            i -= 1\\n        total = ans * (N - i) + s[i]\\n        if total >= ans * k:\\n            break\\n        ans -= 1\\n    # print ('i =', i)\\n    print (ans)\\n\", \"from collections import Counter\\nN = int(input())\\nC = sorted(list(Counter(list(map(int, input().split()))).values()))\\n\\nrest = N\\nremoved = 0\\nfor K in range(1, N + 1):\\n    d = K - removed\\n    while C and C[- 1] > rest//d:\\n        rest -= C[- 1]\\n        C.pop()\\n        removed += 1\\n        d -= 1\\n    print((rest//d))\\n\"]",
        "difficulty": "interview",
        "input": "3\n2 1 2\n",
        "output": "3\n1\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://atcoder.jp/contests/abc143/tasks/abc143_f"
    },
    {
        "id": 1965,
        "task_id": 2476,
        "test_case_id": 2,
        "question": "Takahashi has N cards. The i-th of these cards has an integer A_i written on it.\nTakahashi will choose an integer K, and then repeat the following operation some number of times:\n - Choose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)\nFor each K = 1,2, \\ldots, N, find the maximum number of times Takahashi can do the operation.\n\n-----Constraints-----\n -  1 \\le N \\le 3 \\times 10^5 \n -  1 \\le A_i \\le N \n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\nA_1 A_2 \\ldots A_N\n\n-----Output-----\nPrint N integers.\nThe t-th (1 \\le t \\le N) of them should be the answer for the case K=t.\n\n-----Sample Input-----\n3\n2 1 2\n\n-----Sample Output-----\n3\n1\n0\n\nFor K = 1, we can do the operation as follows:\n - Choose the first card to eat.\n - Choose the second card to eat.\n - Choose the third card to eat.\nFor K = 2, we can do the operation as follows:\n - Choose the first and second cards to eat.\nFor K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.",
        "solutions": "[\"N = int(input())\\nA = list(map(int,input().split()))\\nfrom collections import Counter\\nfrom bisect import bisect\\nvs = list(Counter(A).values())\\nvs.sort()\\ncums = [0]\\nfor v in vs:\\n    cums.append(cums[-1] + v)\\n\\ndef is_ok(k,m):\\n    j = bisect(vs,m)\\n    z = cums[j] + m*(len(vs)-j)\\n    return z >= m*k\\n\\nans = []\\nfor k in range(1,N+1):\\n    if k > len(vs):\\n        ans.append(0)\\n    else:\\n        ok = 0\\n        ng = N//k + 1\\n        while ng-ok > 1:\\n            m = (ok+ng)//2\\n            if is_ok(k,m):\\n                ok = m\\n            else:\\n                ng = m\\n        ans.append(ok)\\n\\nprint(*ans, sep='\\\\n')\", \"from collections import Counter\\nimport bisect\\nN=int(input())\\nA=list(map(int,input().split()))\\nC=list(Counter(A).values())\\nC.sort()\\nL=len(C)\\n\\n# C\\u306e\\u3046\\u3061x\\u4ee5\\u4e0a\\u306e\\u3082\\u306e\\u306e\\u500b\\u6570D[x]\\u3092\\u8a08\\u7b97(x=0,...,N)\\nD=[L-bisect.bisect_left(C,x) for x in range(N+1)]\\nS=[0]\\nfor n in range(1,N+1):\\n    S.append(S[-1]+D[n])\\n\\n# T[x]=S[x]/x(x=1,...,N)\\u3068\\u3057\\u3066K\\u3092bisect_right\\u3067\\u633f\\u5165\\u3057\\u305f\\u6642\\u306eindex\\u304c\\u7b54\\u3048\\nT=[x/S[x] for x in range(1,N+1)]\\nfor K in range(1,N+1):\\n    print(bisect.bisect_right(T,1/K))\", \"from collections import Counter\\nfrom bisect import bisect_left\\nfrom itertools import accumulate\\n\\n# https://betrue12.hateblo.jp/entry/2019/10/20/001106\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\na = list(Counter(A).values())\\na.sort()\\nb = list(accumulate(a))\\nlength = len(a)\\n\\nfor i in range(1, N + 1):\\n    if i == 1:\\n        print(b[-1])\\n    elif len(a) < i:\\n        print(0)\\n    else:\\n        n = b[-1] // i\\n        for j in reversed(range(1, n + 1)):\\n            t = bisect_left(a, j)\\n            if j * i <= b[t - 1] + (length - t) * j:\\n                print(j)\\n                break\", \"from collections import Counter\\nfrom itertools import accumulate\\nn = int(input())\\nA = tuple(map(int, input().split()))\\nC = Counter(A)\\nD = [0]*(n+1)\\nfor v in C.values():\\n  D[v] += 1\\nE = tuple(accumulate(k*d for k, d in enumerate(D)))\\nD = tuple(accumulate(D))\\nF = [0]*(n+1)\\nfor x in range(1, n+1):\\n  temp = (E[x] + x*(D[n]-D[x])) // x\\n  F[x] = temp\\nfor k in range(1, n+1):\\n  ok = 0\\n  ng = n+1\\n  while ng-ok > 1:\\n    mid = (ok+ng)//2\\n    if k <= F[mid]:\\n      ok = mid\\n    else:\\n      ng = mid\\n  print(ok)\", \"from collections import Counter\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nc = Counter(a)\\nd = Counter(c.values())\\n\\ndx = [0 for _ in range(n+1)]\\nfor i in range(1, n+1):\\n\\tdx[i] = dx[i-1] + i*d[i]\\n\\nxdx = [0 for _ in range(n+2)]\\nxdx[n] = d[n]\\nfor i in range(n-1, 0, -1):\\n\\txdx[i] = xdx[i+1] + d[i]\\n\\nres = [0] + [(dx[i] + i*xdx[i+1]) // i for i in range(1, n+1)]\\nans = [0 for _ in range(n)]\\ncur = n\\nfor i in range(n):\\n\\twhile cur > 0 and res[cur] < i+1:\\n\\t\\tcur -= 1\\n\\tif cur > 0:\\n\\t\\tans[i] = cur\\nprint(*ans, sep=\\\"\\\\n\\\")\", \"N = int(input())\\nA = list(map(int, input().split()))\\nC = [0]*N\\nfor a in A:\\n    C[a - 1] += 1\\nD = [0]*(N + 1)\\nfor c in C:\\n    D[c] += 1\\n\\nDk_accum = [0]*(N + 1)\\nfor i in range(1, N + 1):\\n    Dk_accum[i] = Dk_accum[i - 1] + i*D[i]\\n    \\nD_sum = sum(D)\\nD_accum = [0]*(N + 2)\\nD_accum[0] = D_sum\\nfor i in range(1, N + 1):\\n    D_accum[i] = D_accum[i - 1] - D[i - 1]\\n    \\nF = [0]*(N + 1)\\nfor i in range(1, N + 1):\\n    F[i] = (Dk_accum[i]//i + D_accum[i + 1])\\n\\ni = N\\nfor K in range(1, N + 1):\\n    while i > 0 and K > F[i]:\\n        i -= 1\\n    print(i)\\n\", \"# coding: utf-8\\n# Your code here!\\ndef f(m,k):#\\u6700\\u521d\\u306em\\u500b, k\\u305a\\u3064\\n    if m == 0: return 0\\n    if m < k: return 0\\n#    if (m,k) in memo:\\n#        return memo[(m,k)]\\n    z = 0\\n    if acc[m]//k >= c[m]:\\n        return acc[m]//k\\n    else:\\n        return f(m-1,k-1)\\n\\n\\nimport sys\\n#sys.setrecursionlimit(10**6)\\nreadline = sys.stdin.readline \\n\\nfrom itertools import accumulate\\n\\nn = int(input())\\na = [int(i) for i in readline().split()]\\n\\nres = [0]*(n+1)\\nfor i in a: res[i] += 1\\n\\nc = [0]\\nfor i in res:\\n    if i > 0: c.append(i)\\nc.sort()#reverse=True)\\n\\nl = len(c)-1\\n#print(c)\\nacc = list(accumulate(c))\\n\\n#print(acc,c)\\nres = [n]+[acc[m]//c[m] for m in range(1,l+1)]\\n\\n\\n#print(l,res)\\n\\n\\nm = l\\nfor k in range(1,n+1):\\n    k -= l-m\\n    if res[m] >= k:\\n        print((acc[m]//k))\\n    else:\\n#        print(k,m)\\n        while res[m] < k:\\n            m -= 1\\n            k -= 1\\n        print((acc[m]//(k)))\\n\\n\\n\\n\\n\\n\", \"import sys\\ninput = sys.stdin.readline\\nfrom collections import Counter\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nC = sorted(list(Counter(A).values()), reverse=True)\\nL = len(C)\\nB = []\\n\\nnum = C[0]\\nfor i, c in enumerate(C):\\n    for _ in range(num-c):\\n        B.append(i)\\n    num = c\\nfor _ in range(num):\\n    B.append(L)\\n\\nans = [N]\\nfor n in range(2, N+1):\\n    if n > L:\\n        ans.append(0)\\n        continue\\n    count = 0\\n    stack = []\\n    for b in B:\\n        tmp = b\\n        while stack:\\n            if tmp >= n:\\n                last = stack.pop()\\n                tmp = tmp + last - n\\n                count += 1\\n            else:\\n                break\\n        count += tmp//n\\n        stack.append(tmp%n)\\n    ans.append(count)\\n\\nprint(*ans, sep='\\\\n')\", \"from collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nc = list(Counter(a).values())\\nc.sort()\\n\\nans = n\\ncnt = 0\\nfor i in range(n):\\n    m = i + 1 - cnt\\n    while c and c[-1] > ans // m:\\n        ans -= c.pop()\\n        cnt += 1\\n        m -= 1\\n    print(ans // m)\", \"import os\\nimport sys\\n\\nimport numpy as np\\n\\nif os.getenv(\\\"LOCAL\\\"):\\n    sys.stdin = open(\\\"_in.txt\\\", \\\"r\\\")\\n\\nsys.setrecursionlimit(2147483647)\\nINF = float(\\\"inf\\\")\\nIINF = 10 ** 18\\nMOD = 10 ** 9 + 7\\n\\n# \\u89e3\\u8aacAC\\n# https://twitter.com/maspy_stars/status/1185552225474498560\\nN = int(sys.stdin.readline())\\nA = list(map(int, sys.stdin.readline().split()))\\n\\nC = list(np.bincount(A).tolist())\\nC.sort()\\ndeleted = 0\\nS = N\\n\\n\\ndef solve(k):\\n    nonlocal S, deleted\\n\\n    k -= deleted\\n    while k > 0 and C[-1] > S // k:\\n        S -= C.pop()\\n        deleted += 1\\n        k -= 1\\n    if k > 0:\\n        return S // k\\n    return 0\\n\\n\\nfor k in range(1, N + 1):\\n    print((solve(k)))\\n\", \"N = int(input())\\n \\nA = list(map(int,input().split()))\\n \\ndic = {}\\n \\nfor a in A:\\n \\n    if a not in dic:\\n        dic[a] = 1\\n    else:\\n        dic[a] += 1\\n \\nB = []\\nfor i in dic:\\n    B.append(dic[i])\\n \\nB.sort()\\n \\nB_sub = B.copy()\\n \\nfor i in range(len(B)-1):\\n    B_sub[i+1] += B_sub[i] \\n \\naind = N + 1\\nnind = len(B) - 1\\n \\n#print (B,B_sub)\\n \\nfor i in range(N):\\n \\n    i += 1\\n \\n    while True:\\n \\n        while nind > 0 and B[nind] > aind - 1:\\n \\n          nind -= 1\\n \\n        if i > len(B):\\n            print (0)\\n            break\\n \\n        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:\\n            print (aind - 1)\\n            break\\n \\n        aind -= 1\", \"import collections\\nimport numpy as np\\n\\n# \\u30ea\\u30b9\\u30c8arr\\u304b\\u3089x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u3092\\u53d6\\u308a\\u51fa\\u3059\\u6642\\u306e\\u6700\\u5927\\u306e\\u9577\\u3055\\n# \\u767a\\u60f3: x\\u500b\\u53d6\\u308a\\u51fa\\u3059\\u6642\\u3001\\u3042\\u308b\\u6587\\u5b57\\u3092x\\u500b\\u3088\\u308a\\u591a\\u304f\\u53d6\\u308a\\u51fa\\u3057\\u3066\\u5217\\u306b\\u542b\\u3080\\u3053\\u3068\\u306f\\u306a\\u3044\\n#       \\u4e00\\u65b9\\u3042\\u308b\\u6587\\u5b57\\u3092\\u305d\\u306e\\u6587\\u5b57\\u304c\\u3042\\u308b\\u6570\\u3088\\u308a\\u3082\\u53d6\\u308a\\u51fa\\u3057\\u3066\\u4f7f\\u3046\\u3053\\u3068\\u3082\\u3067\\u304d\\u306a\\u3044\\n#       \\u3064\\u307e\\u308a\\u3001min(arr.count(a), x)\\u3067\\u3001x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u306b\\u4f7f\\u3048\\u308ba\\u306e\\u6570\\u304c\\u308f\\u304b\\u308b\\n#       \\u3055\\u3089\\u306b\\u3001sum(min(arr.count(a),x))\\u3067\\u3001x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u306b\\u4f7f\\u3048\\u308b\\u6587\\u5b57\\u306e\\u6570\\u304c\\u308f\\u304b\\u308b\\n#       \\u3088\\u3063\\u3066\\u3001sum(min(arr.count(a),x))//x\\u3067\\u3001x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u306e\\u9577\\u3055\\u304c\\u308f\\u304b\\u308b\\n#       \\u767a\\u5c55\\u7684\\u306b\\u3001longest(arr,x)\\u307e\\u3067\\u306e\\u8a08\\u7b97\\u72b6\\u6cc1\\u304b\\u3089longest(arr,x+1)\\u304c\\u8a08\\u7b97\\u3067\\u304d\\u308b\\n# def longest(arr, x):    # legacy\\n#     return sum(min(arr.count(a), x) for a in arr) // x\\n\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\ncounter = collections.Counter(a)        #O(n)\\nnums = list(counter.values())           #O(n)\\nnum_counter = collections.Counter(nums) #O(n)\\nlastest_add = np.count_nonzero(nums)    #O(n)\\nbuilding, longests = [0], [0]\\nfor i in range(1, n+1):                 #O(n)\\n    appended = building[-1] + lastest_add   #O(1)\\n    building.append(appended)               #O(1)\\n    longests.append(appended // i)          #O(1)\\n    lastest_add -= num_counter[i]           #O(1)\\n\\n\\nlastest_longest = 0\\nk_most = []\\nfor i, x in enumerate(reversed(longests)):\\n    while x > lastest_longest:\\n        lastest_longest += 1\\n        k_most.append(n-i)\\n\\nk_most.extend([0]*(n-len(k_most)))      # zero padding\\n\\nfor longests_num in k_most:\\n    print(longests_num)\\n\\n# print('----------------')\\n# for k in range(1, n+1):\\n#     maxindexes = list(i for i, x in enumerate(longests) if x >= k)\\n#     if maxindexes:\\n#         print(maxindexes[-1])\\n#     else:\\n#         print(0)\\n\", \"import bisect\\n\\nn = int(input())\\nA = list(map(int, input().split()))\\ncounts = [0]*(n)\\nfor a in A:\\n    counts[a-1] += 1\\ncounts.sort()\\n\\ncumsum = []\\nnum = 0\\nfor count in counts:\\n    num += count\\n    cumsum.append(num)\\n\\nanswers = [0]*(n)\\nfor i in range(1, n+1):\\n    idx = bisect.bisect_right(counts, i)\\n    left = cumsum[idx-1]\\n    right = (n-idx)*i\\n    K = (right+left)//i\\n    answers[K-1] = i\\n\\nnow = 0\\nfor i in range(n-1, -1, -1):\\n    if answers[i] == 0:\\n        answers[i] = now\\n    now = answers[i]\\n\\nfor ans in answers:\\n    print(ans)\", \"def main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    C = [0] * (N+1)\\n    Cnt_A = [0] * (N+1)\\n    for a in A:\\n        Cnt_A[a] += 1\\n        cnt = Cnt_A[a]\\n        C[cnt] += 1\\n    cum_C = []\\n    cu = 0\\n    for c in C:\\n        cu += c\\n        cum_C.append(cu)\\n    Ans = []\\n    for k in range(1, N+1):\\n        # K = k \\u306e\\u3068\\u304d\\u3001 n \\u7d44\\u4ee5\\u4e0a\\u4f5c\\u308c\\u308b <=> \\u4f7f\\u3048\\u308b\\u30ab\\u30fc\\u30c9\\u304c nk \\u679a\\u4ee5\\u4e0a\\n        # n \\u7d44\\u4ee5\\u4e0a\\u4f5c\\u308c\\u308b <=> \\u540c\\u3058\\u30ab\\u30fc\\u30c9\\u306f n \\u679a\\u4ee5\\u4e0b\\n        # \\u540c\\u3058\\u30ab\\u30fc\\u30c9\\u306f n \\u679a\\u4ee5\\u4e0b\\u3067\\u5168\\u4f53\\u3068\\u3057\\u3066 nk \\u679a\\u4ee5\\u4e0a\\u7528\\u610f\\u3067\\u304d\\u308b\\u304b\\uff1f\\n        ok, ng = 0, N//k+1\\n        while ok + 1 < ng:\\n            n = ok+ng>>1\\n            if cum_C[n] >= n*k:\\n                ok = n\\n            else:\\n                ng = n\\n        Ans.append(ok)\\n    print((\\\"\\\\n\\\".join(map(str, Ans))))\\n\\nmain()\\n\", \"n = int(input())\\narr = list(map(int,input().split()))\\n\\nfrom collections import Counter\\nc = Counter(arr)\\nc = list(c.values())\\nc.sort()\\ns = n\\n\\nsol = []\\nremoved = 0\\nfor k in range(1,n+1):\\n    rest = k - removed\\n    while c and c[-1] > s//rest:\\n        s -= c[-1]\\n        c.pop()\\n        rest -= 1\\n        removed += 1\\n    sol.append(s//rest)\\n\\nprint(\\\"\\\\n\\\".join(map(str,sol)))\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\nC = [0] * N\\nD = [0] * (N + 1)\\nfor a in A:\\n    C[a - 1] += 1\\n    D[C[a - 1]] += 1\\n\\nS = [0] * (N + 1)\\nfor i in range(N):\\n    S[i + 1] = S[i] + D[i + 1]\\n\\nans = N\\nfor K in range(1, N + 1):\\n    while ans > 0 and S[ans] < K * ans:\\n        ans -= 1\\n    print(ans)\", \"#!/usr/bin/env python3\\nimport sys\\nimport collections\\n\\ndef solve(N: int, A: \\\"List[int]\\\"):\\n    counter = sorted(list(collections.Counter(A).values()),reverse=True)\\n    c_index = 0\\n    k=0\\n    for i in range(1,N+1):\\n        k+=1\\n        if len(counter)<i:\\n            print((0))\\n            continue\\n        while counter[c_index]*k > N and c_index<len(counter)-1:\\n            N-=counter[c_index]\\n            c_index+=1\\n            k-=1\\n        print((N//k))\\n    return\\n\\ndef main():\\n    def iterate_tokens():\\n        for line in sys.stdin:\\n            for word in line.split():\\n                yield word\\n    tokens = iterate_tokens()\\n    N = int(next(tokens))  # type: int\\n    A = [int(next(tokens)) for _ in range(N)]  # type: \\\"List[int]\\\"\\n    solve(N, A)\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\nimport time,random\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\ndef pe(s): return print(str(s), file=sys.stderr)\\ndef JA(a, sep): return sep.join(map(str, a))\\ndef JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)\\n\\n\\ndef main():\\n    n = I()\\n    c = sorted(collections.Counter(LI()).values(), reverse=True) + [0]\\n    ci = 0\\n    t = n\\n    r = [0]\\n    for i in range(n,0,-1):\\n        while c[ci] > i:\\n            ci += 1\\n        t -= ci\\n        r.append(t // i)\\n\\n    rr = []\\n    r.reverse()\\n    ri = 0\\n    for i in range(n,0,-1):\\n        while r[ri] >= i:\\n            ri += 1\\n        rr.append(ri)\\n\\n    rr.reverse()\\n\\n    return JA(rr,\\\"\\\\n\\\")\\n\\n\\nprint(main())\\n\\n\\n\", \"from collections import Counter\\nN = int(input())\\nC = sorted(list(Counter(list(map(int, input().split()))).values()))\\n\\nrest = N\\nremoved = 0\\nfor K in range(1, N + 1):\\n    d = K - removed\\n    while C and C[- 1] > rest//d:\\n        rest -= C[- 1]\\n        C.pop()\\n        removed += 1\\n        d -= 1\\n    print((rest//d))\\n\", \"# F - Distinct Numbers\\nfrom bisect import bisect_left\\n\\ndef isOK(c, k, N, L, cum_sum):\\n    i = bisect_left(L, c)\\n    s = c * (N - i) + cum_sum[i];\\n    return (s >= c * k)\\n\\nN = int(input())\\nD = list(map(int, input().split()))\\nfreq = [0] * N\\nfor d in D:\\n    freq[d - 1] += 1\\n    \\nfreq.sort()\\ncum_sum = [0] * (N + 1)\\nfor i in range(N):\\n    cum_sum[i + 1] = cum_sum[i] + freq[i]\\n    \\nfor k in range(1, N + 1):\\n    l = 0\\n    r = int(N / k) + 1\\n    while l + 1 < r:\\n        c = int((l + r) / 2)\\n        ok = isOK(c, k, N, freq, cum_sum)\\n        if ok:\\n            l = c\\n        else:\\n            r = c\\n    print(l)\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nfrom collections import Counter\\nfrom itertools import accumulate\\nfrom math import floor\\nfrom bisect import bisect_left\\n\\n\\ndef main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n\\n    c = Counter(a)\\n    c = list(c.values())\\n\\n    d = Counter(c)\\n    d_li = [0] * (n + 1)\\n    for k, v in list(d.items()):\\n        d_li[k] = v\\n\\n    dk_acm = list(accumulate(d_li))\\n\\n    kdk_acm = [0]\\n    for k, e in enumerate(d_li[1:], 1):\\n        kdk_acm.append(kdk_acm[-1] + k * e)\\n\\n    def f(x):\\n        kdk_sm = kdk_acm[x]\\n        dk_sm = dk_acm[n] - dk_acm[x]\\n\\n        return floor((kdk_sm + x * dk_sm) / x)\\n\\n    fs = [float(\\\"inf\\\")] + [f(x) for x in range(1, n + 1)]\\n    fs = fs[::-1]\\n\\n    for k in range(1, n + 1):\\n        print((n - bisect_left(fs, k)))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys \\nimport collections as cl\\n\\n\\nN=int(input())\\nA=list(map(int,sys.stdin.readline().split()))\\nc=cl.Counter(A)\\nNumberTupleList=c.most_common()\\nNumberList=[x[1] for x in NumberTupleList[::-1]]\\nLengthOfNumberList=len(NumberList)\\nFormulaList=[0 for i in range(N)]\\nflag=0\\nS=sum(NumberList)\\nfor x in range(1,N+1):\\n    while flag<LengthOfNumberList and NumberList[flag]<=x:\\n        flag+=1\\n    if flag<LengthOfNumberList:\\n        FormulaList[x-1]=(sum(NumberList[:flag])+x*(LengthOfNumberList-flag))/x\\n    else:\\n        FormulaList[x-1]=S/x\\npin=N-1\\nfor K in range(1,N+1):\\n    while pin>=0 and K>FormulaList[pin]:\\n        pin-=1\\n    print((pin+1))\\n\\n\", \"from bisect import bisect_left\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nlst = [0] * (N + 1)\\nfor a in A:\\n    lst[a - 1] += 1\\nlst.sort() #\\u983b\\u5ea6\\u5217\\n\\ns = [0] * (N + 1)\\nfor i in range(N):\\n    s[i + 1] = s[i] + lst[i + 1]\\n\\n# print (lst)\\n# print (s)\\n\\ndef check(x, k):\\n    i = bisect_left(lst, x) - 1\\n    total = x * (N - i) + s[i]\\n    return total >= x * k\\n\\n\\nfor k in range(1, N + 1):\\n    l = 0 #OK\\n    r = N // k + 1 #NG\\n    while l + 1 < r:\\n        c = (l + r) // 2\\n        if check(c, k):\\n            l = c\\n        else:\\n            r = c\\n    print (l)\\n\", \"import os\\nimport sys\\n\\nimport numpy as np\\n\\nif os.getenv(\\\"LOCAL\\\"):\\n    sys.stdin = open(\\\"_in.txt\\\", \\\"r\\\")\\n\\nsys.setrecursionlimit(2147483647)\\nINF = float(\\\"inf\\\")\\nIINF = 10 ** 18\\nMOD = 10 ** 9 + 7\\n\\n# \\u89e3\\u8aacAC\\n# https://img.atcoder.jp/abc143/editorial.pdf\\nN = int(sys.stdin.readline())\\nA = list(map(int, sys.stdin.readline().split()))\\n\\nA = np.array(A, dtype=int)\\nC = np.bincount(A, minlength=N + 2)\\nD = np.bincount(C, minlength=N + 2)\\n\\nld = (D * np.arange(len(D))).cumsum()\\nud = D[::-1].cumsum()[::-1]\\n\\nX = np.arange(1, N + 1, dtype=int)\\n# L[x]: x \\u56de\\u53d6\\u308c\\u308b\\u3068\\u304d\\u306e\\u6700\\u5927\\u306e\\u9577\\u3055 k\\nL = np.zeros(N + 1, dtype=int)\\nL[X] = (ld[X] + X * ud[X + 1]) // X\\n\\ni = len(L) - 1\\nfor k in range(1, N + 1):\\n    while i > 0 and L[i] < k:\\n        i -= 1\\n    print(i)\\n\", \"from collections import Counter\\nN = int(input())\\n#C = sorted(list(Counter(map(int, input().split())).values()))\\nC = list(Counter(map(int, input().split())).values())\\nC.sort()\\n\\nrest = N\\nremoved = 0\\nfor K in range(1, N + 1):\\n    d = K - removed\\n    while C and C[- 1] > rest//d:\\n        rest -= C[- 1]\\n        C.pop()\\n        removed += 1\\n        d -= 1\\n    print(rest//d)\", \"import sys\\nstdin = sys.stdin\\n\\nni = lambda: int(ns())\\nna = lambda: list(map(int, stdin.readline().split()))\\nnn = lambda: list(stdin.readline().split())\\nns = lambda: stdin.readline().rstrip()\\n\\nimport bisect\\nfrom collections import Counter\\n\\nn = ni()\\na = na()\\n\\nc = sorted(Counter(a).values())\\ncc = [0]\\nm = len(c)\\nfor i in c:\\n    cc.append(cc[-1]+i)\\n\\ndef is_ok(k,arg):\\n    b = bisect.bisect_right(c,arg)\\n    p = cc[b] + (m-b)*arg\\n    return True if p >= arg*k else False\\n\\nfor k in range(1,n+1):\\n    if k > m:\\n        print((0))\\n        continue\\n    #\\u306b\\u3076\\u305f\\u3093\\n    ok,ng = -1,n//k+1\\n    while (abs(ok - ng) > 1):\\n        mid = (ok + ng) // 2\\n        if is_ok(k,mid):\\n            ok = mid\\n        else:\\n            ng = mid\\n    \\n    print(ok)\\n\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\na=[int(j) for j in input().split()]\\nfrom collections import Counter\\nc=Counter(a)\\nl=c.most_common()\\nll=[]\\nfor i,j in l:\\n    ll.append(j)\\nll.sort()\\ns=sum(ll)\\nrem=0\\nfor k in range(1,n+1):\\n    rest=k-rem\\n    while ll and ll[-1]>s//rest:\\n        s-=ll[-1]\\n        ll.pop()\\n        rem+=1\\n        rest-=1\\n    print((s//rest))\\n\\n\\n\\n\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nN=int(input())\\nA=list(map(int,input().split()))\\n\\nfrom collections import Counter\\nfrom itertools import accumulate\\nimport bisect\\n\\nC=Counter(A)\\n\\nLIST=sorted(C.values())\\nLEN=len(LIST)\\nSUM=[0]+list(accumulate(LIST))\\nMIN=0\\nMAX=SUM[-1]\\n\\nfor k in range(1,N+1):\\n    MIN=0\\n    while MIN!=MAX:\\n        mid=(MIN+MAX+1)//2\\n        x=bisect.bisect_right(LIST,mid)\\n\\n        if SUM[x]+(LEN-x)*mid>=mid*k:\\n            MIN=mid\\n        else:\\n            MAX=mid-1\\n\\n    print(MIN)\\n\", \"from bisect import bisect_left\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nlst = [0] * (N + 1)\\nfor a in A:\\n    lst[a - 1] += 1\\nlst.sort() #\\u983b\\u5ea6\\u5217\\n\\ns = [0] * (N + 1)\\nfor i in range(N):\\n    s[i + 1] = s[i] + lst[i + 1]\\n\\n# print (lst)\\n# print (s)\\n\\ndef check(x, k):\\n    i = bisect_left(lst, x) - 1\\n    total = x * (N - i) + s[i]\\n    return total >= x * k\\n\\nans = N\\nfor k in range(1, N + 1):\\n    while True:\\n        if check(ans, k):\\n            break\\n        ans -= 1\\n    print (ans)\\n\", \"# -*- coding: utf-8 -*-\\nfrom collections import Counter\\nfrom itertools import accumulate\\n\\nN = int(input())\\nA = list(map(int,input().split()))\\n\\nB = list(Counter(A).values())\\n\\nC = [0] * N \\nfor i in B:\\n    C[i-1] += 1\\n\\nF = list(accumulate(C))\\n\\nS = [0] * N\\nf = [0] * N\\nS[0] = f[0] = sum(C) \\nfor i in range(2, N+1):\\n    S[i-1] = (S[i-2] + C[i-1] + S[0] - F[i-1] ) \\n    f[i-1] = S[i-1] / i\\n\\nf.sort()\\nn = 0     \\nK = 1\\n    \\nwhile K != N+1:\\n    if K <= f[n]:\\n        print(N-n)\\n        K += 1\\n    else:\\n        n += 1\\n    if n == N:\\n        for i in range(N-K+1):\\n            print(0)\\n        K = N+1    \", \"import itertools\\nimport collections\\nN = int(input())\\nA = [int(_) for _ in input().split()]\\nc = sorted(collections.Counter(A).values())\\nacc = list(itertools.accumulate([0] + c))\\nn = len(acc) - 1\\nj = 0\\nfor i in range(1, n + 1):\\n    r = 0\\n    while i - j > 0:\\n        if (i - j) * c[-1 - j] <= acc[-1 - j]:\\n            r = acc[-1 - j] // (i - j)\\n            break\\n        else:\\n            j += 1\\n    print(r)\\nfor _ in range(N - n):\\n    print((0))\\n\", \"from collections import Counter\\nimport bisect\\n\\n\\ndef main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    count_list = list(Counter(A).values())\\n    count_list.sort()\\n    cumsum_count = [0] * len(count_list)\\n    cumsum_count[0] = count_list[0]\\n    for i in range(1, len(count_list)):\\n        cumsum_count[i] = cumsum_count[i - 1] + count_list[i]\\n    ans_list = [0] * N\\n    n_max = N\\n    for k in range(1, len(count_list) + 1):\\n        # \\u6700\\u5927\\u3067\\u3082 N // k \\u56de\\u307e\\u3067\\u3002\\n        # \\u5404\\u30ab\\u30fc\\u30c9 n_max \\u679a\\u307e\\u3067\\u4f7f\\u3063\\u3066 k * n_max \\u306e\\u9577\\u65b9\\u5f62\\u9818\\u57df\\u3092\\u5168\\u90e8\\u57cb\\u3081\\u5c3d\\u304f\\u305b\\u308b\\u304b\\u3092\\u8abf\\u3079\\u308b\\u3002\\n        # \\u57cb\\u3081\\u5c3d\\u304f\\u305b\\u308b\\u6700\\u5c0f\\u306e n_max \\u304c\\u7b54\\u3048\\u3002\\n        n_max = min(n_max, N // k)\\n        s = 0\\n        while True:\\n            # n_max \\u679a\\u4ee5\\u4e0a\\u3042\\u308b\\u30ab\\u30fc\\u30c9\\u306f n_max \\u679a\\u56fa\\u5b9a\\n            index = bisect.bisect_left(count_list, n_max)\\n            s = n_max * (len(count_list) - index)\\n            # \\u305d\\u308c\\u672a\\u6e80\\u306e\\u30ab\\u30fc\\u30c9\\u306f\\u305d\\u306e\\u307e\\u307e\\u5168\\u90e8\\u4f7f\\u3046\\n            if index > 0:\\n                s += cumsum_count[index - 1]\\n            if s >= k * n_max or n_max == 0:\\n                break\\n            n_max -= 1\\n        ans_list[k - 1] = n_max\\n    for ans in ans_list:\\n        print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n = int(input())\\nA = list(map(int,input().split()))\\nB = [0]*(n+1)\\nC = [0]*(n+1)\\nfor a in A:\\n    B[a] += 1\\n    C[B[a]] += 1\\n\\nX = [0]\\nfor i in range(1,n+1):\\n    X.append(X[i-1] + C[i])\\nfor j in range(1,n+1):\\n    X[j] = X[j] // j\\n\\nind = n\\nk = 1\\nwhile k<=n:\\n    if ind<0:\\n        for _ in range(n-k+1):\\n            print(0)\\n        break\\n    if k<=X[ind]:\\n        print(ind)\\n        k += 1\\n    else:\\n        ind -= 1\", \"from itertools import accumulate\\n\\nN, *A = map(int, open(0).read().split())\\n\\nC = [0] * (N + 1)\\nD = [0] * (N + 1)\\nfor a in A:\\n    C[a] += 1\\n    D[C[a]] += 1\\n\\nT = [0] + [s // i for i, s in enumerate(accumulate(D[1:]), 1)]\\n\\nans = []\\nx = N\\nfor k in range(1, N + 1):\\n    while 0 < x and T[x] < k:\\n        x -= 1\\n    ans.append(x)\\n\\nprint(\\\"\\\\n\\\".join(map(str, ans)))\", \"from collections import Counter\\nfrom bisect import bisect_left\\nfrom itertools import accumulate\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\na = list(Counter(A).values())\\na.sort()\\nb = list(accumulate(a + [0]))\\ns = sum(a)\\nlength = len(a)\\n\\nfor i in range(1, N + 1):\\n    if i == 1:\\n        print(s)\\n    elif len(a) < i:\\n        print(0)\\n    else:\\n        n = s // i\\n        for j in reversed(range(1, n + 1)):\\n            t = bisect_left(a, j)\\n            if j * i <= b[t - 1] + (length - t) * j:\\n                print(j)\\n                break\", \"def main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    # C[x]: \\u66f8\\u304b\\u308c\\u3066\\u3044\\u308b\\u6574\\u6570\\u304cx\\u3067\\u3042\\u308b\\u30ab\\u30fc\\u30c9\\u306e\\u679a\\u6570\\n    C = [0] * (N + 1)\\n    D = [0] * (N + 1)\\n    for a in A:\\n        C[a] += 1\\n        D[C[a]] += 1\\n\\n    # A\\u304b\\u3089K(1<=K<=N)\\u679a\\u305a\\u3064\\u30ab\\u30fc\\u30c9\\u3092\\u629c\\u3044\\u3066\\u3063\\u305f\\u3068\\u304d\\u306b\\u3001\\n    # x\\u56de\\u4ee5\\u4e0a\\u629c\\u304f\\u3053\\u3068\\u304c\\u3067\\u304d\\u308b\\u304b\\u5224\\u5b9a\\u3059\\u308b\\u3002\\n    # \\u629c\\u304f\\u3053\\u3068\\u304c\\u3067\\u304d\\u308b\\u3068\\u5224\\u5b9a\\u3055\\u308c\\u305fx\\u306e\\u6700\\u5927\\u5024\\u304c\\u7b54\\u3048\\u306b\\u306a\\u308b\\u3002\\n\\n    # \\u4f8b\\u3048\\u3070\\u3001A = [1 1 1 1 1 2 2 3] \\u3068\\u3059\\u308b\\u3002\\n    # -> C = [5 2 1 0 0 0 0 0]\\n    # \\u3053\\u3053\\u304b\\u30892\\u679a\\u305a\\u3064\\u30ab\\u30fc\\u30c9\\u3092\\u629c\\u3051\\u308b\\u56de\\u6570\\u3092\\u8003\\u3048\\u308b\\u3068\\u304d\\u3001\\n    # \\u300c3\\u56de\\u629c\\u304f\\u300d\\u3068\\u3059\\u308b\\u3068\\u3001\\u6570\\u5b57\\u306e1\\u306f\\u3001\\u3069\\u3046\\u3084\\u3063\\u3066\\u30822\\u500b\\u306f\\u7d76\\u5bfe\\u4f59\\u308b\\n    # \\u305d\\u3053\\u3067\\u3001\\u7d76\\u5bfe\\u4f59\\u308b\\u90e8\\u5206\\u3092\\u6368\\u3066\\u3066C\\u3092\\u4f5c\\u308a\\u76f4\\u3059(=E\\u3068\\u3059\\u308b)\\u3068\\u3001\\n    # E = [3 2 1 0 0 0 0 0]\\n    # \\u3053\\u3053\\u304b\\u30892\\u679a\\u305a\\u30643\\u56de\\u629c\\u3051\\u308b\\u304b\\u5224\\u5b9a\\u3059\\u308b\\u306a\\u3089\\u3001\\n    # sum(E) >= 2 * 3 = 6\\n    # \\u3067\\u3042\\u308b\\u304b\\u898b\\u308c\\u3070\\u3088\\u3044\\u3002\\u4eca\\u56de\\u306e\\u5834\\u5408\\u3061\\u3087\\u3046\\u30696\\u306a\\u306e\\u3067\\u30012\\u679a\\u305a\\u30643\\u56de\\u306f\\u629c\\u3051\\u308b\\u3002\\n    \\n    # 3\\u679a\\u305a\\u30642\\u56de\\u306c\\u3051\\u308b\\u304b\\u8abf\\u3079\\u308b\\u5834\\u5408\\u3001\\n    # E = [2 2 1] \\u3068\\u306a\\u308a\\u3001sum(E) = 5 < 3 * 2 = 6 \\u306a\\u306e\\u3067\\u3001\\u629c\\u3051\\u306a\\u3044\\u3053\\u3068\\u304c\\u5206\\u304b\\u308b\\n\\n    # \\u3088\\u3063\\u3066\\u3001\\n    # sum(min(C[i], x)) >= K * x \\u3067\\u3042\\u308c\\u3070\\u629c\\u304f\\u3053\\u3068\\u304c\\u3067\\u304d\\u308b\\n    # S(x) = sum(min(C[i], x)) \\u3068\\u3059\\u308b\\u3068\\u3001\\n    # S(x) = S(x-1) + [C\\u306e\\u4e2d\\u3067C[i] >= x \\u3067\\u3042\\u308b\\u3082\\u306e\\u306e\\u500b\\u6570]\\n    # \\u3068\\u306a\\u308b\\u3053\\u3068\\u304b\\u3089\\u3001C\\u306e\\u4e2d\\u3067C[i] >= x \\u3067\\u3042\\u308b\\u3082\\u306e\\u306e\\u500b\\u6570 = D(x) \\u3068\\u3059\\u308b\\u3068\\u3001\\n    # S(x) = sum_(1~x) D(i) \\u3068\\u306a\\u308b\\u3002\\n    # \\u3064\\u307e\\u308a\\u3001S(x)\\u306f\\u3001D(x) \\u3092\\u6700\\u521d\\u306b\\u5168\\u90e8\\u8a08\\u7b97\\u3057\\u3066\\u304a\\u3044\\u3066\\u3001\\u7d2f\\u7a4d\\u548c\\u3092\\u3068\\u308b\\u3053\\u3068\\u3067\\u9ad8\\u901f\\u306b\\u8a08\\u7b97\\u3067\\u304d\\u308b\\u3002\\n\\n    # S(x) >= K * x \\u3068\\u306a\\u308bx\\u306e\\u6700\\u5927\\u5024\\u3092\\u3001k\\u30921\\u304b\\u3089N\\u307e\\u3067\\u52d5\\u304b\\u3057\\u3066\\u898b\\u3064\\u3051\\u308c\\u3070\\u3088\\u3044\\u3002\\n    # \\u3053\\u3053\\u3067\\u3001x\\u3092\\u5de6\\u8fba\\u306b\\u3082\\u3063\\u3066\\u3044\\u3063\\u3066\\u3001\\n    # S(x) / x >= K\\u3068\\u306a\\u308bx\\u306e\\u6700\\u5927\\u5024\\u3092\\u898b\\u3064\\u3051\\u308b\\u3088\\u3046\\u306b\\u3059\\u308b\\u3002\\n    # \\u307e\\u305f\\u3001S(x) / x = f(x) \\u3068\\u304a\\u304f\\u3002\\n\\n    # \\u6700\\u5927\\u5024\\u3092\\u898b\\u3064\\u3051\\u308b\\u305f\\u3081\\u306b2\\u5206\\u63a2\\u7d22\\u3057\\u3066\\u3082\\u3044\\u3044\\u304c\\u3001\\n    # K\\u304c\\u5897\\u3048\\u308b\\u3068\\u3001\\u7b54\\u3048\\u306f\\u4ee5\\u524d\\u306e\\u5024\\u4ee5\\u4e0b\\u306b\\u306a\\u308b\\u306f\\u305a\\u306a\\u306e\\u3067\\u3001\\n    # K+1\\u306e\\u3068\\u304d\\u3001K\\u3067\\u306e\\u7b54\\u3048\\u306e\\u4f4d\\u7f6e\\u304b\\u30890\\u3078\\u3068\\u63a2\\u7d22\\u3057\\u3066\\u3044\\u3051\\u3070\\u3001O(N)\\u3067\\u7b54\\u3048\\u304c\\u898b\\u3064\\u304b\\u308b\\n    S = [0] * (N + 1)\\n    f = [0] * (N + 1)\\n    for x in range(1, N+1):\\n        S[x] = S[x-1] + D[x]\\n        f[x] = S[x] // x\\n\\n    ans = []\\n    prev_ans = N\\n    for K in range(1, N+1):\\n        a = prev_ans\\n        while True:\\n            if f[a] >= K or a == 0:\\n                break\\n            a -= 1\\n        ans.append(a)\\n        prev_ans = a\\n\\n    print(*ans, sep='\\\\n')\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"def main():\\n    from sys import stdin\\n    input = stdin.readline\\n    from collections import Counter as ct\\n    from bisect import bisect_left as bl\\n\\n    n = int(input())\\n    max_a = sorted(ct(list(map(int, input().split()))).values())\\n    now_a = [i for i in max_a]\\n    m = len(max_a)\\n    cnt = m\\n    ans = 0\\n    ans_list = [0]*(n-m)\\n\\n    for use in range(m, 1, -1):\\n        rest = ans\\n        nex = now_a[0]\\n        while rest:\\n            val = nex\\n            start = bl(now_a, val+1)\\n            nex += 1\\n            q = max(-1, start-1-rest, bl(max_a, now_a[start-1]+1)-1)\\n            for i in range(start-1, q, -1):\\n                now_a[i] += 1\\n            if now_a[start-1] == 1:\\n                cnt += start-1-q\\n            rest -= start-1-q\\n            if start != m:\\n                nex = now_a[start]\\n        while cnt >= use:\\n            ans += 1\\n            rest = use\\n            nex = now_a[-1]\\n            end = m\\n            while rest:\\n                val = nex\\n                start = bl(now_a, val)\\n                if start != 0:\\n                    nex = now_a[start-1]\\n                end = min(end, bl(now_a, val+1), start+rest)\\n                for i in range(start, end):\\n                    now_a[i] -= 1\\n                if now_a[start] == 0:\\n                    cnt -= end-start\\n                rest -= end-start\\n                end = start\\n        ans_list.append(ans)\\n    print(n)\\n    for i in ans_list[::-1]:\\n        print(i)\\n\\n\\nmain()\", \"N = int(input())\\nA = list(map(int,input().split()))\\nC = [0] * (N + 1)\\nfor a in A:\\n    C[a] += 1\\nD = [0] * (N + 1)\\nfor c in C:\\n    D[c] += 1\\nP = [0] * (N + 1)\\nQ = [0] * (N + 1)\\nfor i in range(1, N+1):\\n    P[i] = P[i-1] + i * D[i]\\n    Q[i] = Q[i-1] + D[i]\\nF = [0] * (N + 1)\\nfor i in range(1, N+1):\\n    F[i] = int((P[i] + i * (Q[N] - Q[i])) / i)\\nindex = N\\nfor i in range(1, N+1):\\n    while True:\\n        if index == 0:\\n            print(0)\\n            break\\n        if F[index] >= i:\\n            print(index)\\n            break\\n        else:\\n            index -= 1\", \"from collections import defaultdict\\nfrom bisect import bisect\\nN = int(input())\\nA = list(map(int,input().split()))\\n\\nd = defaultdict(lambda:0)\\n\\nfor i in range(N):\\n    d[A[i]] += 1\\n\\nC = [0]*(N+1)\\n\\nfor i in d:\\n    C[d[i]] += 1\\n\\nC1 = [0]*(N+1)\\nC2 = [0]*(N+1)\\n\\nfor i in range(N):\\n    C1[i+1] = C1[i] + (i+1)*C[i+1]\\n    C2[i+1] = C2[i] + C[i+1]\\n\\nl = [0]*N\\nfor n in range(N):\\n    l[n] = C1[n+1]//(n+1)+C2[N]-C2[n+1]\\n    l[n] *= -1\\n\\n\\nfor i in range(N):\\n    print(bisect(l,-(i+1)))\", \"\\nN = int(input())\\n\\nA = list(map(int,input().split()))\\n\\ndic = {}\\n\\nfor a in A:\\n\\n    if a not in dic:\\n        dic[a] = 1\\n    else:\\n        dic[a] += 1\\n\\nB = []\\nfor i in dic:\\n    B.append(dic[i])\\n\\nB.sort()\\n\\nB_sub = B.copy()\\n\\nfor i in range(len(B)-1):\\n    B_sub[i+1] += B_sub[i] \\n\\naind = N + 1\\nnind = len(B) - 1\\n\\n#print (B,B_sub)\\n\\nfor i in range(N):\\n\\n    i += 1\\n\\n    while True:\\n\\n        while nind > 0 and B[nind] > aind - 1:\\n\\n          nind -= 1\\n\\n        if i > len(B):\\n            print((0))\\n            break\\n\\n        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:\\n            print((aind - 1))\\n            break\\n\\n        aind -= 1\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\nnum = [0 for _ in range(N)]\\nfor a in A:\\n    num[a-1] += 1\\nnum.sort()\\ncum = [0 for _ in range(N)]\\ncum[0] = num[0]\\nfor i in range(1, N):\\n    cum[i] = cum[i-1] + num[i]\\n\\nindex = N - 1\\nans = N\\nfor k in range(1, N+1):\\n    while ans > 0:\\n        tmp_index = index\\n        while tmp_index >= 0 and num[tmp_index] > ans:\\n            tmp_index -= 1\\n        decided = N - tmp_index - 1\\n        rest_total = 0 if tmp_index < 0 else cum[tmp_index]\\n        if rest_total >= ans * (k - decided):\\n            index = tmp_index\\n            break\\n        ans -= 1\\n    print(ans)\", \"import sys\\nfrom collections import Counter\\n\\nsys.setrecursionlimit(10 ** 6)\\ninput = sys.stdin.readline\\n\\ndef main():\\n    n = int(input())\\n    aa = list(map(int, input().split()))\\n    aa = list(Counter(aa).values())\\n    aa.sort()\\n    cs = [0]\\n    s = 0\\n    for a in aa:\\n        s += a\\n        cs += [s]\\n    # print(aa)\\n    # print(cs)\\n    ans = n + 1\\n    i = len(aa)\\n    for k in range(1, n + 1):\\n        while 1:\\n            while i > 0 and aa[i - 1] >= ans:\\n                i -= 1\\n            s = cs[i] + ans * (len(aa) - i)\\n            if s >= ans * k:\\n                break\\n            else:\\n                ans -= 1\\n        print(ans)\\n\\nmain()\\n\", \"N=int(input())\\nA=list(map(int,input().split()))\\n\\nc = [0] * (N + 1)\\nDx = [0] * (N + 1)\\nfor a in A:\\n    c[a] += 1 #c\\u306f\\u3001a\\u3068\\u3044\\u3046\\u6570\\u304c\\u51fa\\u305f\\u56de\\u6570\\u3092\\u8a18\\u9332\\n    Dx[c[a]]+=1\\n    #Dx\\u306f\\u3001\\u305d\\u306e\\u56de\\u6570\\u306e\\u3068\\u3053\\u308d\\u306b\\u7a2e\\u985e\\u3092\\u8a18\\u9332\\u3002\\u8ce2\\u3044\\u3002\\n\\nSx=[0]#\\u521d\\u9805\\u306f0\\nfor j in range(1,N+1):\\n    Sx.append(Sx[j-1]+Dx[j])\\n#\\u89e3\\u6cd52\\u3092\\u771f\\u4f3c\\u3057\\u3066\\u307f\\u308b\\u3002\\nfor h in range(1,N+1):\\n    Sx[h]=Sx[h]/h\\n\\nx=N\\nk=1\\nwhile k<N+1:\\n    if x<0:\\n        for _ in range(N-k+1):\\n            print((0))\\n        return\\n    if k<=Sx[x]:\\n        print(x)\\n        k+=1\\n    else:\\n        x-=1\\n\", \"from collections import Counter\\n\\nN = int(input())\\nAs = list(map(int, input().split()))\\n\\ncntA = Counter(As)\\ncntCntA = Counter(list(cntA.values()))\\n\\naccDs = [cntCntA[0]]\\nfor i in range(1, N+1):\\n    accDs.append(accDs[-1] + cntCntA[i])\\n\\naccKDs = [0]\\nfor i in range(1, N+1):\\n    accKDs.append(accKDs[-1] + i*cntCntA[i])\\n\\nfXs = [0]\\nfor X in range(1, N+1):\\n    fXs.append((accKDs[X] + X*(accDs[N]-accDs[X])) // X)\\n\\nanss = [0] * (N+1)\\nfor X, fX in enumerate(fXs):\\n    anss[fX] = X\\n\\nfor i in reversed(list(range(N))):\\n    if anss[i] == 0:\\n        anss[i] = anss[i+1]\\n\\nprint(('\\\\n'.join(map(str, anss[1:]))))\\n\", \"from bisect import bisect_left\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nlst = [0] * (N)\\nfor a in A:\\n    lst[a - 1] += 1\\nlst.sort() #\\u983b\\u5ea6\\u5217\\n\\ns = [0] * (N + 1)\\nfor i in range(N):\\n    s[i + 1] = s[i] + lst[i]\\n\\n# print (lst)\\n# print (s)\\n\\n# def check(x, k):\\n#     i = bisect_left(lst, x) - 1\\n#     total = x * (N - i) + s[i]\\n#     return total >= x * k\\n\\n\\nans = N\\ni = N\\nfor k in range(1, N + 1):\\n    while True:\\n        while  i >= 1 and lst[i - 1] >= ans:\\n            i -= 1\\n        total = ans * (N - i) + s[i]\\n        if total >= ans * k:\\n            break\\n        ans -= 1\\n    # print ('i =', i)\\n    print (ans)\\n\", \"from collections import Counter\\nN = int(input())\\nC = sorted(list(Counter(list(map(int, input().split()))).values()))\\n\\nrest = N\\nremoved = 0\\nfor K in range(1, N + 1):\\n    d = K - removed\\n    while C and C[- 1] > rest//d:\\n        rest -= C[- 1]\\n        C.pop()\\n        removed += 1\\n        d -= 1\\n    print((rest//d))\\n\"]",
        "difficulty": "interview",
        "input": "5\n1 2 3 4 5\n",
        "output": "5\n2\n1\n1\n1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://atcoder.jp/contests/abc143/tasks/abc143_f"
    },
    {
        "id": 1966,
        "task_id": 2476,
        "test_case_id": 3,
        "question": "Takahashi has N cards. The i-th of these cards has an integer A_i written on it.\nTakahashi will choose an integer K, and then repeat the following operation some number of times:\n - Choose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)\nFor each K = 1,2, \\ldots, N, find the maximum number of times Takahashi can do the operation.\n\n-----Constraints-----\n -  1 \\le N \\le 3 \\times 10^5 \n -  1 \\le A_i \\le N \n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\nA_1 A_2 \\ldots A_N\n\n-----Output-----\nPrint N integers.\nThe t-th (1 \\le t \\le N) of them should be the answer for the case K=t.\n\n-----Sample Input-----\n3\n2 1 2\n\n-----Sample Output-----\n3\n1\n0\n\nFor K = 1, we can do the operation as follows:\n - Choose the first card to eat.\n - Choose the second card to eat.\n - Choose the third card to eat.\nFor K = 2, we can do the operation as follows:\n - Choose the first and second cards to eat.\nFor K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.",
        "solutions": "[\"N = int(input())\\nA = list(map(int,input().split()))\\nfrom collections import Counter\\nfrom bisect import bisect\\nvs = list(Counter(A).values())\\nvs.sort()\\ncums = [0]\\nfor v in vs:\\n    cums.append(cums[-1] + v)\\n\\ndef is_ok(k,m):\\n    j = bisect(vs,m)\\n    z = cums[j] + m*(len(vs)-j)\\n    return z >= m*k\\n\\nans = []\\nfor k in range(1,N+1):\\n    if k > len(vs):\\n        ans.append(0)\\n    else:\\n        ok = 0\\n        ng = N//k + 1\\n        while ng-ok > 1:\\n            m = (ok+ng)//2\\n            if is_ok(k,m):\\n                ok = m\\n            else:\\n                ng = m\\n        ans.append(ok)\\n\\nprint(*ans, sep='\\\\n')\", \"from collections import Counter\\nimport bisect\\nN=int(input())\\nA=list(map(int,input().split()))\\nC=list(Counter(A).values())\\nC.sort()\\nL=len(C)\\n\\n# C\\u306e\\u3046\\u3061x\\u4ee5\\u4e0a\\u306e\\u3082\\u306e\\u306e\\u500b\\u6570D[x]\\u3092\\u8a08\\u7b97(x=0,...,N)\\nD=[L-bisect.bisect_left(C,x) for x in range(N+1)]\\nS=[0]\\nfor n in range(1,N+1):\\n    S.append(S[-1]+D[n])\\n\\n# T[x]=S[x]/x(x=1,...,N)\\u3068\\u3057\\u3066K\\u3092bisect_right\\u3067\\u633f\\u5165\\u3057\\u305f\\u6642\\u306eindex\\u304c\\u7b54\\u3048\\nT=[x/S[x] for x in range(1,N+1)]\\nfor K in range(1,N+1):\\n    print(bisect.bisect_right(T,1/K))\", \"from collections import Counter\\nfrom bisect import bisect_left\\nfrom itertools import accumulate\\n\\n# https://betrue12.hateblo.jp/entry/2019/10/20/001106\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\na = list(Counter(A).values())\\na.sort()\\nb = list(accumulate(a))\\nlength = len(a)\\n\\nfor i in range(1, N + 1):\\n    if i == 1:\\n        print(b[-1])\\n    elif len(a) < i:\\n        print(0)\\n    else:\\n        n = b[-1] // i\\n        for j in reversed(range(1, n + 1)):\\n            t = bisect_left(a, j)\\n            if j * i <= b[t - 1] + (length - t) * j:\\n                print(j)\\n                break\", \"from collections import Counter\\nfrom itertools import accumulate\\nn = int(input())\\nA = tuple(map(int, input().split()))\\nC = Counter(A)\\nD = [0]*(n+1)\\nfor v in C.values():\\n  D[v] += 1\\nE = tuple(accumulate(k*d for k, d in enumerate(D)))\\nD = tuple(accumulate(D))\\nF = [0]*(n+1)\\nfor x in range(1, n+1):\\n  temp = (E[x] + x*(D[n]-D[x])) // x\\n  F[x] = temp\\nfor k in range(1, n+1):\\n  ok = 0\\n  ng = n+1\\n  while ng-ok > 1:\\n    mid = (ok+ng)//2\\n    if k <= F[mid]:\\n      ok = mid\\n    else:\\n      ng = mid\\n  print(ok)\", \"from collections import Counter\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nc = Counter(a)\\nd = Counter(c.values())\\n\\ndx = [0 for _ in range(n+1)]\\nfor i in range(1, n+1):\\n\\tdx[i] = dx[i-1] + i*d[i]\\n\\nxdx = [0 for _ in range(n+2)]\\nxdx[n] = d[n]\\nfor i in range(n-1, 0, -1):\\n\\txdx[i] = xdx[i+1] + d[i]\\n\\nres = [0] + [(dx[i] + i*xdx[i+1]) // i for i in range(1, n+1)]\\nans = [0 for _ in range(n)]\\ncur = n\\nfor i in range(n):\\n\\twhile cur > 0 and res[cur] < i+1:\\n\\t\\tcur -= 1\\n\\tif cur > 0:\\n\\t\\tans[i] = cur\\nprint(*ans, sep=\\\"\\\\n\\\")\", \"N = int(input())\\nA = list(map(int, input().split()))\\nC = [0]*N\\nfor a in A:\\n    C[a - 1] += 1\\nD = [0]*(N + 1)\\nfor c in C:\\n    D[c] += 1\\n\\nDk_accum = [0]*(N + 1)\\nfor i in range(1, N + 1):\\n    Dk_accum[i] = Dk_accum[i - 1] + i*D[i]\\n    \\nD_sum = sum(D)\\nD_accum = [0]*(N + 2)\\nD_accum[0] = D_sum\\nfor i in range(1, N + 1):\\n    D_accum[i] = D_accum[i - 1] - D[i - 1]\\n    \\nF = [0]*(N + 1)\\nfor i in range(1, N + 1):\\n    F[i] = (Dk_accum[i]//i + D_accum[i + 1])\\n\\ni = N\\nfor K in range(1, N + 1):\\n    while i > 0 and K > F[i]:\\n        i -= 1\\n    print(i)\\n\", \"# coding: utf-8\\n# Your code here!\\ndef f(m,k):#\\u6700\\u521d\\u306em\\u500b, k\\u305a\\u3064\\n    if m == 0: return 0\\n    if m < k: return 0\\n#    if (m,k) in memo:\\n#        return memo[(m,k)]\\n    z = 0\\n    if acc[m]//k >= c[m]:\\n        return acc[m]//k\\n    else:\\n        return f(m-1,k-1)\\n\\n\\nimport sys\\n#sys.setrecursionlimit(10**6)\\nreadline = sys.stdin.readline \\n\\nfrom itertools import accumulate\\n\\nn = int(input())\\na = [int(i) for i in readline().split()]\\n\\nres = [0]*(n+1)\\nfor i in a: res[i] += 1\\n\\nc = [0]\\nfor i in res:\\n    if i > 0: c.append(i)\\nc.sort()#reverse=True)\\n\\nl = len(c)-1\\n#print(c)\\nacc = list(accumulate(c))\\n\\n#print(acc,c)\\nres = [n]+[acc[m]//c[m] for m in range(1,l+1)]\\n\\n\\n#print(l,res)\\n\\n\\nm = l\\nfor k in range(1,n+1):\\n    k -= l-m\\n    if res[m] >= k:\\n        print((acc[m]//k))\\n    else:\\n#        print(k,m)\\n        while res[m] < k:\\n            m -= 1\\n            k -= 1\\n        print((acc[m]//(k)))\\n\\n\\n\\n\\n\\n\", \"import sys\\ninput = sys.stdin.readline\\nfrom collections import Counter\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nC = sorted(list(Counter(A).values()), reverse=True)\\nL = len(C)\\nB = []\\n\\nnum = C[0]\\nfor i, c in enumerate(C):\\n    for _ in range(num-c):\\n        B.append(i)\\n    num = c\\nfor _ in range(num):\\n    B.append(L)\\n\\nans = [N]\\nfor n in range(2, N+1):\\n    if n > L:\\n        ans.append(0)\\n        continue\\n    count = 0\\n    stack = []\\n    for b in B:\\n        tmp = b\\n        while stack:\\n            if tmp >= n:\\n                last = stack.pop()\\n                tmp = tmp + last - n\\n                count += 1\\n            else:\\n                break\\n        count += tmp//n\\n        stack.append(tmp%n)\\n    ans.append(count)\\n\\nprint(*ans, sep='\\\\n')\", \"from collections import Counter\\nn = int(input())\\na = list(map(int, input().split()))\\nc = list(Counter(a).values())\\nc.sort()\\n\\nans = n\\ncnt = 0\\nfor i in range(n):\\n    m = i + 1 - cnt\\n    while c and c[-1] > ans // m:\\n        ans -= c.pop()\\n        cnt += 1\\n        m -= 1\\n    print(ans // m)\", \"import os\\nimport sys\\n\\nimport numpy as np\\n\\nif os.getenv(\\\"LOCAL\\\"):\\n    sys.stdin = open(\\\"_in.txt\\\", \\\"r\\\")\\n\\nsys.setrecursionlimit(2147483647)\\nINF = float(\\\"inf\\\")\\nIINF = 10 ** 18\\nMOD = 10 ** 9 + 7\\n\\n# \\u89e3\\u8aacAC\\n# https://twitter.com/maspy_stars/status/1185552225474498560\\nN = int(sys.stdin.readline())\\nA = list(map(int, sys.stdin.readline().split()))\\n\\nC = list(np.bincount(A).tolist())\\nC.sort()\\ndeleted = 0\\nS = N\\n\\n\\ndef solve(k):\\n    nonlocal S, deleted\\n\\n    k -= deleted\\n    while k > 0 and C[-1] > S // k:\\n        S -= C.pop()\\n        deleted += 1\\n        k -= 1\\n    if k > 0:\\n        return S // k\\n    return 0\\n\\n\\nfor k in range(1, N + 1):\\n    print((solve(k)))\\n\", \"N = int(input())\\n \\nA = list(map(int,input().split()))\\n \\ndic = {}\\n \\nfor a in A:\\n \\n    if a not in dic:\\n        dic[a] = 1\\n    else:\\n        dic[a] += 1\\n \\nB = []\\nfor i in dic:\\n    B.append(dic[i])\\n \\nB.sort()\\n \\nB_sub = B.copy()\\n \\nfor i in range(len(B)-1):\\n    B_sub[i+1] += B_sub[i] \\n \\naind = N + 1\\nnind = len(B) - 1\\n \\n#print (B,B_sub)\\n \\nfor i in range(N):\\n \\n    i += 1\\n \\n    while True:\\n \\n        while nind > 0 and B[nind] > aind - 1:\\n \\n          nind -= 1\\n \\n        if i > len(B):\\n            print (0)\\n            break\\n \\n        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:\\n            print (aind - 1)\\n            break\\n \\n        aind -= 1\", \"import collections\\nimport numpy as np\\n\\n# \\u30ea\\u30b9\\u30c8arr\\u304b\\u3089x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u3092\\u53d6\\u308a\\u51fa\\u3059\\u6642\\u306e\\u6700\\u5927\\u306e\\u9577\\u3055\\n# \\u767a\\u60f3: x\\u500b\\u53d6\\u308a\\u51fa\\u3059\\u6642\\u3001\\u3042\\u308b\\u6587\\u5b57\\u3092x\\u500b\\u3088\\u308a\\u591a\\u304f\\u53d6\\u308a\\u51fa\\u3057\\u3066\\u5217\\u306b\\u542b\\u3080\\u3053\\u3068\\u306f\\u306a\\u3044\\n#       \\u4e00\\u65b9\\u3042\\u308b\\u6587\\u5b57\\u3092\\u305d\\u306e\\u6587\\u5b57\\u304c\\u3042\\u308b\\u6570\\u3088\\u308a\\u3082\\u53d6\\u308a\\u51fa\\u3057\\u3066\\u4f7f\\u3046\\u3053\\u3068\\u3082\\u3067\\u304d\\u306a\\u3044\\n#       \\u3064\\u307e\\u308a\\u3001min(arr.count(a), x)\\u3067\\u3001x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u306b\\u4f7f\\u3048\\u308ba\\u306e\\u6570\\u304c\\u308f\\u304b\\u308b\\n#       \\u3055\\u3089\\u306b\\u3001sum(min(arr.count(a),x))\\u3067\\u3001x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u306b\\u4f7f\\u3048\\u308b\\u6587\\u5b57\\u306e\\u6570\\u304c\\u308f\\u304b\\u308b\\n#       \\u3088\\u3063\\u3066\\u3001sum(min(arr.count(a),x))//x\\u3067\\u3001x\\u500b\\u306e\\u540c\\u3058\\u9577\\u3055\\u306e\\u5217\\u306e\\u9577\\u3055\\u304c\\u308f\\u304b\\u308b\\n#       \\u767a\\u5c55\\u7684\\u306b\\u3001longest(arr,x)\\u307e\\u3067\\u306e\\u8a08\\u7b97\\u72b6\\u6cc1\\u304b\\u3089longest(arr,x+1)\\u304c\\u8a08\\u7b97\\u3067\\u304d\\u308b\\n# def longest(arr, x):    # legacy\\n#     return sum(min(arr.count(a), x) for a in arr) // x\\n\\n\\nn = int(input())\\na = list(map(int, input().split()))\\n\\ncounter = collections.Counter(a)        #O(n)\\nnums = list(counter.values())           #O(n)\\nnum_counter = collections.Counter(nums) #O(n)\\nlastest_add = np.count_nonzero(nums)    #O(n)\\nbuilding, longests = [0], [0]\\nfor i in range(1, n+1):                 #O(n)\\n    appended = building[-1] + lastest_add   #O(1)\\n    building.append(appended)               #O(1)\\n    longests.append(appended // i)          #O(1)\\n    lastest_add -= num_counter[i]           #O(1)\\n\\n\\nlastest_longest = 0\\nk_most = []\\nfor i, x in enumerate(reversed(longests)):\\n    while x > lastest_longest:\\n        lastest_longest += 1\\n        k_most.append(n-i)\\n\\nk_most.extend([0]*(n-len(k_most)))      # zero padding\\n\\nfor longests_num in k_most:\\n    print(longests_num)\\n\\n# print('----------------')\\n# for k in range(1, n+1):\\n#     maxindexes = list(i for i, x in enumerate(longests) if x >= k)\\n#     if maxindexes:\\n#         print(maxindexes[-1])\\n#     else:\\n#         print(0)\\n\", \"import bisect\\n\\nn = int(input())\\nA = list(map(int, input().split()))\\ncounts = [0]*(n)\\nfor a in A:\\n    counts[a-1] += 1\\ncounts.sort()\\n\\ncumsum = []\\nnum = 0\\nfor count in counts:\\n    num += count\\n    cumsum.append(num)\\n\\nanswers = [0]*(n)\\nfor i in range(1, n+1):\\n    idx = bisect.bisect_right(counts, i)\\n    left = cumsum[idx-1]\\n    right = (n-idx)*i\\n    K = (right+left)//i\\n    answers[K-1] = i\\n\\nnow = 0\\nfor i in range(n-1, -1, -1):\\n    if answers[i] == 0:\\n        answers[i] = now\\n    now = answers[i]\\n\\nfor ans in answers:\\n    print(ans)\", \"def main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    C = [0] * (N+1)\\n    Cnt_A = [0] * (N+1)\\n    for a in A:\\n        Cnt_A[a] += 1\\n        cnt = Cnt_A[a]\\n        C[cnt] += 1\\n    cum_C = []\\n    cu = 0\\n    for c in C:\\n        cu += c\\n        cum_C.append(cu)\\n    Ans = []\\n    for k in range(1, N+1):\\n        # K = k \\u306e\\u3068\\u304d\\u3001 n \\u7d44\\u4ee5\\u4e0a\\u4f5c\\u308c\\u308b <=> \\u4f7f\\u3048\\u308b\\u30ab\\u30fc\\u30c9\\u304c nk \\u679a\\u4ee5\\u4e0a\\n        # n \\u7d44\\u4ee5\\u4e0a\\u4f5c\\u308c\\u308b <=> \\u540c\\u3058\\u30ab\\u30fc\\u30c9\\u306f n \\u679a\\u4ee5\\u4e0b\\n        # \\u540c\\u3058\\u30ab\\u30fc\\u30c9\\u306f n \\u679a\\u4ee5\\u4e0b\\u3067\\u5168\\u4f53\\u3068\\u3057\\u3066 nk \\u679a\\u4ee5\\u4e0a\\u7528\\u610f\\u3067\\u304d\\u308b\\u304b\\uff1f\\n        ok, ng = 0, N//k+1\\n        while ok + 1 < ng:\\n            n = ok+ng>>1\\n            if cum_C[n] >= n*k:\\n                ok = n\\n            else:\\n                ng = n\\n        Ans.append(ok)\\n    print((\\\"\\\\n\\\".join(map(str, Ans))))\\n\\nmain()\\n\", \"n = int(input())\\narr = list(map(int,input().split()))\\n\\nfrom collections import Counter\\nc = Counter(arr)\\nc = list(c.values())\\nc.sort()\\ns = n\\n\\nsol = []\\nremoved = 0\\nfor k in range(1,n+1):\\n    rest = k - removed\\n    while c and c[-1] > s//rest:\\n        s -= c[-1]\\n        c.pop()\\n        rest -= 1\\n        removed += 1\\n    sol.append(s//rest)\\n\\nprint(\\\"\\\\n\\\".join(map(str,sol)))\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\nC = [0] * N\\nD = [0] * (N + 1)\\nfor a in A:\\n    C[a - 1] += 1\\n    D[C[a - 1]] += 1\\n\\nS = [0] * (N + 1)\\nfor i in range(N):\\n    S[i + 1] = S[i] + D[i + 1]\\n\\nans = N\\nfor K in range(1, N + 1):\\n    while ans > 0 and S[ans] < K * ans:\\n        ans -= 1\\n    print(ans)\", \"#!/usr/bin/env python3\\nimport sys\\nimport collections\\n\\ndef solve(N: int, A: \\\"List[int]\\\"):\\n    counter = sorted(list(collections.Counter(A).values()),reverse=True)\\n    c_index = 0\\n    k=0\\n    for i in range(1,N+1):\\n        k+=1\\n        if len(counter)<i:\\n            print((0))\\n            continue\\n        while counter[c_index]*k > N and c_index<len(counter)-1:\\n            N-=counter[c_index]\\n            c_index+=1\\n            k-=1\\n        print((N//k))\\n    return\\n\\ndef main():\\n    def iterate_tokens():\\n        for line in sys.stdin:\\n            for word in line.split():\\n                yield word\\n    tokens = iterate_tokens()\\n    N = int(next(tokens))  # type: int\\n    A = [int(next(tokens)) for _ in range(N)]  # type: \\\"List[int]\\\"\\n    solve(N, A)\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools\\nimport time,random\\n\\nsys.setrecursionlimit(10**7)\\ninf = 10**20\\neps = 1.0 / 10**10\\nmod = 10**9+7\\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\\n\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]\\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\\ndef LS(): return sys.stdin.readline().split()\\ndef I(): return int(sys.stdin.readline())\\ndef F(): return float(sys.stdin.readline())\\ndef S(): return input()\\ndef pf(s): return print(s, flush=True)\\ndef pe(s): return print(str(s), file=sys.stderr)\\ndef JA(a, sep): return sep.join(map(str, a))\\ndef JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)\\n\\n\\ndef main():\\n    n = I()\\n    c = sorted(collections.Counter(LI()).values(), reverse=True) + [0]\\n    ci = 0\\n    t = n\\n    r = [0]\\n    for i in range(n,0,-1):\\n        while c[ci] > i:\\n            ci += 1\\n        t -= ci\\n        r.append(t // i)\\n\\n    rr = []\\n    r.reverse()\\n    ri = 0\\n    for i in range(n,0,-1):\\n        while r[ri] >= i:\\n            ri += 1\\n        rr.append(ri)\\n\\n    rr.reverse()\\n\\n    return JA(rr,\\\"\\\\n\\\")\\n\\n\\nprint(main())\\n\\n\\n\", \"from collections import Counter\\nN = int(input())\\nC = sorted(list(Counter(list(map(int, input().split()))).values()))\\n\\nrest = N\\nremoved = 0\\nfor K in range(1, N + 1):\\n    d = K - removed\\n    while C and C[- 1] > rest//d:\\n        rest -= C[- 1]\\n        C.pop()\\n        removed += 1\\n        d -= 1\\n    print((rest//d))\\n\", \"# F - Distinct Numbers\\nfrom bisect import bisect_left\\n\\ndef isOK(c, k, N, L, cum_sum):\\n    i = bisect_left(L, c)\\n    s = c * (N - i) + cum_sum[i];\\n    return (s >= c * k)\\n\\nN = int(input())\\nD = list(map(int, input().split()))\\nfreq = [0] * N\\nfor d in D:\\n    freq[d - 1] += 1\\n    \\nfreq.sort()\\ncum_sum = [0] * (N + 1)\\nfor i in range(N):\\n    cum_sum[i + 1] = cum_sum[i] + freq[i]\\n    \\nfor k in range(1, N + 1):\\n    l = 0\\n    r = int(N / k) + 1\\n    while l + 1 < r:\\n        c = int((l + r) / 2)\\n        ok = isOK(c, k, N, freq, cum_sum)\\n        if ok:\\n            l = c\\n        else:\\n            r = c\\n    print(l)\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nfrom collections import Counter\\nfrom itertools import accumulate\\nfrom math import floor\\nfrom bisect import bisect_left\\n\\n\\ndef main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n\\n    c = Counter(a)\\n    c = list(c.values())\\n\\n    d = Counter(c)\\n    d_li = [0] * (n + 1)\\n    for k, v in list(d.items()):\\n        d_li[k] = v\\n\\n    dk_acm = list(accumulate(d_li))\\n\\n    kdk_acm = [0]\\n    for k, e in enumerate(d_li[1:], 1):\\n        kdk_acm.append(kdk_acm[-1] + k * e)\\n\\n    def f(x):\\n        kdk_sm = kdk_acm[x]\\n        dk_sm = dk_acm[n] - dk_acm[x]\\n\\n        return floor((kdk_sm + x * dk_sm) / x)\\n\\n    fs = [float(\\\"inf\\\")] + [f(x) for x in range(1, n + 1)]\\n    fs = fs[::-1]\\n\\n    for k in range(1, n + 1):\\n        print((n - bisect_left(fs, k)))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys \\nimport collections as cl\\n\\n\\nN=int(input())\\nA=list(map(int,sys.stdin.readline().split()))\\nc=cl.Counter(A)\\nNumberTupleList=c.most_common()\\nNumberList=[x[1] for x in NumberTupleList[::-1]]\\nLengthOfNumberList=len(NumberList)\\nFormulaList=[0 for i in range(N)]\\nflag=0\\nS=sum(NumberList)\\nfor x in range(1,N+1):\\n    while flag<LengthOfNumberList and NumberList[flag]<=x:\\n        flag+=1\\n    if flag<LengthOfNumberList:\\n        FormulaList[x-1]=(sum(NumberList[:flag])+x*(LengthOfNumberList-flag))/x\\n    else:\\n        FormulaList[x-1]=S/x\\npin=N-1\\nfor K in range(1,N+1):\\n    while pin>=0 and K>FormulaList[pin]:\\n        pin-=1\\n    print((pin+1))\\n\\n\", \"from bisect import bisect_left\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nlst = [0] * (N + 1)\\nfor a in A:\\n    lst[a - 1] += 1\\nlst.sort() #\\u983b\\u5ea6\\u5217\\n\\ns = [0] * (N + 1)\\nfor i in range(N):\\n    s[i + 1] = s[i] + lst[i + 1]\\n\\n# print (lst)\\n# print (s)\\n\\ndef check(x, k):\\n    i = bisect_left(lst, x) - 1\\n    total = x * (N - i) + s[i]\\n    return total >= x * k\\n\\n\\nfor k in range(1, N + 1):\\n    l = 0 #OK\\n    r = N // k + 1 #NG\\n    while l + 1 < r:\\n        c = (l + r) // 2\\n        if check(c, k):\\n            l = c\\n        else:\\n            r = c\\n    print (l)\\n\", \"import os\\nimport sys\\n\\nimport numpy as np\\n\\nif os.getenv(\\\"LOCAL\\\"):\\n    sys.stdin = open(\\\"_in.txt\\\", \\\"r\\\")\\n\\nsys.setrecursionlimit(2147483647)\\nINF = float(\\\"inf\\\")\\nIINF = 10 ** 18\\nMOD = 10 ** 9 + 7\\n\\n# \\u89e3\\u8aacAC\\n# https://img.atcoder.jp/abc143/editorial.pdf\\nN = int(sys.stdin.readline())\\nA = list(map(int, sys.stdin.readline().split()))\\n\\nA = np.array(A, dtype=int)\\nC = np.bincount(A, minlength=N + 2)\\nD = np.bincount(C, minlength=N + 2)\\n\\nld = (D * np.arange(len(D))).cumsum()\\nud = D[::-1].cumsum()[::-1]\\n\\nX = np.arange(1, N + 1, dtype=int)\\n# L[x]: x \\u56de\\u53d6\\u308c\\u308b\\u3068\\u304d\\u306e\\u6700\\u5927\\u306e\\u9577\\u3055 k\\nL = np.zeros(N + 1, dtype=int)\\nL[X] = (ld[X] + X * ud[X + 1]) // X\\n\\ni = len(L) - 1\\nfor k in range(1, N + 1):\\n    while i > 0 and L[i] < k:\\n        i -= 1\\n    print(i)\\n\", \"from collections import Counter\\nN = int(input())\\n#C = sorted(list(Counter(map(int, input().split())).values()))\\nC = list(Counter(map(int, input().split())).values())\\nC.sort()\\n\\nrest = N\\nremoved = 0\\nfor K in range(1, N + 1):\\n    d = K - removed\\n    while C and C[- 1] > rest//d:\\n        rest -= C[- 1]\\n        C.pop()\\n        removed += 1\\n        d -= 1\\n    print(rest//d)\", \"import sys\\nstdin = sys.stdin\\n\\nni = lambda: int(ns())\\nna = lambda: list(map(int, stdin.readline().split()))\\nnn = lambda: list(stdin.readline().split())\\nns = lambda: stdin.readline().rstrip()\\n\\nimport bisect\\nfrom collections import Counter\\n\\nn = ni()\\na = na()\\n\\nc = sorted(Counter(a).values())\\ncc = [0]\\nm = len(c)\\nfor i in c:\\n    cc.append(cc[-1]+i)\\n\\ndef is_ok(k,arg):\\n    b = bisect.bisect_right(c,arg)\\n    p = cc[b] + (m-b)*arg\\n    return True if p >= arg*k else False\\n\\nfor k in range(1,n+1):\\n    if k > m:\\n        print((0))\\n        continue\\n    #\\u306b\\u3076\\u305f\\u3093\\n    ok,ng = -1,n//k+1\\n    while (abs(ok - ng) > 1):\\n        mid = (ok + ng) // 2\\n        if is_ok(k,mid):\\n            ok = mid\\n        else:\\n            ng = mid\\n    \\n    print(ok)\\n\", \"import sys\\ninput = sys.stdin.readline\\nn=int(input())\\na=[int(j) for j in input().split()]\\nfrom collections import Counter\\nc=Counter(a)\\nl=c.most_common()\\nll=[]\\nfor i,j in l:\\n    ll.append(j)\\nll.sort()\\ns=sum(ll)\\nrem=0\\nfor k in range(1,n+1):\\n    rest=k-rem\\n    while ll and ll[-1]>s//rest:\\n        s-=ll[-1]\\n        ll.pop()\\n        rem+=1\\n        rest-=1\\n    print((s//rest))\\n\\n\\n\\n\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nN=int(input())\\nA=list(map(int,input().split()))\\n\\nfrom collections import Counter\\nfrom itertools import accumulate\\nimport bisect\\n\\nC=Counter(A)\\n\\nLIST=sorted(C.values())\\nLEN=len(LIST)\\nSUM=[0]+list(accumulate(LIST))\\nMIN=0\\nMAX=SUM[-1]\\n\\nfor k in range(1,N+1):\\n    MIN=0\\n    while MIN!=MAX:\\n        mid=(MIN+MAX+1)//2\\n        x=bisect.bisect_right(LIST,mid)\\n\\n        if SUM[x]+(LEN-x)*mid>=mid*k:\\n            MIN=mid\\n        else:\\n            MAX=mid-1\\n\\n    print(MIN)\\n\", \"from bisect import bisect_left\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nlst = [0] * (N + 1)\\nfor a in A:\\n    lst[a - 1] += 1\\nlst.sort() #\\u983b\\u5ea6\\u5217\\n\\ns = [0] * (N + 1)\\nfor i in range(N):\\n    s[i + 1] = s[i] + lst[i + 1]\\n\\n# print (lst)\\n# print (s)\\n\\ndef check(x, k):\\n    i = bisect_left(lst, x) - 1\\n    total = x * (N - i) + s[i]\\n    return total >= x * k\\n\\nans = N\\nfor k in range(1, N + 1):\\n    while True:\\n        if check(ans, k):\\n            break\\n        ans -= 1\\n    print (ans)\\n\", \"# -*- coding: utf-8 -*-\\nfrom collections import Counter\\nfrom itertools import accumulate\\n\\nN = int(input())\\nA = list(map(int,input().split()))\\n\\nB = list(Counter(A).values())\\n\\nC = [0] * N \\nfor i in B:\\n    C[i-1] += 1\\n\\nF = list(accumulate(C))\\n\\nS = [0] * N\\nf = [0] * N\\nS[0] = f[0] = sum(C) \\nfor i in range(2, N+1):\\n    S[i-1] = (S[i-2] + C[i-1] + S[0] - F[i-1] ) \\n    f[i-1] = S[i-1] / i\\n\\nf.sort()\\nn = 0     \\nK = 1\\n    \\nwhile K != N+1:\\n    if K <= f[n]:\\n        print(N-n)\\n        K += 1\\n    else:\\n        n += 1\\n    if n == N:\\n        for i in range(N-K+1):\\n            print(0)\\n        K = N+1    \", \"import itertools\\nimport collections\\nN = int(input())\\nA = [int(_) for _ in input().split()]\\nc = sorted(collections.Counter(A).values())\\nacc = list(itertools.accumulate([0] + c))\\nn = len(acc) - 1\\nj = 0\\nfor i in range(1, n + 1):\\n    r = 0\\n    while i - j > 0:\\n        if (i - j) * c[-1 - j] <= acc[-1 - j]:\\n            r = acc[-1 - j] // (i - j)\\n            break\\n        else:\\n            j += 1\\n    print(r)\\nfor _ in range(N - n):\\n    print((0))\\n\", \"from collections import Counter\\nimport bisect\\n\\n\\ndef main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    count_list = list(Counter(A).values())\\n    count_list.sort()\\n    cumsum_count = [0] * len(count_list)\\n    cumsum_count[0] = count_list[0]\\n    for i in range(1, len(count_list)):\\n        cumsum_count[i] = cumsum_count[i - 1] + count_list[i]\\n    ans_list = [0] * N\\n    n_max = N\\n    for k in range(1, len(count_list) + 1):\\n        # \\u6700\\u5927\\u3067\\u3082 N // k \\u56de\\u307e\\u3067\\u3002\\n        # \\u5404\\u30ab\\u30fc\\u30c9 n_max \\u679a\\u307e\\u3067\\u4f7f\\u3063\\u3066 k * n_max \\u306e\\u9577\\u65b9\\u5f62\\u9818\\u57df\\u3092\\u5168\\u90e8\\u57cb\\u3081\\u5c3d\\u304f\\u305b\\u308b\\u304b\\u3092\\u8abf\\u3079\\u308b\\u3002\\n        # \\u57cb\\u3081\\u5c3d\\u304f\\u305b\\u308b\\u6700\\u5c0f\\u306e n_max \\u304c\\u7b54\\u3048\\u3002\\n        n_max = min(n_max, N // k)\\n        s = 0\\n        while True:\\n            # n_max \\u679a\\u4ee5\\u4e0a\\u3042\\u308b\\u30ab\\u30fc\\u30c9\\u306f n_max \\u679a\\u56fa\\u5b9a\\n            index = bisect.bisect_left(count_list, n_max)\\n            s = n_max * (len(count_list) - index)\\n            # \\u305d\\u308c\\u672a\\u6e80\\u306e\\u30ab\\u30fc\\u30c9\\u306f\\u305d\\u306e\\u307e\\u307e\\u5168\\u90e8\\u4f7f\\u3046\\n            if index > 0:\\n                s += cumsum_count[index - 1]\\n            if s >= k * n_max or n_max == 0:\\n                break\\n            n_max -= 1\\n        ans_list[k - 1] = n_max\\n    for ans in ans_list:\\n        print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n = int(input())\\nA = list(map(int,input().split()))\\nB = [0]*(n+1)\\nC = [0]*(n+1)\\nfor a in A:\\n    B[a] += 1\\n    C[B[a]] += 1\\n\\nX = [0]\\nfor i in range(1,n+1):\\n    X.append(X[i-1] + C[i])\\nfor j in range(1,n+1):\\n    X[j] = X[j] // j\\n\\nind = n\\nk = 1\\nwhile k<=n:\\n    if ind<0:\\n        for _ in range(n-k+1):\\n            print(0)\\n        break\\n    if k<=X[ind]:\\n        print(ind)\\n        k += 1\\n    else:\\n        ind -= 1\", \"from itertools import accumulate\\n\\nN, *A = map(int, open(0).read().split())\\n\\nC = [0] * (N + 1)\\nD = [0] * (N + 1)\\nfor a in A:\\n    C[a] += 1\\n    D[C[a]] += 1\\n\\nT = [0] + [s // i for i, s in enumerate(accumulate(D[1:]), 1)]\\n\\nans = []\\nx = N\\nfor k in range(1, N + 1):\\n    while 0 < x and T[x] < k:\\n        x -= 1\\n    ans.append(x)\\n\\nprint(\\\"\\\\n\\\".join(map(str, ans)))\", \"from collections import Counter\\nfrom bisect import bisect_left\\nfrom itertools import accumulate\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\na = list(Counter(A).values())\\na.sort()\\nb = list(accumulate(a + [0]))\\ns = sum(a)\\nlength = len(a)\\n\\nfor i in range(1, N + 1):\\n    if i == 1:\\n        print(s)\\n    elif len(a) < i:\\n        print(0)\\n    else:\\n        n = s // i\\n        for j in reversed(range(1, n + 1)):\\n            t = bisect_left(a, j)\\n            if j * i <= b[t - 1] + (length - t) * j:\\n                print(j)\\n                break\", \"def main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n\\n    # C[x]: \\u66f8\\u304b\\u308c\\u3066\\u3044\\u308b\\u6574\\u6570\\u304cx\\u3067\\u3042\\u308b\\u30ab\\u30fc\\u30c9\\u306e\\u679a\\u6570\\n    C = [0] * (N + 1)\\n    D = [0] * (N + 1)\\n    for a in A:\\n        C[a] += 1\\n        D[C[a]] += 1\\n\\n    # A\\u304b\\u3089K(1<=K<=N)\\u679a\\u305a\\u3064\\u30ab\\u30fc\\u30c9\\u3092\\u629c\\u3044\\u3066\\u3063\\u305f\\u3068\\u304d\\u306b\\u3001\\n    # x\\u56de\\u4ee5\\u4e0a\\u629c\\u304f\\u3053\\u3068\\u304c\\u3067\\u304d\\u308b\\u304b\\u5224\\u5b9a\\u3059\\u308b\\u3002\\n    # \\u629c\\u304f\\u3053\\u3068\\u304c\\u3067\\u304d\\u308b\\u3068\\u5224\\u5b9a\\u3055\\u308c\\u305fx\\u306e\\u6700\\u5927\\u5024\\u304c\\u7b54\\u3048\\u306b\\u306a\\u308b\\u3002\\n\\n    # \\u4f8b\\u3048\\u3070\\u3001A = [1 1 1 1 1 2 2 3] \\u3068\\u3059\\u308b\\u3002\\n    # -> C = [5 2 1 0 0 0 0 0]\\n    # \\u3053\\u3053\\u304b\\u30892\\u679a\\u305a\\u3064\\u30ab\\u30fc\\u30c9\\u3092\\u629c\\u3051\\u308b\\u56de\\u6570\\u3092\\u8003\\u3048\\u308b\\u3068\\u304d\\u3001\\n    # \\u300c3\\u56de\\u629c\\u304f\\u300d\\u3068\\u3059\\u308b\\u3068\\u3001\\u6570\\u5b57\\u306e1\\u306f\\u3001\\u3069\\u3046\\u3084\\u3063\\u3066\\u30822\\u500b\\u306f\\u7d76\\u5bfe\\u4f59\\u308b\\n    # \\u305d\\u3053\\u3067\\u3001\\u7d76\\u5bfe\\u4f59\\u308b\\u90e8\\u5206\\u3092\\u6368\\u3066\\u3066C\\u3092\\u4f5c\\u308a\\u76f4\\u3059(=E\\u3068\\u3059\\u308b)\\u3068\\u3001\\n    # E = [3 2 1 0 0 0 0 0]\\n    # \\u3053\\u3053\\u304b\\u30892\\u679a\\u305a\\u30643\\u56de\\u629c\\u3051\\u308b\\u304b\\u5224\\u5b9a\\u3059\\u308b\\u306a\\u3089\\u3001\\n    # sum(E) >= 2 * 3 = 6\\n    # \\u3067\\u3042\\u308b\\u304b\\u898b\\u308c\\u3070\\u3088\\u3044\\u3002\\u4eca\\u56de\\u306e\\u5834\\u5408\\u3061\\u3087\\u3046\\u30696\\u306a\\u306e\\u3067\\u30012\\u679a\\u305a\\u30643\\u56de\\u306f\\u629c\\u3051\\u308b\\u3002\\n    \\n    # 3\\u679a\\u305a\\u30642\\u56de\\u306c\\u3051\\u308b\\u304b\\u8abf\\u3079\\u308b\\u5834\\u5408\\u3001\\n    # E = [2 2 1] \\u3068\\u306a\\u308a\\u3001sum(E) = 5 < 3 * 2 = 6 \\u306a\\u306e\\u3067\\u3001\\u629c\\u3051\\u306a\\u3044\\u3053\\u3068\\u304c\\u5206\\u304b\\u308b\\n\\n    # \\u3088\\u3063\\u3066\\u3001\\n    # sum(min(C[i], x)) >= K * x \\u3067\\u3042\\u308c\\u3070\\u629c\\u304f\\u3053\\u3068\\u304c\\u3067\\u304d\\u308b\\n    # S(x) = sum(min(C[i], x)) \\u3068\\u3059\\u308b\\u3068\\u3001\\n    # S(x) = S(x-1) + [C\\u306e\\u4e2d\\u3067C[i] >= x \\u3067\\u3042\\u308b\\u3082\\u306e\\u306e\\u500b\\u6570]\\n    # \\u3068\\u306a\\u308b\\u3053\\u3068\\u304b\\u3089\\u3001C\\u306e\\u4e2d\\u3067C[i] >= x \\u3067\\u3042\\u308b\\u3082\\u306e\\u306e\\u500b\\u6570 = D(x) \\u3068\\u3059\\u308b\\u3068\\u3001\\n    # S(x) = sum_(1~x) D(i) \\u3068\\u306a\\u308b\\u3002\\n    # \\u3064\\u307e\\u308a\\u3001S(x)\\u306f\\u3001D(x) \\u3092\\u6700\\u521d\\u306b\\u5168\\u90e8\\u8a08\\u7b97\\u3057\\u3066\\u304a\\u3044\\u3066\\u3001\\u7d2f\\u7a4d\\u548c\\u3092\\u3068\\u308b\\u3053\\u3068\\u3067\\u9ad8\\u901f\\u306b\\u8a08\\u7b97\\u3067\\u304d\\u308b\\u3002\\n\\n    # S(x) >= K * x \\u3068\\u306a\\u308bx\\u306e\\u6700\\u5927\\u5024\\u3092\\u3001k\\u30921\\u304b\\u3089N\\u307e\\u3067\\u52d5\\u304b\\u3057\\u3066\\u898b\\u3064\\u3051\\u308c\\u3070\\u3088\\u3044\\u3002\\n    # \\u3053\\u3053\\u3067\\u3001x\\u3092\\u5de6\\u8fba\\u306b\\u3082\\u3063\\u3066\\u3044\\u3063\\u3066\\u3001\\n    # S(x) / x >= K\\u3068\\u306a\\u308bx\\u306e\\u6700\\u5927\\u5024\\u3092\\u898b\\u3064\\u3051\\u308b\\u3088\\u3046\\u306b\\u3059\\u308b\\u3002\\n    # \\u307e\\u305f\\u3001S(x) / x = f(x) \\u3068\\u304a\\u304f\\u3002\\n\\n    # \\u6700\\u5927\\u5024\\u3092\\u898b\\u3064\\u3051\\u308b\\u305f\\u3081\\u306b2\\u5206\\u63a2\\u7d22\\u3057\\u3066\\u3082\\u3044\\u3044\\u304c\\u3001\\n    # K\\u304c\\u5897\\u3048\\u308b\\u3068\\u3001\\u7b54\\u3048\\u306f\\u4ee5\\u524d\\u306e\\u5024\\u4ee5\\u4e0b\\u306b\\u306a\\u308b\\u306f\\u305a\\u306a\\u306e\\u3067\\u3001\\n    # K+1\\u306e\\u3068\\u304d\\u3001K\\u3067\\u306e\\u7b54\\u3048\\u306e\\u4f4d\\u7f6e\\u304b\\u30890\\u3078\\u3068\\u63a2\\u7d22\\u3057\\u3066\\u3044\\u3051\\u3070\\u3001O(N)\\u3067\\u7b54\\u3048\\u304c\\u898b\\u3064\\u304b\\u308b\\n    S = [0] * (N + 1)\\n    f = [0] * (N + 1)\\n    for x in range(1, N+1):\\n        S[x] = S[x-1] + D[x]\\n        f[x] = S[x] // x\\n\\n    ans = []\\n    prev_ans = N\\n    for K in range(1, N+1):\\n        a = prev_ans\\n        while True:\\n            if f[a] >= K or a == 0:\\n                break\\n            a -= 1\\n        ans.append(a)\\n        prev_ans = a\\n\\n    print(*ans, sep='\\\\n')\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"def main():\\n    from sys import stdin\\n    input = stdin.readline\\n    from collections import Counter as ct\\n    from bisect import bisect_left as bl\\n\\n    n = int(input())\\n    max_a = sorted(ct(list(map(int, input().split()))).values())\\n    now_a = [i for i in max_a]\\n    m = len(max_a)\\n    cnt = m\\n    ans = 0\\n    ans_list = [0]*(n-m)\\n\\n    for use in range(m, 1, -1):\\n        rest = ans\\n        nex = now_a[0]\\n        while rest:\\n            val = nex\\n            start = bl(now_a, val+1)\\n            nex += 1\\n            q = max(-1, start-1-rest, bl(max_a, now_a[start-1]+1)-1)\\n            for i in range(start-1, q, -1):\\n                now_a[i] += 1\\n            if now_a[start-1] == 1:\\n                cnt += start-1-q\\n            rest -= start-1-q\\n            if start != m:\\n                nex = now_a[start]\\n        while cnt >= use:\\n            ans += 1\\n            rest = use\\n            nex = now_a[-1]\\n            end = m\\n            while rest:\\n                val = nex\\n                start = bl(now_a, val)\\n                if start != 0:\\n                    nex = now_a[start-1]\\n                end = min(end, bl(now_a, val+1), start+rest)\\n                for i in range(start, end):\\n                    now_a[i] -= 1\\n                if now_a[start] == 0:\\n                    cnt -= end-start\\n                rest -= end-start\\n                end = start\\n        ans_list.append(ans)\\n    print(n)\\n    for i in ans_list[::-1]:\\n        print(i)\\n\\n\\nmain()\", \"N = int(input())\\nA = list(map(int,input().split()))\\nC = [0] * (N + 1)\\nfor a in A:\\n    C[a] += 1\\nD = [0] * (N + 1)\\nfor c in C:\\n    D[c] += 1\\nP = [0] * (N + 1)\\nQ = [0] * (N + 1)\\nfor i in range(1, N+1):\\n    P[i] = P[i-1] + i * D[i]\\n    Q[i] = Q[i-1] + D[i]\\nF = [0] * (N + 1)\\nfor i in range(1, N+1):\\n    F[i] = int((P[i] + i * (Q[N] - Q[i])) / i)\\nindex = N\\nfor i in range(1, N+1):\\n    while True:\\n        if index == 0:\\n            print(0)\\n            break\\n        if F[index] >= i:\\n            print(index)\\n            break\\n        else:\\n            index -= 1\", \"from collections import defaultdict\\nfrom bisect import bisect\\nN = int(input())\\nA = list(map(int,input().split()))\\n\\nd = defaultdict(lambda:0)\\n\\nfor i in range(N):\\n    d[A[i]] += 1\\n\\nC = [0]*(N+1)\\n\\nfor i in d:\\n    C[d[i]] += 1\\n\\nC1 = [0]*(N+1)\\nC2 = [0]*(N+1)\\n\\nfor i in range(N):\\n    C1[i+1] = C1[i] + (i+1)*C[i+1]\\n    C2[i+1] = C2[i] + C[i+1]\\n\\nl = [0]*N\\nfor n in range(N):\\n    l[n] = C1[n+1]//(n+1)+C2[N]-C2[n+1]\\n    l[n] *= -1\\n\\n\\nfor i in range(N):\\n    print(bisect(l,-(i+1)))\", \"\\nN = int(input())\\n\\nA = list(map(int,input().split()))\\n\\ndic = {}\\n\\nfor a in A:\\n\\n    if a not in dic:\\n        dic[a] = 1\\n    else:\\n        dic[a] += 1\\n\\nB = []\\nfor i in dic:\\n    B.append(dic[i])\\n\\nB.sort()\\n\\nB_sub = B.copy()\\n\\nfor i in range(len(B)-1):\\n    B_sub[i+1] += B_sub[i] \\n\\naind = N + 1\\nnind = len(B) - 1\\n\\n#print (B,B_sub)\\n\\nfor i in range(N):\\n\\n    i += 1\\n\\n    while True:\\n\\n        while nind > 0 and B[nind] > aind - 1:\\n\\n          nind -= 1\\n\\n        if i > len(B):\\n            print((0))\\n            break\\n\\n        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:\\n            print((aind - 1))\\n            break\\n\\n        aind -= 1\\n\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\n\\nnum = [0 for _ in range(N)]\\nfor a in A:\\n    num[a-1] += 1\\nnum.sort()\\ncum = [0 for _ in range(N)]\\ncum[0] = num[0]\\nfor i in range(1, N):\\n    cum[i] = cum[i-1] + num[i]\\n\\nindex = N - 1\\nans = N\\nfor k in range(1, N+1):\\n    while ans > 0:\\n        tmp_index = index\\n        while tmp_index >= 0 and num[tmp_index] > ans:\\n            tmp_index -= 1\\n        decided = N - tmp_index - 1\\n        rest_total = 0 if tmp_index < 0 else cum[tmp_index]\\n        if rest_total >= ans * (k - decided):\\n            index = tmp_index\\n            break\\n        ans -= 1\\n    print(ans)\", \"import sys\\nfrom collections import Counter\\n\\nsys.setrecursionlimit(10 ** 6)\\ninput = sys.stdin.readline\\n\\ndef main():\\n    n = int(input())\\n    aa = list(map(int, input().split()))\\n    aa = list(Counter(aa).values())\\n    aa.sort()\\n    cs = [0]\\n    s = 0\\n    for a in aa:\\n        s += a\\n        cs += [s]\\n    # print(aa)\\n    # print(cs)\\n    ans = n + 1\\n    i = len(aa)\\n    for k in range(1, n + 1):\\n        while 1:\\n            while i > 0 and aa[i - 1] >= ans:\\n                i -= 1\\n            s = cs[i] + ans * (len(aa) - i)\\n            if s >= ans * k:\\n                break\\n            else:\\n                ans -= 1\\n        print(ans)\\n\\nmain()\\n\", \"N=int(input())\\nA=list(map(int,input().split()))\\n\\nc = [0] * (N + 1)\\nDx = [0] * (N + 1)\\nfor a in A:\\n    c[a] += 1 #c\\u306f\\u3001a\\u3068\\u3044\\u3046\\u6570\\u304c\\u51fa\\u305f\\u56de\\u6570\\u3092\\u8a18\\u9332\\n    Dx[c[a]]+=1\\n    #Dx\\u306f\\u3001\\u305d\\u306e\\u56de\\u6570\\u306e\\u3068\\u3053\\u308d\\u306b\\u7a2e\\u985e\\u3092\\u8a18\\u9332\\u3002\\u8ce2\\u3044\\u3002\\n\\nSx=[0]#\\u521d\\u9805\\u306f0\\nfor j in range(1,N+1):\\n    Sx.append(Sx[j-1]+Dx[j])\\n#\\u89e3\\u6cd52\\u3092\\u771f\\u4f3c\\u3057\\u3066\\u307f\\u308b\\u3002\\nfor h in range(1,N+1):\\n    Sx[h]=Sx[h]/h\\n\\nx=N\\nk=1\\nwhile k<N+1:\\n    if x<0:\\n        for _ in range(N-k+1):\\n            print((0))\\n        return\\n    if k<=Sx[x]:\\n        print(x)\\n        k+=1\\n    else:\\n        x-=1\\n\", \"from collections import Counter\\n\\nN = int(input())\\nAs = list(map(int, input().split()))\\n\\ncntA = Counter(As)\\ncntCntA = Counter(list(cntA.values()))\\n\\naccDs = [cntCntA[0]]\\nfor i in range(1, N+1):\\n    accDs.append(accDs[-1] + cntCntA[i])\\n\\naccKDs = [0]\\nfor i in range(1, N+1):\\n    accKDs.append(accKDs[-1] + i*cntCntA[i])\\n\\nfXs = [0]\\nfor X in range(1, N+1):\\n    fXs.append((accKDs[X] + X*(accDs[N]-accDs[X])) // X)\\n\\nanss = [0] * (N+1)\\nfor X, fX in enumerate(fXs):\\n    anss[fX] = X\\n\\nfor i in reversed(list(range(N))):\\n    if anss[i] == 0:\\n        anss[i] = anss[i+1]\\n\\nprint(('\\\\n'.join(map(str, anss[1:]))))\\n\", \"from bisect import bisect_left\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\n\\nlst = [0] * (N)\\nfor a in A:\\n    lst[a - 1] += 1\\nlst.sort() #\\u983b\\u5ea6\\u5217\\n\\ns = [0] * (N + 1)\\nfor i in range(N):\\n    s[i + 1] = s[i] + lst[i]\\n\\n# print (lst)\\n# print (s)\\n\\n# def check(x, k):\\n#     i = bisect_left(lst, x) - 1\\n#     total = x * (N - i) + s[i]\\n#     return total >= x * k\\n\\n\\nans = N\\ni = N\\nfor k in range(1, N + 1):\\n    while True:\\n        while  i >= 1 and lst[i - 1] >= ans:\\n            i -= 1\\n        total = ans * (N - i) + s[i]\\n        if total >= ans * k:\\n            break\\n        ans -= 1\\n    # print ('i =', i)\\n    print (ans)\\n\", \"from collections import Counter\\nN = int(input())\\nC = sorted(list(Counter(list(map(int, input().split()))).values()))\\n\\nrest = N\\nremoved = 0\\nfor K in range(1, N + 1):\\n    d = K - removed\\n    while C and C[- 1] > rest//d:\\n        rest -= C[- 1]\\n        C.pop()\\n        removed += 1\\n        d -= 1\\n    print((rest//d))\\n\"]",
        "difficulty": "interview",
        "input": "4\n1 3 3 3\n",
        "output": "4\n1\n0\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://atcoder.jp/contests/abc143/tasks/abc143_f"
    },
    {
        "id": 1967,
        "task_id": 2522,
        "test_case_id": 3,
        "question": "Given are two sequences A and B, both of length N.\nA and B are each sorted in the ascending order.\nCheck if it is possible to reorder the terms of B so that for each i (1 \\leq i \\leq N) A_i \\neq B_i holds, and if it is possible, output any of the reorderings that achieve it.\n\n-----Constraints-----\n - 1\\leq N \\leq 2 \\times 10^5\n - 1\\leq A_i,B_i \\leq N\n - A and B are each sorted in the ascending order.\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\nA_1 A_2 \\cdots A_N\nB_1 B_2 \\cdots B_N\n\n-----Output-----\nIf there exist no reorderings that satisfy the condition, print No.\nIf there exists a reordering that satisfies the condition, print Yes on the first line.\nAfter that, print a reordering of B on the second line, separating terms with a whitespace.\nIf there are multiple reorderings that satisfy the condition, you can print any of them.\n\n-----Sample Input-----\n6\n1 1 1 2 2 3\n1 1 1 2 2 3\n\n-----Sample Output-----\nYes\n2 2 3 1 1 1\n",
        "solutions": "[\"# b\\u3092\\u5fc5\\u8981\\u306a\\u3060\\u3051(stride\\u306e\\u5206)\\u53f3\\u306b\\u305a\\u3089\\u305b\\u3070\\u3088\\u3044\\ndef main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = list(map(int, input().split()))\\n\\n    ai, bi = 0, 0\\n    stride = 0\\n    while ai < n and bi < n:\\n        ax, bx = a[ai], b[bi]\\n        if ax == bx:\\n            cnt = 2\\n\\n            ai += 1\\n            while ai < n and a[ai] == ax:\\n                cnt += 1\\n                ai += 1\\n\\n            bi_copy = bi\\n            bi += 1\\n            while bi < n and b[bi] == bx:\\n                cnt += 1\\n                bi += 1\\n\\n            if cnt > n:\\n                print('No')\\n                return\\n\\n            if stride < ai - bi_copy:\\n                stride = ai - bi_copy\\n\\n        elif ax < bx:\\n            ai += 1\\n        else:\\n            bi += 1\\n\\n    print('Yes')\\n    print(' '.join(map(str, b[n-stride:] + b[:n-stride])))\\n\\nmain()\", \"n = int(input())\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ns = 0\\nc = True\\nfor i in range(n):\\n    if i > 0:\\n        if a[i] != a[i-1]:\\n            s = 0\\n    if a[i] != b[i]:\\n        continue\\n    else:\\n        c = False\\n        while s != n:\\n            if a[i] != b[s] and a[s] != b[i]:\\n                b[i], b[s] = b[s], b[i]\\n                c = True\\n                break\\n            s += 1\\n        if not c:\\n            break\\nif not c:\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n    print(*b)\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nreadline = sys.stdin.readline\\nread = sys.stdin.read\\n\\nn, = list(map(int,readline().split()))\\n*a, = list(map(int,readline().split()))\\n*b, = list(map(int,readline().split()))\\nb = b[::-1]\\n\\nsame = [i for i in range(n) if a[i] == b[i]]\\nif same:\\n    # \\u4ee5\\u4e0b\\u3059\\u3079\\u3066\\u534a\\u958b\\u533a\\u9593\\n    v = a[same[0]] # \\u91cd\\u306a\\u308b\\u5024\\u306f\\u4e00\\u7a2e\\u985e\\u3057\\u304b\\u306a\\u3044\\u3002\\u3053\\u308c\\u3092 v \\u3068\\u304a\\u304f\\u3002\\n    r = same[0]\\n    s = same[-1]+1\\n    vidx = [i for i in range(n) if a[i]==v or b[i]==v]\\n    p = vidx[0]\\n    q = vidx[-1]+1\\n    # [p,q) \\u3067\\u304b\\u3076\\u308b\\u3002[r,s)\\u3067\\u3069\\u3061\\u3089\\u304b\\u304c\\u5024 v \\u3092\\u3068\\u308b\\n    if q > n-s+r+p: # \\u304b\\u3076\\u308a\\u3092\\u5439\\u3063\\u98db\\u3070\\u305b\\u306a\\u3044\\n        print(\\\"No\\\")\\n        return\\n    # \\u304b\\u3076\\u3063\\u305f\\u90e8\\u5206\\u3092\\u5de6\\u3001\\u53f3\\u306b\\u3088\\u3051\\u308b\\n    if p >= s-r:\\n        b[r:s],b[:s-r] = b[:s-r],b[r:s]\\n    else:\\n        b[r:r+p],b[:p] = b[:p],b[r:r+p]\\n        b[r+p:s],b[n-s+r+p:] = b[n-s+r+p:], b[r+p:s]\\n\\nprint(\\\"Yes\\\")\\nprint((*b))\\n\\n\", \"from collections import Counter, deque\\n\\nN = int(input())\\nA = list(map(int, input().split())) + [N+1]\\nB = list(map(int, input().split())) + [N+1]\\nC = [0]\\nD = [0]\\n\\nAB_cn = Counter(A+B)\\nif AB_cn.most_common()[0][1] > N:\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n    for i in range(N+1):\\n        if len(C) != A[i]:\\n            C.extend([i]*(A[i]-len(C)))\\n        if len(D) != B[i]:\\n            D.extend([i]*(B[i]-len(D)))\\n    ans = 0\\n    for i in range(N):\\n        curr = C[i+1] - D[i]\\n        ans= max(curr, ans)\\n    B = B[:-1]\\n    ans = [B[(i-ans)%N] for i in range(N)]\\n \\n    print((*ans))\\n\", \"N=int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\nB.sort(reverse=True)\\nArev=sorted(A, reverse=True)\\nBrev=sorted(B)\\natai=0\\ns=0\\nfor i in range(len(A)):\\n    if A[i]==B[i]:\\n        atai=A[i]\\n        s+=1\\nC=[]\\nfor i in range(len(A)):\\n    C.append(A[i]-B[i])\\nif s>0:\\n    hajime=C.index(0)\\nif s==0:\\n    print(\\\"Yes\\\")\\n    print(*B)\\nelse:\\n    Acount=A.count(atai)\\n    Bcount=B.count(atai)\\n    if N-Acount<Bcount:\\n        print(\\\"No\\\")\\n    else:\\n        afirst=A.index(atai)\\n        alast=N-1-Arev.index(atai)\\n        bfirst=B.index(atai)\\n        blast=N-1-Brev.index(atai)\\n        t=min(afirst,bfirst)\\n        if t>=s:\\n            for i in range(0,s):\\n                B[hajime+i]=B[i]\\n                B[i]=atai\\n        else:\\n            for i in range(0,t):\\n                B[hajime+i]=B[i]\\n                B[i]=atai\\n            ss=s-t\\n            for i in range(0,ss):\\n                B[hajime+t+i]=B[-i-1]\\n                B[-i-1]=atai\\n        print(\\\"Yes\\\")\\n        print(*B)\", \"from collections import Counter\\nfrom heapq import heapify, heappop, heappush\\nfrom itertools import groupby\\n\\nn = int(input())\\naaa = list(map(int, input().split()))\\nbbb = list(map(int, input().split()))\\n\\ncnt_b = Counter(bbb)\\nhq_both = []\\nfree_a = []\\nidx_a = {}\\ncnt_a = {}\\ni = 0\\nfor a, itr in groupby(aaa):\\n    cnt = len(list(itr))\\n    idx_a[a] = i\\n    cnt_a[a] = cnt\\n    if a in cnt_b:\\n        cnt_ab = cnt + cnt_b[a]\\n        if cnt_ab > n:\\n            print('No')\\n            return\\n        hq_both.append((-cnt_ab, a))\\n    else:\\n        free_a.append(a)\\n    i += cnt\\nheapify(hq_both)\\n\\nans = [-1] * n\\nremaining = n\\n\\nwhile hq_both:\\n    cnt_ab, b = heappop(hq_both)\\n    cnt_ab = -cnt_ab\\n    assert cnt_ab == cnt_a[b] + cnt_b[b]\\n    assert cnt_ab <= remaining\\n\\n    cb = cnt_b[b]\\n    while cb:\\n        if hq_both:\\n            _, a = heappop(hq_both)\\n        else:\\n            a = free_a.pop()\\n        ca = cnt_a[a]\\n\\n        fill_len = min(ca, cb)\\n        i = idx_a[a]\\n        ans[i:i + fill_len] = [b] * fill_len\\n        remaining -= fill_len\\n        idx_a[a] += fill_len\\n        cnt_a[a] -= fill_len\\n        cnt_b[b] -= fill_len\\n        cb -= fill_len\\n\\n        if cnt_a[a] > 0:\\n            if a in cnt_b and cnt_b[a] > 0:\\n                heappush(hq_both, (-(cnt_a[a] + cnt_b[a]), a))\\n            else:\\n                free_a.append(a)\\n\\n    free_a.append(b)\\n\\nfor b, cb in list(cnt_b.items()):\\n    if cb == 0:\\n        continue\\n    while cb:\\n        a = free_a.pop()\\n        ca = cnt_a[a]\\n\\n        fill_len = min(ca, cb)\\n        i = idx_a[a]\\n        ans[i:i + fill_len] = [b] * fill_len\\n        idx_a[a] += fill_len\\n        cnt_a[a] -= fill_len\\n        cb -= fill_len\\n\\n        if cnt_a[a] > 0:\\n            free_a.append(a)\\n\\nprint('Yes')\\nprint((*ans))\\n\", \"# Reference: https://betrue12.hateblo.jp/entry/2020/09/15/180849\\n\\nimport sys\\nfrom itertools import accumulate\\n\\nread = sys.stdin.read\\nreadline = sys.stdin.readline\\nreadlines = sys.stdin.readlines\\nsys.setrecursionlimit(10 ** 9)\\nINF = 1 << 60\\nMOD = 1000000007\\n\\n\\ndef main():\\n    N = int(readline())\\n    A = list(map(int, readline().split()))\\n    B = list(map(int, readline().split()))\\n\\n    C = [0] * (N + 1)\\n    D = [0] * (N + 1)\\n\\n    for i in range(N):\\n        C[A[i]] += 1\\n        D[B[i]] += 1\\n\\n    for i in range(1, N + 1):\\n        if C[i] + D[i] > N:\\n            print('No')\\n            return\\n\\n    print('Yes')\\n\\n    C = list(accumulate(C))\\n    D = list(accumulate(D))\\n\\n    B.reverse()\\n\\n    i = 0\\n    while i < N and A[i] != B[i]:\\n        i += 1\\n\\n    if i == N:\\n        print((*B))\\n        return\\n\\n    n = A[i]\\n\\n    idx_ng = []\\n    idx_ok = []\\n\\n    for i in range(N):\\n        if A[i] == n and B[i] == n:\\n            idx_ng.append(i)\\n        elif A[i] != n and B[i] != n:\\n            idx_ok.append(i)\\n\\n    for ng, ok in zip(idx_ng, idx_ok):\\n        B[ng], B[ok] = B[ok], B[ng]\\n\\n    print((*B))\\n    return\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\ncnt = [0 for i in range(n+1)]\\n\\ndef lb(x):\\n    l, r = 0, n\\n    while l < r:\\n        m = (l+r)//2\\n        if a[m] < x:\\n            l = m + 1\\n        else:\\n            r = m\\n    return l\\n\\ndef ub(x):\\n    l, r = 0, n\\n    while l < r:\\n        m = (l+r)//2\\n        if a[m] <= x:\\n            l = m + 1\\n        else:\\n            r = m\\n    return l\\n\\nfor i in range(n):\\n    l = lb(b[i])\\n    r = ub(b[i])-1\\n    if l > r:\\n        continue\\n    if l < i and i <= r:\\n        cnt[l+n-i]+=1\\n        cnt[0]+=1\\n        cnt[r-i+1]-=1\\n    elif i <= l:\\n        cnt[l-i]+=1\\n        cnt[r-i+1]-=1\\n    elif i > r:\\n        cnt[l+n-i]+=1\\n        cnt[r+n+1-i]-=1\\n\\nres = 0\\nans = -1\\nfor i in range(n):\\n    res += cnt[i]\\n    if(res == 0):\\n        ans = i\\nif ans == -1:\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n    for i in range(n):\\n        print(b[(i-ans+n)%n],end=' ')\", \"def solve(n):\\n    a = list(map(int, input().split()))\\n    b = list(map(int, input().split()))[::-1]\\n    ind = [-1] * (n + 1)\\n    for i in range(n):\\n        if i == 0:\\n            ind[b[i]] = 0\\n        elif b[i] != b[i - 1]:\\n            ind[b[i]] = i\\n    cnt = 0\\n    for i in range(n):\\n        if a[i] != b[i]:\\n            continue\\n        else:\\n            swap = 0\\n            for j in range(b[i] - 1, 0, -1):\\n                if ind[j] != -1 or ind[j] >= ind[j - 1]:\\n                    swap = ind[j]\\n                    ind[j] += 1\\n                    break\\n            if n <= swap:\\n                swap = cnt\\n                cnt += 1\\n                cnt %= n\\n            b[i], b[swap] = b[swap], b[i]\\n    return a, b\\n\\n\\ndef main():\\n    n = int(input())\\n    a, b = solve(n)\\n    if all(a[i] != b[i] for i in range(n)):\\n        print(\\\"Yes\\\")\\n        print((\\\" \\\".join(map(str, b))))\\n    else:\\n        print(\\\"No\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#\\u89e3\\u8aac\\u53c2\\u7167\\nn=int(input())\\n*a,=map(int, input().split())\\n*b,=map(int, input().split())\\nshift=0\\nfrom bisect import bisect_right,bisect_left\\nfrom collections import Counter\\nsb=Counter(b)\\nsa=Counter(a)\\nfor bi in sb:\\n    if bi in sa:\\n        if sa[bi]+sb[bi]>n:\\n            print(\\\"No\\\")\\n            return\\nfor bi in sb:\\n    lb=bisect_left(b,bi)\\n    ra=bisect_right(a,bi)\\n    if a[ra-1]==b[lb]:\\n        shift=max(shift,ra-lb)\\nans=[b[(i-shift)%n] for i in range(n)]##\\nprint(\\\"Yes\\\")\\nprint(*ans)\", \"n = int(input())\\na = list(map(int,input().split()))\\nb = list(map(int,input().split()))\\nb = b[::-1]\\n\\nl = []\\nnum = -1\\nfor i in range(n):\\n    if a[i] == b[i]:\\n        l.append(i)\\n        num = a[i]\\n\\nind = 0\\nfor i in range(n):\\n    if b[i] != num and a[i] != num and ind < len(l):\\n        b[i],b[l[ind]] = b[l[ind]],b[i]\\n        ind += 1\\nif ind < len(l):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n    print(*b)\", \"n=int(input())\\ny=lambda:[*map(int,input().split())]\\na,b=y(),y()[::-1]\\nc=0\\nfor i in range(n):\\n  if a[i]==b[i]:c=a[i]\\nif c<1:print(\\\"Yes\\\");print(' '.join(map(str,b)));return\\nal,bl,ah,bh=[-1]*4\\nea=eb=0\\nfor i in range(n):\\n  if al<0 and a[i]==c:al=i\\n  if bl<0 and b[i]==c:bl=i\\n  if al<0:ea+=1\\n  if bl<0:eb+=1\\n  if ah<0 and al>=0 and a[i]!=c:ah=i\\n  if bh<0 and bl>=0 and b[i]!=c:bh=i\\nif ah<0:ah=n\\nif bh<0:bh=n\\nt=ah+bh-al-bl\\nif ah+bh-al-bl>n:print(\\\"No\\\");return\\no1=min(bh-bl,ea,ea-eb+ah-al)\\nprint(\\\"Yes\\\")\\nprint(' '.join(map(str,[c]*o1+b[:eb]+b[eb+bh-bl:]+[c]*(bh-bl-o1))))\", \"import numpy as np\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\n\\ncount = [0] * (N+1)\\nfor a, b in zip(A, B):\\n    count[a] += 1\\n    count[b] += 1\\n\\nfor i in range(N+1):\\n    if count[i] > N:\\n        print('No')\\n        return\\n\\ndiff = 0\\nchecked = set()\\nida = 0\\nfor i, b in enumerate(B):\\n    if b in checked:\\n        continue\\n    checked.add(b)\\n    while ida < N and A[ida] <= b:\\n        ida += 1\\n    diff = max(diff, ida - i)\\n\\n\\nidx = (np.arange(N) - diff) % N\\nprint('Yes')\\nprint(*np.array(B)[idx])\", \"N = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\n\\nR = list(reversed(B))\\nflag = True\\nfor i in range(N):\\n  if A[i] == R[i]:\\n    flag = False\\n    break\\nif flag:\\n  print('Yes')\\n  print(*R)\\n  return\\n\\nl1 = B[N//2:]  + B[:N//2]\\nl2 = B[N//2+1:]  + B[:N//2+1]\\nflag1 = True\\nfor i in range(N):\\n  if A[i] == l1[i]:\\n    flag1 = False\\n    break\\nflag2 = True\\nfor i in range(N):\\n  if A[i] == l2[i]:\\n    flag2 = False\\n    break\\nif (flag1==False) and (flag2==False):\\n  print('No')\\nelif flag1 == True:\\n  print('Yes')\\n  print(*l1)\\nelse:\\n  print('Yes')\\n  print(*l2)\", \"import bisect\\nn = int(input())\\nA = tuple(map(int, input().split()))\\nB = tuple(map(int, input().split()))\\nsA = set(A)\\nsB = set(B)\\nx = 0\\nfor i in sA & sB:\\n    r = bisect.bisect_right(A, i)\\n    l = bisect.bisect_left(B, i)\\n    x = max(x, r-l)\\nans = B[-x:] + B[:-x]\\nfor a, b in zip(A, ans):\\n    if a == b:\\n        print(\\\"No\\\")\\n        break\\nelse:\\n    print(\\\"Yes\\\")\\n    print((*ans))\\n\", \"import collections\\nn=int(input())\\na=list(map(int,input().split()))\\nb=list(map(int,input().split()))\\nA=collections.Counter(a)\\nB=collections.Counter(b)\\n\\ninf=10e18\\ncc,cd=0,0\\nR=0\\nfor i in range(n+1):\\n    if(A[i]+B[i]>n):\\n        R=inf\\n    else:\\n        cc+=A[i]\\n        R=max(R,cc-cd)\\n        cd+=B[i]\\nif(R==inf):\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n    ans=\\\" \\\".join(map(str,b[-R:]+b[:-R]))\\n    print(ans)\", \"#a,b,c,d = map(int, input().split())\\nn = int(input())\\na = list(map(int, input().strip().split()))\\nb = list(map(int, input().strip().split()))\\nb = b[::-1]\\n\\nfirst = 0\\nlast = n-1\\nfor i in range(n):\\n\\tif a[i] == b[i]:\\n\\t\\tif i < last and b[last] != a[i]:\\n\\t\\t\\tb[i],b[last] = b[last],b[i]\\n\\t\\t\\tlast -= 1\\n\\t\\telif first < i and b[first] != a[i]:\\n\\t\\t\\tb[i],b[first] = b[first],b[i]\\n\\t\\t\\tfirst += 1\\n\\nok = True\\nfor i in range(n):\\n\\tok = ok and a[i] != b[i]\\n\\nif ok:\\n\\tprint(\\\"Yes\\\")\\n\\tfor i in range(n):\\n\\t\\tprint(b[i],end=' ')\\nelse:\\n\\tprint(\\\"No\\\")\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\nidx_B = 0\\nma = 0\\nfor idx_A, a in enumerate(A):\\n    while idx_B < N and B[idx_B] < a:\\n        idx_B += 1\\n    if ma < idx_A - idx_B:\\n        ma = idx_A - idx_B\\nAns = (B+B)[N-ma-1:2*N-ma-1]\\nfor a, b in zip(A, Ans):\\n    if a == b:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\\nprint((\\\" \\\".join(map(str, Ans))))\\n\", \"def f_contrast():\\n    from collections import Counter\\n    N = int(input())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n\\n    c = [0] * (N + 1)\\n    d = [0] * (N + 1)\\n\\n    for a, b in zip(A, B):\\n        c[a] += 1\\n        d[b] += 1\\n\\n    for s, t in zip(c, d):\\n        if s + t > N:\\n            return 'No'\\n\\n    for i in range(1, N + 1):\\n        c[i] += c[i - 1]\\n        d[i] += d[i - 1]\\n\\n    shift = max(c[i] - d[i - 1] for i in range(1, N + 1))\\n    ans = [B[(i + N - shift) % N] for i in range(N)]\\n    ret = ' '.join(map(str, ans))\\n    return f'Yes\\\\n{ret}'\\n\\nprint(f_contrast())\", \"import sys\\ninput = sys.stdin.readline\\nN = int(input())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nRB = B[::-1]\\n\\nstart = v = -1\\nseq = 0\\nfor i,(a,b) in enumerate(zip(A,RB)):\\n    if a==b:\\n        v = a\\n        seq += 1\\n        if start == -1:\\n            start = i\\n\\nif v == -1:\\n    print('Yes')\\n    print(*RB)\\n    return\\n\\nif A.count(v) + B.count(v) > N:\\n    print('No')\\n    return\\n\\nfrom bisect import bisect_left,bisect\\nal = bisect_left(A,v)\\nbr = bisect(B,v)\\nrbl = N - br\\n\\nm = min(seq,start,al,rbl)\\nRB[:m],RB[start:start+m] = RB[start:start+m],RB[:m]\\nseq -= m\\nstart += m\\nif seq:\\n    RB[start:start+seq],RB[-seq:] = RB[-seq:],RB[start:start+seq]\\n\\nassert all(a!=b for a,b in zip(A,RB))\\nprint('Yes')\\nprint(*RB)\", \"#!/usr/bin/env python\\n\\n\\ndef main():\\n    n = int(input())\\n    a = list(map(int, input().split()))\\n    b = list(map(int, input().split()))\\n    b = list(reversed(b))\\n    bad = next((x for x, y in zip(a, b) if x == y), None)\\n    if bad is None:\\n        print('Yes')\\n        print((' '.join(map(str, b))))\\n    else:\\n        l_1 = sum(1 for x, y in zip(a, b) if x < bad < y)\\n        l_2 = sum(1 for x, y in zip(a, b) if x < y and bad in (x, y))\\n        l_3 = sum(1 for x, y in zip(a, b) if x == y)\\n        l_4 = sum(1 for x, y in zip(a, b) if x > y and bad in (x, y))\\n        l_5 = sum(1 for x, y in zip(a, b) if x > bad > y and x != bad)\\n        if l_3 > l_1 + l_5:\\n            print('No')\\n        else:\\n            good_part = b[:l_1] + b[l_1 + l_2 + l_3 + l_4:]\\n            bad_part = b[l_1 + l_2:l_1 + l_2 + l_3]\\n            b[l_1 + l_2:l_1 + l_2 + l_3] = good_part[:l_3]\\n            good_part[:l_3] = bad_part\\n            b[:l_1] = good_part[:l_1]\\n            b[l_1 + l_2 + l_3 + l_4:] = good_part[l_1:]\\n            assert all(x != y for x, y in zip(a, b))\\n            print('Yes')\\n            print((' '.join(map(str, b))))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"def solve(n, a, b):\\n    b.reverse()\\n    l, r = 0, n-1\\n    for i in range(n):\\n        if a[i] == b[i]:\\n            if (l < i) and (a[i] != b[l]) and (a[l] != b[i]):\\n                b[l], b[i] = b[i], b[l]\\n                l += 1\\n            elif (i < r) and (a[i] != b[r]):\\n                b[r], b[i] = b[i], b[r]\\n                r -= 1\\n            else:\\n                return \\\"No\\\"\\n    return \\\"\\\\n\\\".join([\\n        \\\"Yes\\\",\\n        \\\" \\\".join(map(str, b))\\n    ])\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nprint(solve(n, a, b))\", \"from collections import Counter\\nfrom heapq import heapify, heappop, heappush\\nfrom itertools import groupby\\n\\nn = int(input())\\naaa = list(map(int, input().split()))\\nbbb = list(map(int, input().split()))\\n\\nidx_a = {}\\ncnt_a = {}\\ni = 0\\nfor a, itr in groupby(aaa):\\n    cnt = len(list(itr))\\n    idx_a[a] = i\\n    cnt_a[a] = cnt\\n    i += cnt\\n\\ncnt_b = Counter(bbb)\\nhq_both = []\\nhq_free = []\\nfor a, ca in list(cnt_a.items()):\\n    if a in cnt_b:\\n        hq_both.append((-(ca + cnt_b[a]), a))\\n    else:\\n        hq_free.append(a)\\nheapify(hq_both)\\n\\n# A\\u306e\\u500b\\u6570\\u3068B\\u306e\\u500b\\u6570\\u306e\\u548c\\u304c\\u5927\\u304d\\u3044\\u3084\\u3064\\u304c\\u30e4\\u30d0\\u3052\\n\\nans = [-1] * n\\nremaining = n\\n\\nwhile hq_both:\\n    cab, a1 = heappop(hq_both)\\n    cab = -cab\\n    assert cab == cnt_a[a1] + cnt_b[a1]\\n\\n    # print(a1, cab, cnt_a, cnt_b, ans, hq_both, hq_free)\\n\\n    if cab > remaining:\\n        print('No')\\n        return\\n\\n    cb = cnt_b[a1]\\n    while cb:\\n        if hq_both:\\n            _, a2 = heappop(hq_both)\\n            pop_from_que = True\\n        else:\\n            a2 = hq_free.pop()\\n            pop_from_que = False\\n        ca = cnt_a[a2]\\n        # print('b', cb, a2, pop_from_que, ca <= cb, hq_both, hq_free)\\n        if ca <= cb:\\n            l = idx_a[a2]\\n            ans[l:l + ca] = [a1] * ca\\n            remaining -= ca\\n            idx_a[a2] += ca\\n            cnt_a[a2] -= ca\\n            cnt_b[a1] -= ca\\n            cb -= ca\\n        else:\\n            l = idx_a[a2]\\n            ans[l:l + cb] = [a1] * cb\\n            remaining -= cb\\n            idx_a[a2] += cb\\n            cnt_a[a2] -= cb\\n            cnt_b[a1] -= cb\\n            cb = 0\\n            if pop_from_que:\\n                heappush(hq_both, (-(cnt_a[a2] + cnt_b[a2]), a2))\\n            else:\\n                hq_free.append(a2)\\n        # print('b', cb, a2, pop_from_que, ca <= cb, hq_both, hq_free)\\n    hq_free.append(a1)\\n\\nfor b, cb in list(cnt_b.items()):\\n    if cb == 0:\\n        continue\\n    while cb:\\n        a = hq_free.pop()\\n        ca = cnt_a[a]\\n        if ca <= cb:\\n            l = idx_a[a]\\n            ans[l:l + ca] = [b] * ca\\n            cb -= ca\\n        else:\\n            l = idx_a[a]\\n            ans[l:l + cb] = [b] * cb\\n            idx_a[a] += cb\\n            cnt_a[a] -= cb\\n            cb = 0\\n            hq_free.append(a)\\n\\nprint('Yes')\\nprint((*ans))\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\n\\nfrom collections import Counter\\n\\ncA = Counter(A)\\ncB = Counter(B)\\n\\nf = 0\\n\\nfor num, val in cA.items():\\n    if num not in cB:\\n        continue\\n    else:\\n        if cB[num] + val > N:\\n            f = 1\\n\\ntpA = [-1] * (N + 1)\\ntpB = [-1] * (N + 1)\\na = A[0]\\nb = B[0]\\ntpB[b] = 0\\nfor i in range(1, N):\\n    if a != A[i]:\\n        tpA[a] = i\\n        a = A[i]\\n    if b != B[i]:\\n        b = B[i]\\n        tpB[b] = i\\ntpA[a] = N\\n\\n\\nans = [0] * N\\nif f == 1:\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n    t = 0\\n    for i in range(N+1):\\n        if tpA[i] >= 0 and tpB[i] >= 0:\\n            t = max(t, tpA[i] - tpB[i])\\n    for i in range(N):\\n        ans[i+t-N] = B[i]\\n    #print(tpA, tpB, t)\\n    print(\\\" \\\".join([str(_) for _ in ans]))\", \"\\nfrom collections import Counter\\ndef resolve():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    B = list(map(int, input().split()))\\n\\n    CNT = Counter(A+B)\\n    num = CNT.most_common()[0][1]\\n    if num > N:\\n        print(\\\"No\\\")\\n        return \\n\\n    j, pre = 0, -1\\n    for i in range(N):\\n        if A[i] != pre:\\n            j = 0\\n        if A[i] == B[i]:\\n            while j < N:\\n                if A[i] != B[j] and A[j] != B[i]:\\n                    B[i], B[j] = B[j], B[i]\\n                    break\\n                j += 1\\n        pre = A[i]\\n\\n    print('Yes')\\n    print(*B)\\n\\n\\ndef __starting_point():\\n    resolve()\\n__starting_point()\", \"def solve(n, a, b):\\n    b.reverse()\\n    l, r = 0, n-1\\n    for i in range(n):\\n        if a[i] == b[i]:\\n            if (l < i) and (a[i] != b[l]) and (a[l] != b[i]):\\n                b[l], b[i] = b[i], b[l]\\n                l += 1\\n            elif (i < r) and (a[i] != b[r]) and (a[r] != a[i]):\\n                b[r], b[i] = b[i], b[r]\\n                r -= 1\\n            else:\\n                return \\\"No\\\"\\n    return \\\"\\\\n\\\".join([\\n        \\\"Yes\\\",\\n        \\\" \\\".join(map(str, b))\\n    ])\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nprint(solve(n, a, b))\", \"import sys\\ninput = sys.stdin.readline\\n\\nN=int(input())\\nA=list(map(int,input().split()))\\nB=list(map(int,input().split()))\\n\\nfrom collections import Counter\\n\\nCA=Counter(A)\\nCB=Counter(B)\\n\\nH=[]\\n\\nfor ca in CA:\\n    if CA[ca]>0 and CB[ca]>0:\\n        if CA[ca]+CB[ca]>N:\\n            print(\\\"No\\\")\\n            return\\n        H.append((-(CA[ca]+CB[ca]),ca))\\n\\nimport heapq\\nheapq.heapify(H)\\n\\nANSDICT=dict()\\n\\nwhile len(H)>=2:\\n    c1,x1=heapq.heappop(H)\\n    c1=-c1\\n\\n    c2,x2=heapq.heappop(H)\\n    c2=-c2\\n\\n    if x1 in ANSDICT:\\n        ANSDICT[x1].append(x2)\\n    else:\\n        ANSDICT[x1]=[x2]\\n\\n    if x2 in ANSDICT:\\n        ANSDICT[x2].append(x1)\\n    else:\\n        ANSDICT[x2]=[x1]\\n\\n    CA[x1]-=1\\n    CA[x2]-=1\\n    CB[x1]-=1\\n    CB[x2]-=1\\n\\n    if CA[x1]>0 and CB[x1]>0:\\n        heapq.heappush(H,(-(c1-2),x1))\\n\\n    if CA[x2]>0 and CB[x2]>0:\\n        heapq.heappush(H,(-(c2-2),x2))\\n\\nANS=[-1]*N\\n\\nfor i in range(N):\\n    a=A[i]\\n    if a in ANSDICT and len(ANSDICT[a])!=0:\\n        \\n        x=ANSDICT[a].pop()\\n        ANS[i]=x\\n\\nif H:\\n    cc,xx=H[0]\\n    cc=-cc\\n\\n    for i in range(N):\\n        if ANS[i]==-1 and A[i]!=xx:\\n            ANS[i]=xx\\n            CB[xx]-=1\\n\\n            if CB[xx]==0:\\n                break\\n\\nind=0\\nfor cb in CB:\\n    while CB[cb]!=0:\\n        while ANS[ind]!=-1:\\n            ind+=1\\n        ANS[ind]=cb\\n        CB[cb]-=1\\n\\nprint(\\\"Yes\\\")\\nprint((*ANS))\\n\", \"from collections import Counter\\n\\n\\ndef solve(n, a_list, b_list):\\n    count_a = Counter(a_list)\\n    count_b = Counter(b_list)\\n    count_ab = dict()\\n    for k in list(count_a.keys()):\\n        if k in list(count_b.keys()):\\n            if count_a[k] + count_b[k] > n:\\n                return [\\\"No\\\"]\\n            count_ab[k] = min(count_a[k], count_b[k])\\n\\n    # move a\\n    a_list_1 = []\\n    a_list_2 = []\\n    a = 0\\n    for i in range(n):\\n        if a != a_list[i]:\\n            if a_list[i] in list(count_ab.keys()):\\n                c = count_ab[a_list[i]]\\n            else:\\n                c = 0\\n        a = a_list[i]\\n        if c > 0:\\n            a_list_1.append(a)\\n            c -= 1\\n        else:\\n            a_list_2.append(a)\\n    # move b\\n    b_list_1 = []\\n    b_list_2 = []\\n    b = 0\\n    for i in range(n):\\n        if b != b_list[i]:\\n            if b_list[i] in list(count_ab.keys()):\\n                c = count_ab[b_list[i]]\\n            else:\\n                c = 0\\n        b = b_list[i]\\n        if c > 0:\\n            b_list_1.append(b)\\n            c -= 1\\n        else:\\n            b_list_2.append(b)\\n    # print(a_list_1, a_list_2, b_list_1, b_list_2)\\n    k_max = -1\\n    if len(list(count_ab.values())) == 0:\\n        return [\\\"Yes\\\", \\\" \\\".join([str(b) for b in b_list])]\\n    d = max(count_ab.values())\\n    for k in list(count_ab.keys()):\\n        if count_ab[k] == d:\\n            k_max = k\\n            break\\n    a_list_moved = a_list_1 + a_list_2\\n    b_list_moved = b_list_1[d:] + b_list_1[:d] + b_list_2\\n\\n    # need to modify\\n    if d * 2 > len(a_list_1):\\n        # a includes many k_max\\n        if count_a[k_max] >= count_b[k_max]:\\n            # swap a\\n            j = len(a_list_1)\\n            for i in range(len(a_list_1)):\\n                if a_list_moved[i] == b_list_moved[i] == k_max:\\n                    while a_list_moved[j] == k_max:\\n                        j += 1\\n                    a_list_moved[i], a_list_moved[j] = a_list_moved[j], a_list_moved[i]\\n        else:\\n            # swap b\\n            j = len(a_list_1)\\n            for i in range(len(a_list_1)):\\n                if a_list_moved[i] == b_list_moved[i] == k_max:\\n                    while b_list_moved[j] == k_max:\\n                        j += 1\\n                    b_list_moved[i], b_list_moved[j] = b_list_moved[j], b_list_moved[i]\\n    # print(a_list_moved, b_list_moved)\\n    res_ab = list(sorted([(a, b) for a, b in zip(a_list_moved, b_list_moved)], key=lambda x: x[0]))\\n    res_b = \\\" \\\".join([str(ab[1]) for ab in res_ab])\\n    # print(res_b)\\n    return [\\\"Yes\\\", res_b]\\n\\n\\ndef main():\\n    n = int(input())\\n    a_list = list(map(int, input().split()))\\n    b_list = list(map(int, input().split()))\\n    res = solve(n, a_list, b_list)\\n    for r in res:\\n        print(r)\\n\\n\\ndef test():\\n    assert solve(6, [1, 1, 1, 2, 2, 3], [1, 1, 1, 2, 2, 3]) == [\\\"Yes\\\", \\\"2 2 3 1 1 1\\\"]\\n    assert solve(3, [1, 1, 2], [1, 1, 3]) == [\\\"No\\\"]\\n    assert solve(4, [1, 1, 2, 3], [1, 2, 3, 3]) == [\\\"Yes\\\", \\\"2 3 3 1\\\"]\\n\\n\\ndef __starting_point():\\n    test()\\n    main()\\n\\n__starting_point()\", \"from collections import Counter\\nimport numpy as np\\n\\n\\ndef main():\\n    n = int(input())\\n    a = np.array([int(i) for i in input().split()])\\n    b = np.array([int(i) for i in input().split()])\\n    ca = Counter(a)\\n    cb = Counter(b)\\n    for k in list(cb.keys()):\\n        if cb[k] > n - ca[k]:\\n            print(\\\"No\\\")\\n            return\\n    while any(a == b):\\n        s = max(ca[k] for k in list(cb.keys()))\\n        b = np.roll(b, s)\\n    print(\\\"Yes\\\")\\n    print((*b))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import collections\\n\\nn=int(input())\\narr1=list(map(int,input().split()))\\narr2=list(map(int,input().split()))\\ncnt1=collections.Counter(arr1)\\ncnt2=collections.Counter(arr2)\\nacum1=[0]*(n+1)\\nacum2=[0]*(n+1)\\nfor i in range(1,n+1):\\n  acum1[i]=acum1[i-1]+cnt1[i]\\n  acum2[i]=acum2[i-1]+cnt2[i]\\nrotate=0\\nfor i in range(1,n+1):\\n  rotate=max(rotate,acum1[i]-acum2[i-1])\\nans=[0]*n\\nfor i in range(n):\\n  ans[(i+rotate)%n]=arr2[i]\\nfor i in range(n):\\n  if arr1[i]==ans[i]:\\n    print('No')\\n    break\\nelse:\\n  print('Yes')\\n  print(*ans)\", \"from collections import Counter\\n\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\nC_A = Counter(A)\\nC_B = Counter(B)\\nfor k, v in list(C_A.items()):\\n    if v + C_B[k] > N:\\n        print(\\\"No\\\")\\n        return\\nB = B[::-1]\\nsame_range = []\\nfor i, (a, b) in enumerate(zip(A, B)):\\n    if a == b:\\n        same_range.append(i)\\ni = 0\\nwhile same_range:\\n    v = B[same_range[0]]\\n    if A[i] != v and B[i] != v:\\n        j = same_range.pop()\\n        B[i], B[j] = B[j], B[i]\\n    i += 1\\nprint(\\\"Yes\\\")\\nprint((\\\" \\\".join(map(str, B))))\\n\", \"N = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\n\\ncount = [0] * (N+1)\\nfor a, b in zip(A, B):\\n    count[a] += 1\\n    count[b] += 1\\n\\nfor i in range(N+1):\\n    if count[i] > N:\\n        print('No')\\n        return\\n\\ndiff = 0\\nchecked = set()\\nida = 0\\nfor i, b in enumerate(B):\\n    if b in checked:\\n        continue\\n    checked.add(b)\\n    while ida < N and A[ida] <= b:\\n        ida += 1\\n    diff = max(diff, ida - i)\\n\\n\\nprint('Yes')\\nprint(*(B[-diff:]+B[:-diff]))\", \"import sys\\nINF = 1 << 60\\nMOD = 10**9 + 7 # 998244353\\nsys.setrecursionlimit(2147483647)\\ninput = lambda:sys.stdin.readline().rstrip()\\nfrom collections import Counter\\nfrom random import randrange\\ndef resolve():\\n    n = int(input())\\n    A = list(map(int, input().split()))\\n    B = list(map(int, input().split()))\\n\\n    if Counter(A + B).most_common()[0][1] > n:\\n        print(\\\"No\\\")\\n        return\\n\\n    for i in range(n):\\n        if A[i] != B[i]:\\n            continue\\n        while 1:\\n            j = randrange(0, n)\\n            if A[i] != B[j] and A[j] != B[i]:\\n                B[i], B[j] = B[j], B[i]\\n                break\\n    print(\\\"Yes\\\")\\n    print(*B)\\nresolve()\", \"import math\\nimport numpy as np\\nimport decimal\\nimport collections\\nimport itertools\\nimport sys\\nimport random\\n#Union-Find\\nclass UnionFind():\\n    def __init__(self, n):\\n        self.n = n\\n        self.par = [-1 for i in range(self.n)]\\n    def find(self, x):\\n        if self.par[x] < 0:\\n            return x\\n        else:\\n            self.par[x] = self.find(self.par[x])\\n            return self.par[x]\\n    def unite(self, x, y):\\n        p = self.find(x)\\n        q = self.find(y)\\n        if p == q:\\n            return None\\n        if p > q:\\n            p, q = q, p\\n        self.par[p] += self.par[q]\\n        self.par[q] = p\\n    def same(self, x, y):\\n        return self.find(x) == self.find(y)\\n    def size(self, x):\\n        return -self.par[self.find(x)]\\n\\n#\\u7d20\\u6570\\u95a2\\u9023\\ndef prime_numbers(x):\\n    if x < 2:\\n        return []\\n    prime_numbers = [i for i in range(x)]\\n    prime_numbers[1] = 0\\n    for prime_number in prime_numbers:\\n        if prime_number > math.sqrt(x):\\n            break\\n        if prime_number == 0:\\n            continue\\n        for composite_number in range(2 * prime_number, x, prime_number):\\n            prime_numbers[composite_number] = 0\\n    return [prime_number for prime_number in prime_numbers if prime_number != 0]\\ndef is_prime(x):\\n    if x < 2:\\n        return False\\n    if x == 2 or x == 3 or x == 5:\\n        return True\\n    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:\\n        return False\\n    prime_number = 7\\n    difference = 4\\n    while prime_number <= math.sqrt(x):\\n        if x % prime_number == 0:\\n            return False\\n        prime_number += difference\\n        difference = 6 - difference\\n    return True\\n#Prime-Factorize\\ndef prime_factorize(n):\\n    res = []\\n    while n % 2 == 0:\\n        res.append(2)\\n        n //= 2\\n    f = 3\\n    while f ** 2 <= n:\\n        if n % f == 0:\\n            res.append(f)\\n            n //= f\\n        else:\\n            f += 2\\n    if n != 1:\\n        res.append(n)\\n    return res\\n#nCr\\nmod = 10 ** 9 + 7\\nclass nCr():\\n    def __init__(self, n):\\n        self.n = n\\n        self.fa = [1] * (self.n + 1)\\n        self.fi = [1] * (self.n + 1)\\n        for i in range(1, self.n + 1):\\n            self.fa[i] = self.fa[i - 1] * i % mod\\n            self.fi[i] = pow(self.fa[i], mod - 2, mod)\\n    def comb(self, n, r):\\n        if n < r:return 0\\n        if n < 0 or r < 0:return 0\\n        return self.fa[n] * self.fi[r] % mod * self.fi[n - r] % mod\\n#\\u62e1\\u5f35Euclid\\u306e\\u4e92\\u9664\\u6cd5\\ndef extgcd(a, b, d = 0):\\n    g = a\\n    if b == 0:\\n        x, y = 1, 0\\n    else:\\n        x, y, g = extgcd(b, a % b)\\n        x, y = y, x - a // b * y\\n    return x, y, g\\n#BIT\\nclass BinaryIndexedTree():\\n    def __init__(self, n):\\n        self.n = n\\n        self.BIT = [0] * (self.n + 1)\\n    def add(self, i, x):\\n        while i <= self.n:\\n            self.BIT[i] += x\\n            i += i & -i\\n    def query(self, i):\\n        res = 0\\n        while i > 0:\\n            res += self.BIT[i]\\n            i -= i & -i\\n        return res\\n#Associative Array\\nclass AssociativeArray():\\n    def __init__(self, q):\\n        self.dic = dict()\\n        self.q = q\\n    def solve(self):\\n        for i in range(self.q):\\n            Query = list(map(int, input().split()))\\n            if Query[0] == 0:\\n                x, y, z = Query\\n                self.dic[y] = z\\n            else:\\n                x, y = Query\\n                if y in self.dic:\\n                    print(self.dic[y])\\n                else:\\n                    print(0)\\n#Floor Sum\\ndef floor_sum(n, m, a, b):\\n    res = 0\\n    if a >= m:\\n        res += (n - 1) * n * (a // m) // 2\\n        a %= m\\n    if b >= m:\\n        res += n * (b // m)\\n        b %= m\\n    y_max = (a * n + b) // m\\n    x_max = y_max * m - b\\n    if y_max == 0:\\n        return res\\n    res += y_max * (n + (-x_max // a))\\n    res += floor_sum(y_max, a, m, (a - x_max % a) % a)\\n    return res\\n#Z-Algorithm\\ndef z_algorithm(s):\\n    str_len = len(s)\\n    res = [0] * str_len\\n    res[str_len - 1] = str_len\\n    i, j = 1, 0\\n    while i < str_len:\\n        while i + j < str_len and s[i + j] == s[j]:\\n            j += 1\\n        res[i] = j\\n        if j == 0:\\n            i += 1\\n            continue\\n        k = 1\\n        while i + k < str_len and j > res[k] + k:\\n            res[i + k] = res[k]\\n            k += 1\\n        i += k\\n        j -= k\\n    return res\\nclass Manacher():\\n    def __init__(self, s):\\n        self.s = s\\n    def coustruct(self):\\n        i, j = 0, 0 \\n        s_len = len(self.s)\\n        res = [0] * s_len\\n        while i < s_len:\\n            while i - j >= 0 and i + j < s_len and self.s[i - j] == self.s[i + j]:\\n                j += 1\\n            res[i] = j\\n            k = 1\\n            while i - k >= 0 and k + res[i - k] < j:\\n                k += 1\\n            i += k\\n            j -= k\\n#mod-sqrt\\ndef mod_sqrt(a, p):\\n    if a == 0:\\n        return 0\\n    if p == 2:\\n        return 1\\n    k = (p - 1) // 2\\n    if pow(a, k, p) != 1:\\n        return -1\\n    while True:\\n        n = random.randint(2, p - 1)\\n        r = (n ** 2 - a) % p\\n        if r == 0:\\n            return n\\n        if pow(r, k, p) == p - 1:\\n            break\\n    k += 1\\n    w, x, y, z = n, 1, 1, 0\\n    while k:\\n        if k % 2:\\n            y, z = w * y + r * x * z, x * y + w * z\\n        w, x = w * w + r * x * x, 2 * w * x\\n        w %= p\\n        x %= p\\n        y %= p\\n        z %= p\\n        k >>= 1\\n    return y\\nn = int(input())\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\ncur = 0 \\nbefore = 0\\nfor i in range(n):\\n    if before != a[i]:\\n        cur = 0\\n    if a[i] == b[i]:\\n        while cur < n:\\n            if a[i] != b[cur] and a[i] != a[cur]:\\n                b[i], b[cur] = b[cur], b[i]\\n                break\\n            cur += 1\\n        else:\\n            print(\\\"No\\\");return\\n    before = a[i]\\nprint(\\\"Yes\\\")\\nprint(*b)\", \"#!/usr/bin/env python3\\nfrom collections import Counter\\nINF = 1e12\\n\\n\\ndef main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    B = list(map(int, input().split()))\\n    lA = Counter(A)\\n    lB = Counter(B)\\n    if max(Counter(A+B).values()) > N:\\n        print('No')\\n        return\\n\\n    C = [0] * (N + 1)\\n    D = [0] * (N + 1)\\n    for i in range(N):\\n        C[i + 1] = lA[i + 1] + C[i]\\n        D[i + 1] = lB[i + 1] + D[i]\\n    shift = - INF\\n    for i in range(1, N + 1):\\n        shift = max(shift, C[i] - D[i - 1])\\n    print('Yes')\\n    ans = (B + B + B)[N-shift:2*N-shift]\\n    print((' '.join([str(a) for a in ans])))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import sys\\ninput = sys.stdin.readline\\n\\ndef main():\\n    n = int(input())\\n    alst = list(map(int, input().split()))\\n    blst = list(map(int, input().split()))\\n    a_s = [0 for _ in range(n)]\\n    b_s = [0 for _ in range(n)]\\n    for a in alst:\\n        a_s[a - 1] += 1\\n    for b in blst:\\n        b_s[b - 1] += 1\\n    for a, b in zip(a_s, b_s):\\n        if a + b > n:\\n            print(\\\"No\\\")\\n            return\\n    print(\\\"Yes\\\")\\n    a_total = 0\\n    b_total = 0\\n    cor = -100000\\n    for a, b in zip(a_s, b_s):\\n        a_total += a\\n        cor = max(cor, a_total - b_total)\\n        b_total += b\\n    ans = blst[-cor:] + blst[:-cor]\\n    print(*ans)\\n        \\nmain()\", \"N = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\n\\nT = [(A[i], i) for i in range(N)]+[(B[i], N+i) for i in range(N)]\\nT.sort()\\n\\nP = [-1]*(2*N)\\nfor i in range(N):\\n  if T[i][0]==T[i+N][0]:\\n    print(\\\"No\\\")\\n    return\\n  P[T[i][1]] = T[i+N][1]\\n  P[T[i+N][1]] = T[i][1]\\n\\nbp1 = N\\nfor ap1 in range(N):\\n  if P[ap1]//N==1:\\n    continue\\n  while P[bp1]//N==0:\\n    bp1 += 1\\n  ap2 = P[ap1]\\n  bp2 = P[bp1]\\n  if A[ap1]!=B[bp1-N] and A[ap2]!=B[bp2-N]:\\n    P[ap1] = bp1\\n    P[bp1] = ap1\\n    P[ap2] = bp2\\n    P[bp2] = ap2\\n  else:\\n    P[ap1] = bp2\\n    P[bp1] = ap2\\n    P[ap2] = bp1\\n    P[bp2] = ap1\\n\\nprint(\\\"Yes\\\")\\nprint((\\\" \\\".join(str(B[P[i]-N]) for i in range(N))))\\n\", \"from sys import stdin\\nfrom random import randint\\nfrom time import time\\ninput = lambda: stdin.readline().rstrip()\\nstart = time()\\nn = int(input())\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\nb.reverse()\\nok = 0\\nt = time() - start\\nwhile t < 1.8:\\n    cnt = 0\\n    for i in range(n):\\n        if a[i] == b[i]:\\n            rng = randint(0, n - 1)\\n            b[i], b[rng] = b[rng], b[i]\\n            cnt += 1\\n    if cnt == 0:\\n        ok = 1\\n        break\\n    t = time() - start\\nif ok == 1:\\n    print(\\\"Yes\\\")\\n    print((*b))\\nelse:\\n    print(\\\"No\\\")\\n\", \"from heapq import heappush, heappop\\n\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nall_freq = {}\\n\\ncnt_b = [0] * 220000\\nfor num in b:cnt_b[num] += 1\\n\\n\\nfor num in a:\\n    if num not in all_freq:\\n        all_freq[num] = 0\\n    all_freq[num] += 1\\n\\nfor num in b:\\n    if num not in all_freq:\\n        all_freq[num] = 0\\n    all_freq[num] += 1\\n\\nheap = []\\n\\nfor num, freq in list(all_freq.items()):\\n    if freq > n:\\n        print(\\\"No\\\")\\n        return\\n    if cnt_b[num] > 0:\\n        heappush(heap, (-freq, num))\\n\\nans = []\\n\\ndef get_max():\\n    (freq, num) = heappop(heap)\\n    freq = -freq\\n    while all_freq[num] != freq:\\n        (freq, num) = heappop(heap)\\n        freq = -freq\\n\\n    return num\\n\\nfor num in a:\\n    most_freq_num = get_max()\\n    if most_freq_num != num:\\n        ans.append(most_freq_num)\\n        all_freq[most_freq_num] -= 1\\n        cnt_b[most_freq_num] -= 1\\n        if cnt_b[most_freq_num] > 0:\\n            heappush(heap, (-all_freq[most_freq_num], most_freq_num))\\n    else:\\n        second_freq_num = get_max()\\n        heappush(heap, (-all_freq[most_freq_num], most_freq_num))\\n        ans.append(second_freq_num)\\n        all_freq[second_freq_num] -= 1\\n        cnt_b[second_freq_num] -= 1\\n        if cnt_b[second_freq_num] > 0:\\n            heappush(heap, (-all_freq[second_freq_num], second_freq_num))\\n    all_freq[num] -= 1\\n    if cnt_b[num] == 0:continue\\n    heappush(heap, (-all_freq[num], num))\\n\\nprint(\\\"Yes\\\")\\nprint((*ans))\\n\", \"import sys\\npin=sys.stdin.readline\\n\\nN=int(pin())\\nA=list(map(int,pin().split()))\\nB=list(map(int,pin().split()))\\nC=list(reversed(B))\\n\\nfor i in range(N):\\n  if A[i]==C[i]:\\n    break\\nelse:\\n  print(\\\"Yes\\\")\\n  for k in C:\\n    sys.stdout.write(f\\\"{k} \\\")\\n  print()\\n  return\\nD=B[N//2:]+B[:N//2]\\nfor j in range(N):\\n  if A[j]==D[j]:\\n    print(\\\"No\\\")\\n    break\\nelse:\\n  print(\\\"Yes\\\")\\n  for l in D:\\n    sys.stdout.write(f\\\"{l} \\\")\\n  print()\\n  return\\n\", \"from collections import Counter\\nimport sys\\nimport random\\n \\nN = int(input())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nca = Counter(A)\\ncb = Counter(B)\\nfor i in range(N+1):\\n    if ca[i] + cb[i] > N:\\n        print('No')\\n        return\\n\\nC = [0] * (N+1)\\nD = [0] * (N+1)\\n\\nfor i in range(N):\\n    C[i+1] += C[i] + ca[i+1]\\n    D[i+1] += D[i] + cb[i+1]\\n\\nx = 0\\n\\nfor i in range(N):\\n    x = max(x, C[i+1] - D[i])\\n\\nans = [B[(i-x)%N] for i in range(N)]\\n\\nprint('Yes')\\nprint(*ans)\", \"import collections\\n\\nN=int(input())\\nA=list(map(int,input().split()))\\nB=list(map(int,input().split()))\\n\\nAtmp = 0\\nBtmp = 0\\n\\nINF=10e18\\n\\n\\nC=collections.Counter(A)\\nD=collections.Counter(B)\\n\\ncurrentC = 0\\ncurrentD = 0\\n\\nrotation = 0\\n\\n\\n\\nfor n in range(N+1):\\n\\n\\tif N < C[n] + D[n]:\\n\\t\\trotation = INF\\n\\t\\tbreak\\n\\n\\tcurrentC += C[n]\\n\\trotation = max( rotation, currentC - currentD )\\n\\tcurrentD += D[n]\\n\\nif rotation == INF:\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\\t\\n\\tprint((\\\" \\\".join(map(str,B[-rotation:] + B[:-rotation]))))\\n\\n\\n\\n\\n\", \"n=int(input())\\na=[int(_) for _ in input().split()]\\nb=[int(_) for _ in input().split()]\\n\\nd_a={}\\nd_b={}\\n\\nfor i in range(-1,n):\\n    d_a[i]=0\\n    d_b[i]=0\\n\\nfor i in range(n):\\n    d_a[a[i]-1]+=1\\n    d_b[b[i]-1]+=1\\n\\ndiff=0\\nc,d=0,0\\nfor i in range(n):\\n    if d_a[i]+d_b[i]>n:\\n        print(\\\"No\\\")\\n        return\\n    c+=d_a[i]\\n    d+=d_b[i-1]\\n    diff = max(diff,c-d)\\nprint(\\\"Yes\\\")\\n# for i in range(n):\\n#     print(a[i],end=\\\" \\\")\\n# print()\\nfor i in range(n):\\n    print(b[(i-diff)%n],end=\\\" \\\")\\nprint()\", \"import bisect, heapq\\nN = int(input())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\n\\nfor i in range(1,N+1):\\n    a = bisect.bisect_right(A,i) - bisect.bisect_left(A,i)\\n    b = bisect.bisect_right(B,i) - bisect.bisect_left(B,i)\\n\\n    if a + b > N:\\n        print(\\\"No\\\")\\n        return\\n\\nB = B[::-1]\\n\\nj, bef = 0, -1\\nfor i in range(N):\\n    if A[i] != bef:\\n        j = 0\\n    if A[i] == B[i]:\\n        while j < N:\\n            if A[j] != B[i] and B[j] != A[i]:\\n                B[i], B[j] = B[j], B[i]\\n                break\\n            j += 1\\n    bef = A[i]\\n\\nprint(\\\"Yes\\\")\\nfor b in B:\\n    print(b,end=\\\" \\\")\\nprint(\\\"\\\")\", \"import sys\\n\\nsys.setrecursionlimit(10**6)\\nint1 = lambda x: int(x)-1\\np2D = lambda x: print(*x, sep=\\\"\\\\n\\\")\\ndef II(): return int(sys.stdin.readline())\\ndef MI(): return map(int, sys.stdin.readline().split())\\ndef LI(): return list(map(int, sys.stdin.readline().split()))\\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\\ndef SI(): return sys.stdin.readline()[:-1]\\n\\ndef lr(xx):\\n    ll=[-1]*(n+1)\\n    rr=[-1]*(n+1)\\n    for i,x in enumerate(xx):\\n        if ll[x]==-1:ll[x]=i\\n        if i==n-1 or x!=xx[i+1]:rr[x]=i+1\\n    return ll,rr\\n\\nn=II()\\naa=LI()\\nbb=LI()\\nall,arr=lr(aa)\\nbll,brr=lr(bb)\\n# print(all,arr)\\nca=[0]*(n+1)\\ncb=[0]*(n+1)\\nfor a in aa:ca[a]+=1\\nfor b in bb:cb[b]+=1\\nfor i in range(n+1):\\n    if ca[i]+cb[i]>n:\\n        print(\\\"No\\\")\\n        return\\nng=[0]*(n+1)\\nfor al,ar,bl,br in zip(all,arr,bll,brr):\\n    if al==-1 or bl==-1:continue\\n    if bl<ar:\\n        mn=max(0,al-br+1)\\n        mx=ar-bl\\n        ng[mn]+=1\\n        ng[mx]-=1\\n    else:\\n        mn=max(0,al+n-br+1)\\n        mx=min(n,ar+n-bl)\\n        ng[mn]+=1\\n        ng[mx]-=1\\n# print(ng)\\nfor i in range(n):ng[i+1]+=ng[i]\\nshift=-1\\nfor i in range(n):\\n    if ng[i]==0:\\n        shift=i\\n        break\\nans=bb[-shift:]+bb[:-shift]\\nprint(\\\"Yes\\\")\\nprint(*ans)\\n\", \"#!/usr/bin/env python3\\nfrom itertools import accumulate\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\n\\nidx_B = 0\\nma = 0\\nfor idx_A, a in enumerate(A):\\n    while idx_B < N and B[idx_B] < a:\\n        idx_B += 1\\n    if ma < idx_A - idx_B:\\n        ma = idx_A-idx_B\\n\\nAns = (B+B)[N-ma-1:2*N-ma-1]\\n\\nfor a, b in zip(A, Ans):\\n    if a == b:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\\nprint((*Ans))\\n\", \"from collections import Counter, deque\\n\\nN = int(input())\\nA = list(map(int, input().split())) + [N+1]\\nB = list(map(int, input().split())) + [N+1]\\nC = [0]\\nD = [0]\\n\\nAB_cn = Counter(A+B)\\nif AB_cn.most_common()[0][1] > N:\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n    for i in range(N+1):\\n        if len(C) != A[i]:\\n            C.extend([i]*(A[i]-len(C)))\\n        if len(D) != B[i]:\\n            D.extend([i]*(B[i]-len(D)))\\n    ans = -100000000000000000\\n    for i in range(N):\\n        curr = C[i+1] - D[i]\\n        ans= max(curr, ans)\\n    B = B[:-1]\\n    print((*[B[(i-ans)%N] for i in range(N)]))\\n\\n\", \"N = int(input())\\nA = [int(a) for a in input().split()]\\nB = [int(a) for a in input().split()]\\nC = [0]*N\\nD = [0]*N\\nc = d = 0\\nfor i in range(N):\\n    a = A[i]\\n    b = B[i]\\n    if C[a-1]==0:\\n        for j in range(c,a): C[j]=C[c]\\n        c=a-1\\n        C[c]=C[c-1]+1\\n    else: C[a-1]+=1\\n    if D[b-1]==0:\\n        for j in range(d,b): D[j]=D[d]\\n        d=b-1\\n        D[d]=D[d-1]+1\\n    else: D[b-1]+=1\\nfor j in range(c,N): C[j]=C[c]\\nfor j in range(d,N): D[j]=D[d]\\nE = [0]*N\\nfor i in range(N):\\n    if i==0: E[i] = C[i] + D[i]\\n    else:\\n        E[i] = C[i]-C[i-1] + D[i]-D[i-1]\\n#print(C,D,E)\\nif max(E)>N: print(\\\"No\\\")\\nelse:\\n    for i in range(N):\\n        if i==0: x=C[i]\\n        if x < C[i]-D[i-1]: x = C[i]-D[i-1]\\n    B_ = [0]*N\\n    #print(x)\\n    for i in range(N):\\n        B_[(i+x)%N] = B[i]\\n    print(\\\"Yes\\\")\\n    print(*B_,sep=' ')\", \"import sys\\nimport collections\\n\\nsys.setrecursionlimit(10 ** 8)\\n\\ninput = sys.stdin.readline\\n\\n\\ndef main():\\n    N = int(input())\\n    A = [int(x) for x in input().split()]\\n    B = [int(x) for x in input().split()]\\n\\n    ac = collections.Counter(A)\\n    bc = collections.Counter(B)\\n\\n    for i in range(1, N + 1):\\n        if ac[i] + bc[i] > N:\\n            print(\\\"No\\\")\\n            return\\n\\n    ma = 0\\n    cnta = 0\\n    cntb = 0\\n    for i in range(1, N + 1):\\n        cnta += ac[i]\\n        cntb += bc[i - 1]\\n        ma = max(ma, cnta - cntb)\\n\\n    print(\\\"Yes\\\")\\n    ans = []\\n    for i in range(N):\\n        ans.append(B[(i + N - ma) % N])\\n    print((*ans))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import numpy as np\\nimport sys \\nread = sys.stdin.readline\\nn = int(input())\\na = np.fromstring(read(), dtype=np.int32, sep=' ')\\nb = np.fromstring(read(), dtype=np.int32, sep=' ')[::-1]\\n\\nkokan = []\\nsame = -1\\nfor i in range(n):\\n    if a[i] == b[i]:\\n        same = a[i]\\nif same == -1:\\n    print('Yes')\\n    print(*b)\\n    return\\n\\nfor i in range(n):\\n    if a[i] != b[i] and a[i] != same and b[i] != same:\\n        kokan.append(i)\\nfor i in range(n):\\n    if a[i] == b[i]:\\n        if len(kokan) == 0:\\n            print('No')\\n            return\\n        else:\\n            j = kokan[-1]\\n            b[i], b[j] = b[j], b[i] \\n            kokan.pop()\\nprint('Yes')\\nprint(*b)\", \"n=int(input())\\na=list(map(int,input().split()))\\nb=list(map(int,input().split()))\\nb.reverse()\\nc=[0]*(n+1)\\nfor i in a:\\n  c[i]+=1\\nfor i in b:\\n  c[i]+=1\\nif n<max(c):\\n  print('No')\\n  return\\nl=0\\nwhile l<n and a[l]!=b[l]:\\n  l+=1\\ni=0\\nwhile l<n and a[l]==b[l]:\\n  while a[i]==b[l] or a[l]==b[i]:\\n    i+=1\\n  b[i],b[l]=b[l],b[i]\\n  l+=1\\nprint('Yes')\\nprint(' '.join([str(i) for i in b]))\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr1=list(map(int,input().split()))\\narr2=list(map(int,input().split()))\\ncnt1=collections.Counter(arr1)\\ncnt2=collections.Counter(arr2)\\ntmp=[[key,cnt1[key]] for key in cnt1.keys()]\\ntmp=sorted(tmp,reverse=True,key=lambda x:x[1])\\narr3=[]\\nfor key,cnt in tmp:\\n    for _ in range(cnt):\\n        arr3.append(key)\\ncnt1=collections.Counter(arr3)\\nans=[0]*n\\nacum=0\\npos=0\\nblank=0\\nok=0\\nhead=[]\\nfor key in cnt1.keys():\\n    tcnt1=cnt1[key]\\n    tcnt2=cnt2[key]\\n    acum+=tcnt1\\n    tpos=max(acum,pos)\\n    tmp=n-min(tpos,n)\\n    if blank+tmp<tcnt2:\\n        print('No')\\n        return\\n    blank=min(tpos,n)-ok\\n    remain=tcnt2\\n    #print(key,blank,remain)\\n    for i in range(tpos,n):\\n        if remain==0:\\n            break\\n        ans[i]=key\\n        ok+=1\\n        remain-=1\\n        cnt2[key]-=1\\n    for _ in range(remain):\\n        head.append(key)\\n        cnt2[key]-=1\\n    pos=min(tpos+tcnt2,n)\\n    #print(ans,head,pos)\\nfor key in cnt2.keys():\\n    if cnt2[key]==0:\\n        continue\\n    for _ in range(cnt2[key]):\\n        head.append(key)\\npos=0\\nfor i in range(n):\\n    if ans[i]==0:\\n        ans[i]=head[pos]\\n        pos+=1\\ntmp=[[ans[i],arr3[i]] for i in range(n)]\\ntmp=sorted(tmp,key=lambda x:x[1])\\nans=[tmp[i][0] for i in range(n)]\\nprint('Yes')\\nprint(*ans)\", \"import sys\\nimport collections\\n\\nsys.setrecursionlimit(10 ** 8)\\n\\ninput = sys.stdin.readline\\n\\n\\ndef main():\\n    N = int(input())\\n    A = [int(x) for x in input().split()]\\n    B = [int(x) for x in input().split()]\\n\\n    ac = collections.Counter(A)\\n    bc = collections.Counter(B)\\n\\n    for i in range(1, N + 1):\\n        if ac[i] + bc[i] > N:\\n            print(\\\"No\\\")\\n            return\\n\\n    ma = 0\\n    cnta = 0\\n    cntb = 0\\n    for i in range(1, N + 1):\\n        cnta += ac[i]\\n        cntb += bc[i - 1]\\n        ma = max(ma, cnta - cntb)\\n\\n    print(\\\"Yes\\\")\\n\\n    ans = B[N - ma:] + B[:N - ma]\\n    print((*ans))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\n\\nimport heapq\\nimport collections\\nimport sys\\ninput=sys.stdin.readline\\n\\nn=int(input())\\narr1=list(map(int,input().split()))\\narr2=list(map(int,input().split()))\\ncnt1=collections.Counter(arr1)\\ncnt2=collections.Counter(arr2)\\ntmp=[[key,cnt1[key]] for key in cnt1.keys()]\\ntmp=sorted(tmp,reverse=True,key=lambda x:x[1])\\narr3=[]\\nfor key,cnt in tmp:\\n  for _ in range(cnt):\\n    arr3.append(key)\\ncnt3=collections.Counter(arr3)\\nans=[0]*n\\nacum=0\\npos=0\\nhead=[]\\ntail=[]\\nfor key in cnt3.keys():\\n    tcnt1=cnt3[key]\\n    tcnt2=cnt2[key]\\n    if tcnt1+tcnt2>n:\\n        print('No')\\n        return\\n    acum+=tcnt1\\n    tpos=max(acum,pos)\\n    remain=tcnt2\\n    #print(key,blank,remain)\\n    for i in range(tpos,n):\\n        if remain==0:\\n            break\\n        ans[i]=key\\n        remain-=1\\n        cnt2[key]-=1\\n    for _ in range(remain):\\n      if tpos!=pos:\\n        head.append(key)\\n      else:\\n        tail.append(key)\\n      cnt2[key]-=1\\n    pos=min(tpos+tcnt2,n)\\n    #print(ans,head,pos)\\nfor key in cnt2.keys():\\n    if cnt2[key]==0:\\n        continue\\n    for _ in range(cnt2[key]):\\n        tail.append(key)\\npos=0\\nhead+=tail\\nfor i in range(n):\\n    if ans[i]==0:\\n        ans[i]=head[pos]\\n        pos+=1\\nq=[]\\nfor i in range(n):\\n  heapq.heappush(q,(arr3[i],ans[i]))\\nfor i in range(n):\\n  _,val=heapq.heappop(q)\\n  ans[i]=val\\nprint('Yes')\\nprint(*ans)\", \"# \\u89e3\\u8aac\\u3092\\u53c2\\u8003\\u306b\\u4f5c\\u6210\\n# import sys\\n# sys.setrecursionlimit(10 ** 6)\\n# import bisect\\n# from collections import deque\\n# from decorator import stop_watch\\n#\\n#\\n# @stop_watch\\ndef solve(N, Ai, Bi):\\n    Ci = [0] * (N + 1)\\n    Di = [0] * (N + 1)\\n    j = 0\\n    k = 0\\n    for i in range(1, N + 1):\\n        while j < N and Ai[j] <= i:\\n            j += 1\\n        Ci[i] = j\\n        while k < N and Bi[k] <= i:\\n            k += 1\\n        Di[i] = k\\n    # print(Ci)\\n    # print(Di)\\n    for i in range(1, N + 1):\\n        if Ci[i] - Ci[i - 1] + Di[i] - Di[i - 1] > N:\\n            print('No')\\n            return\\n    x = 0\\n    for i in range(1, N + 1):\\n        x = max(x, Ci[i] - Di[i - 1])\\n    print('Yes')\\n    # print(x)\\n    # print(' '.join([str(a) for a in Ai]))\\n    print((' '.join([str(Bi[(N - x + i) % N]) for i in range(N)])))\\n\\n\\ndef __starting_point():\\n    # S = input()\\n    N = int(input())\\n    # N, M = map(int, input().split())\\n    Ai = [int(i) for i in input().split()]\\n    Bi = [int(i) for i in input().split()]\\n    # ABi = [[int(i) for i in input().split()] for _ in range(N)]\\n    solve(N, Ai, Bi)\\n\\n    # # test\\n    # from random import randint\\n    # from func import random_str\\n    # solve()\\n\\n__starting_point()\", \"from collections import Counter, deque\\n\\nN = int(input())\\nA = list(map(int, input().split())) + [N+1]\\nB = list(map(int, input().split())) + [N+1]\\nC = [0]\\nD = [0]\\n\\nAB_cn = Counter(A+B)\\nif AB_cn.most_common()[0][1] > N:\\n    print(\\\"No\\\")\\nelse:\\n    print(\\\"Yes\\\")\\n    for i in range(N+1):\\n        if len(C) != A[i]:\\n            C.extend([i]*(A[i]-len(C)))\\n        if len(D) != B[i]:\\n            D.extend([i]*(B[i]-len(D)))\\n    ans = 0\\n    for i in range(N):\\n        curr = C[i+1] - D[i]\\n        ans= max(curr, ans)\\n    B = B[:-1]\\n    print(*[B[(i-ans)%N] for i in range(N)])\", \"import sys\\nsys.setrecursionlimit(10 ** 9)\\n# input = sys.stdin.readline    ####\\ndef int1(x): return int(x) - 1\\ndef II(): return int(input())\\ndef MI(): return list(map(int, input().split()))\\ndef MI1(): return list(map(int1, input().split()))\\ndef LI(): return list(map(int, input().split()))\\ndef LI1(): return list(map(int1, input().split()))\\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\\ndef MS(): return input().split()\\ndef LS(): return list(input())\\ndef LLS(rows_number): return [LS() for _ in range(rows_number)]\\ndef printlist(lst, k=' '): print((k.join(list(map(str, lst)))))\\nINF = float('inf')\\n# from math import ceil, floor, log2\\n# from collections import deque, defaultdict\\n# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations\\n# from heapq import heapify, heappop, heappush\\n# import numpy as np    # cumsum\\n# from bisect import bisect_left, bisect_right\\n\\ndef solve():\\n    N = II()\\n    A = LI()\\n    B = sorted(LI(), reverse=True)\\n    tmp = []\\n    for i in range(N):\\n        if A[i] == B[i]:\\n            tmp.append((i, A[i]))\\n\\n    j = 0\\n    while tmp:\\n        idx, x = tmp.pop()\\n        for i in range(j, N):\\n            b = B[i]\\n            j = i + 1\\n            if i == idx: continue\\n            if b != x and x != A[i]:\\n                B[i], B[idx] = B[idx], B[i]\\n                break\\n        else:\\n            print('No')\\n            return\\n    print('Yes')\\n    print((*B))\\n\\n\\ndef __starting_point():\\n    solve()\\n\\n\\n__starting_point()\", \"N = int(input())\\nA = [int(x) for x in input().split()]\\nB = [int(x) for x in input().split()]\\n\\na = [0]*(N + 1)\\nb = [0]*(N + 1)\\nfor i in range(N):\\n    a[A[i]] += 1\\n    b[B[i]] += 1\\n\\nok = True\\nfor i in range(1, N + 1):\\n    if a[i] + b[i] > N:\\n        ok = False\\n\\nsa = [0]*(N + 1)\\nsb = [0]*(N + 1)\\nfor i in range(N):\\n    sa[i + 1] = sa[i] + a[i + 1]\\n    sb[i + 1] = sb[i] + b[i + 1]\\n\\nans = 0\\nfor i in range(N):\\n    ans = max(ans, sa[i + 1] - sb[i])\\n\\nif ok:\\n    print(\\\"Yes\\\")\\n    for i in range(N):\\n        print(B[(i + N - ans) % N], end='')\\n        if i == N - 1:\\n            print('')\\n        else:\\n            print(' ', end='')\\nelse:\\n    print(\\\"No\\\")\", \"import sys, re\\nfrom collections import deque, defaultdict, Counter\\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\\nfrom operator import itemgetter, mul\\nfrom copy import deepcopy\\nfrom string import ascii_lowercase, ascii_uppercase, digits\\nfrom bisect import bisect, bisect_left, insort, insort_left\\nfrom heapq import heappush, heappop\\nfrom functools import reduce, lru_cache\\ndef input(): return sys.stdin.readline().strip()\\ndef INT(): return int(input())\\ndef MAP(): return list(map(int, input().split()))\\ndef LIST(): return list(map(int, input().split()))\\ndef TUPLE(): return tuple(map(int, input().split()))\\ndef ZIP(n): return list(zip(*(MAP() for _ in range(n))))\\nsys.setrecursionlimit(10 ** 9)\\nINF = 10**6#float('inf')\\nmod = 10 ** 9 + 7 \\n#mod = 998244353\\n#from decimal import *\\n#import numpy as np\\n#decimal.getcontext().prec = 10\\n\\nN = INT()\\nA = LIST()\\nB = LIST()\\n\\nCA = Counter(A)\\nCB = Counter(B)\\n\\nfor k in list(CB.keys()):\\n\\tif CB[k] > N-CA[k]:\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\nelse:\\n\\tprint(\\\"Yes\\\")\\n\\nB = B[::-1]\\n\\nj = 0\\njdx = 1\\n\\nfor i in range(N):\\n\\tif A[i] == B[i]:\\n\\t\\tif B[i] == B[j] or B[i] == A[j]:\\n\\t\\t\\tj = -1\\n\\t\\t\\tjdx = -1\\n\\t\\tB[i], B[j] = B[j], B[i]\\n\\t\\tj += jdx\\n\\nprint((*B))\\n\\n\\n\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nreadline = sys.stdin.readline\\nread = sys.stdin.read\\n\\nn, = map(int,readline().split())\\n*a, = map(int,readline().split())\\n*b, = map(int,readline().split())\\nb = b[::-1]\\n\\nsame = [i for i in range(n) if a[i] == b[i]]\\nif same:\\n    v = a[same[0]] # b \\u3092\\u9006\\u9806\\u306b\\u3057\\u305f\\u306e\\u3067\\u3001\\u91cd\\u306a\\u308b\\u5024\\u306f\\u4e00\\u7a2e\\u985e\\u3057\\u304b\\u306a\\u3044\\u3002\\u3053\\u308c\\u3092 v \\u3068\\u304a\\u304f\\u3002\\n    r = same[0]\\n    s = same[-1]+1\\n    notv = [i for i in range(n) if a[i]!=v and b[i]!=v] # \\u3069\\u3063\\u3061\\u3082v\\u3068\\u304b\\u3076\\u3089\\u306a\\u3044 index\\n    if len(same) > len(notv):\\n        print(\\\"No\\\")\\n        return\\n    \\n    for i,j in zip(same,notv):\\n        b[i],b[j] = b[j],b[i]\\n\\nprint(\\\"Yes\\\")\\nprint(*b)\", \"n=int(input())\\na=list(map(int,input().split()))\\nb=list(map(int,input().split()))\\nb.reverse()\\nc=[0]*(n+1)\\nfor i in a:\\n  c[i]+=1 #\\u540c\\u3058\\u6570\\u304c\\u3044\\u304f\\u3064\\u3042\\u308b\\u304b\\nfor i in b:\\n  c[i]+=1\\nif max(c)>n:\\n  print('No')\\n  return\\nl=0\\nwhile l<n and a[l]!=b[l]: #\\u304b\\u3076\\u308b\\u307e\\u3067\\u306e\\u6570\\n  l+=1\\ni=0\\nwhile l<n and a[l]==b[l]: #\\u304b\\u3076\\u308a\\u59cb\\u3081\\u3066\\u304b\\u3089\\u304b\\u3076\\u308a\\u7d9a\\u3051\\u308b\\u9650\\u308a\\n  while a[i]==b[l] or a[l]==b[i]: #i\\u756a\\u76ee\\u3068\\u5165\\u308c\\u66ff\\u3048\\u3066\\u3082\\u304b\\u3076\\u308b\\u5834\\u5408\\n    i+=1\\n  b[i],b[l]=b[l],b[i] #\\u304b\\u3076\\u3089\\u306a\\u3044\\u3053\\u3068\\u3092\\u78ba\\u8a8d\\u3057\\u3066\\u304b\\u3089\\u5165\\u308c\\u66ff\\u3048\\n  l+=1\\nprint('Yes')\\nprint(' '.join([str(i) for i in b]))\", \"n = int(input())\\nlst_a = [int(i) for i in input().split()]\\nlst_b = [int(i) for i in input().split()]\\nj = 0\\nflag = True\\nfor i in range(n):\\n  if i > 0:\\n    if lst_a[i] != lst_a[i - 1]:\\n      j = 0\\n  if lst_a[i] != lst_b[i]:\\n    continue\\n  else:\\n    flag = False\\n    while j != n:\\n      if lst_a[i] != lst_b[j] and lst_a[j] != lst_b[i]:\\n        lst_b[i], lst_b[j] = lst_b[j], lst_b[i]\\n        flag = True\\n        break\\n      j += 1\\n    if not flag:\\n      break\\nif not flag:\\n  print('No')\\nelse:\\n  print('Yes')\\n  lst_b = [str(i) for i in lst_b]\\n  print(' '.join(lst_b))\", \"from collections import Counter\\nimport numpy as np\\n\\n\\ndef main():\\n    n = int(input())\\n    a = np.array([int(i) for i in input().split()])\\n    b = np.array([int(i) for i in input().split()])\\n    ca = Counter(a)\\n    cb = Counter(b)\\n    for k in list(cb.keys()):\\n        if cb[k] > n - ca[k]:\\n            print(\\\"No\\\")\\n            return\\n    shift = max(ca[k] for k in list(cb.keys()))\\n    while any(a == b):\\n        b = np.roll(b, shift)\\n    print(\\\"Yes\\\")\\n    print((*b))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nreadline = sys.stdin.readline\\nread = sys.stdin.read\\n\\nn, = list(map(int,readline().split()))\\n*a, = [2*int(x) for x in readline().split()]\\n*b, = [2*int(x)+1 for x in readline().split()]\\n\\nc = sorted(a+b)\\nres = []\\naa = []\\nbb = []\\nfor x,y in zip(c[:n],c[n:]):\\n    if x%2 == 0:\\n        if y%2 == 0:\\n            aa.append((x//2,y//2))\\n        else:\\n            res.append((x//2,y//2))\\n    else:\\n        if y%2 == 0:\\n            res.append((y//2,x//2))\\n        else:\\n            bb.append((x//2,y//2))\\n\\nwhile aa:\\n    p,q = aa.pop()\\n    r,s = bb.pop()\\n    if p != r and q != s:\\n        res.append((p,r))\\n        res.append((q,s))\\n    else:\\n        res.append((p,s))\\n        res.append((q,r))\\n\\nfrom operator import itemgetter\\nres.sort(key = itemgetter(0))\\n\\nfor x,y in res:\\n    if x==y:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\\nans = [y for x,y in res]\\nprint((*ans))\\n\\n\\n\", \"def solve():    \\n    n = int(input())\\n    a = list(map(int,input().split()))\\n    b = list(map(int,input().split()))\\n    b = b[::-1]\\n    \\n    l = []\\n    num = -1\\n    for i in range(n):\\n        if a[i] == b[i]:\\n            l.append(i)\\n            num = a[i]\\n    \\n    ind = 0\\n    for i in range(n):\\n        if b[i] != num and a[i] != num and ind < len(l):\\n            b[i], b[l[ind]] = b[l[ind]], b[i]\\n            ind += 1\\n    \\n    if ind < len(l):\\n        print('No')\\n    else:\\n        print('Yes')\\n        print(*b)\\n    \\n                        \\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"N = int(input())\\n\\nA_list = list(map(int, input().split()))\\nB_list = list(map(int, input().split()))\\n\\ntotal_table = {}\\n\\ndef make_table(l):\\n\\ttable = {}\\n\\tfor v in l:\\n\\t\\tif v in table:\\n\\t\\t\\ttable[v] += 1\\n\\t\\telse:\\n\\t\\t\\ttable[v] = 1\\n\\t\\tif v in total_table:\\n\\t\\t\\ttotal_table[v] += 1\\n\\t\\telse:\\n\\t\\t\\ttotal_table[v] = 1\\n\\treturn table\\n\\nA_table = make_table(A_list)\\nB_table = make_table(B_list)\\n\\ntotal_list = []\\nfor v, c in list(total_table.items()):\\n\\ttotal_list.append((c, v))\\n\\ntotal_list.sort()\\ntotal_list.reverse()\\n\\nA_head = []\\nA_tail = []\\nB_head = []\\nB_tail = []\\nfor c, v in total_list:\\n\\ta = A_table[v] if v in A_table else 0\\n\\tb = B_table[v] if v in B_table else 0\\n#\\tprint(c, a, b)\\n\\twhile a > 0 and len(A_head) + len(B_head) < N:\\n\\t\\tA_head.append(v)\\n\\t\\ta -= 1\\n\\t\\n\\twhile b > 0 and len(A_head) + len(B_head) < N:\\n\\t\\tB_head.append(v)\\n\\t\\tb -= 1\\n\\t\\n\\twhile a > 0:\\n\\t\\tA_tail.append(v)\\n\\t\\ta -= 1\\n\\t\\n\\twhile b > 0:\\n\\t\\tB_tail.append(v)\\n\\t\\tb -= 1\\n\\n#print(A_head)\\n#print(A_tail)\\n#print(B_head)\\n#print(B_tail)\\n\\nA_tail.reverse()\\nB_head.reverse()\\n\\nA_list = A_head + A_tail\\nB_list = B_tail + B_head\\n\\n#print(A_list)\\n#print(B_list)\\n\\ndef check():\\n\\tfor a, b in zip(A_list, B_list):\\n\\t\\tif a == b:\\n\\t\\t\\treturn False\\n\\telse:\\n\\t\\treturn True\\n\\nif check():\\n\\tAB_list = list(zip(A_list, B_list))\\n\\tAB_list.sort()\\n\\tprint(\\\"Yes\\\")\\n\\tprint((*(b for a, b in AB_list)))\\nelse:\\n\\tprint(\\\"No\\\")\\n\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nreadline = sys.stdin.readline\\nread = sys.stdin.read\\n\\nn, = list(map(int,readline().split()))\\n*a, = list(map(int,readline().split()))\\n*b, = list(map(int,readline().split()))\\nb = b[::-1]\\nfrom collections import Counter\\nd = Counter(a+b)\\nif max(d.values()) > n:\\n    print(\\\"No\\\")\\n    return\\n\\nsame = set(i for i in range(n) if a[i]==b[i])\\nfrom random import randrange\\nwhile same:\\n    i = same.pop()\\n    while True:\\n        j = randrange(0,n)\\n        if a[j] != b[i] and a[i] != b[j]:\\n            b[i],b[j] = b[j],b[i]\\n            same.discard(j)\\n            break\\n\\nprint(\\\"Yes\\\")\\nprint((*b))\\n\", \"import sys\\ninput = sys.stdin.readline\\nN = int(input())\\nA = list(map(int,input().split()))\\nB = list(map(int,input().split()))\\nRB = B[::-1]\\n\\nstart = v = -1\\nseq = 0\\nfor i,(a,b) in enumerate(zip(A,RB)):\\n    if a==b:\\n        v = a\\n        seq += 1\\n        if start == -1:\\n            start = i\\n\\nif v == -1:\\n    print('Yes')\\n    print(*RB)\\n    return\\n\\nif A.count(v) + B.count(v) > N:\\n    print('No')\\n    return\\n\\nfrom bisect import bisect_left,bisect\\nal = bisect_left(A,v)\\nbl = bisect_left(B,v)\\nbr = bisect(B,v)\\nrbl = N - br\\n\\nm = min(seq,start,al,rbl)\\nRB[:m],RB[start:start+m] = RB[start:start+m],RB[:m]\\nseq -= m\\nstart += m\\nif seq:\\n    RB[start:start+seq],RB[-seq:] = RB[-seq:],RB[start:start+seq]\\n\\nassert all(a!=b for a,b in zip(A,RB))\\nprint('Yes')\\nprint(*RB)\", \"def Next(): return input()\\ndef NextInt(): return int(Next())\\ndef NextInts(): return map(int,input().split())\\ndef Nexts(): return map(str,input().split())\\ndef NextIntList(): return list(map(int,input().split()))\\ndef RowInts(n): return [input() for i in range(n)]\\n\\ndef output(ans):\\n    print(\\\"Yes\\\")\\n    size = len(ans)\\n    for i in range(size):\\n        if i == size-1:\\n            print(ans[i])\\n        else:\\n            print(ans[i], end=' ')\\n\\nn = NextInt()\\na = NextIntList()\\nb = NextIntList()[::-1]\\n\\n\\ndef solve():\\n    border = n-1\\n    for i in range(n):\\n        if(a[i] >= b[i]):\\n            border = i\\n            break\\n    if a[border] != b[border]:\\n        output(b)\\n        return\\n    key = a[border]\\n    if a.count(key)+b.count(key) > n:\\n        print(\\\"No\\\")\\n        return\\n    cnt = a[:border].count(key) + b[:border].count(key)\\n\\n    for i in range(border, n):\\n        if a[i] != key or b[i] != key:\\n            output(b[i-1::-1] + b[:i-1:-1])\\n            return\\n        cnt += 2\\n        if cnt == i+1:\\n            output(b[i::-1] + b[:i:-1])\\n            return\\n    output(b[::-1])\\n\\nsolve()\", \"from collections import Counter\\n\\n\\nN = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\nC_A = Counter(A)\\nC_B = Counter(B)\\nfor k, v in list(C_A.items()):\\n    if v + C_B[k] > N:\\n        print(\\\"No\\\")\\n        return\\nB = B[::-1]\\nsame_range = []\\nfor i, (a, b) in enumerate(zip(A, B)):\\n    if a == b:\\n        same_range.append(i)\\nif same_range:\\n    same_v = B[same_range[0]]\\n    for i in range(N):\\n        if not same_range:\\n            break\\n        if A[i] == same_v or B[i] == same_v:\\n            continue\\n        j = same_range.pop()\\n        B[i], B[j] = B[j], B[i]\\nprint(\\\"Yes\\\")\\nprint((\\\" \\\".join(map(str, B))))\\n\", \"# \\u89e3\\u8aac\\u3092\\u53c2\\u8003\\u306b\\u4f5c\\u6210\\n# import sys\\n# sys.setrecursionlimit(10 ** 6)\\n# import bisect\\n# from collections import deque\\n# from decorator import stop_watch\\n# \\n# \\n# @stop_watch\\ndef solve(N, A, B):\\n    buf = -1\\n    key = 0\\n    for i in range(N):\\n        if buf != A[i]:\\n            key = 0  # \\u524d\\u56de(A[i - 1])\\u3068\\u540c\\u3058\\u5024\\u3058\\u3083\\u306a\\u3051\\u308c\\u3070\\u30ea\\u30bb\\u30c3\\u30c8\\n        if A[i] == B[i]:\\n            for j in range(key, N):\\n                if A[i] != A[j] and B[j] != A[i]:\\n                    B[i], B[j] = B[j], B[i]\\n                    key = j\\n                    break\\n            else:\\n                print('No')\\n                return\\n        buf = A[i]\\n    print('Yes')\\n    print((' '.join([str(i) for i in B])))\\n\\n\\ndef __starting_point():\\n    # S = input()\\n    N = int(input())\\n    # N, M = map(int, input().split())\\n    A = [int(i) for i in input().split()]\\n    B = [int(i) for i in input().split()]\\n    # ABi = [[int(i) for i in input().split()] for _ in range(N)]\\n    solve(N, A, B)\\n\\n    # # test\\n    # from random import randint\\n    # from func import random_str\\n    # solve()\\n\\n__starting_point()\", \"from itertools import accumulate\\nimport sys\\ninput = sys.stdin.readline\\nsys.setrecursionlimit(10**9)\\n\\ndef solve():\\n    INF = 10**10\\n\\n    N = int(input())\\n    As = list(map(int, input().split())) + [INF]\\n    Bs = list(map(int, input().split())) + [INF]\\n\\n    def f(As):\\n        sts = [-1] * (N+1)\\n        ens = [-1] * (N+1)\\n        i = 0\\n        for v in range(1, N+1):\\n            if As[i] == v:\\n                sts[v] = i\\n            else:\\n                continue\\n            while As[i] == v:\\n                i += 1\\n            ens[v] = i-1\\n        return (sts, ens)\\n\\n    stAs, enAs = f(As)\\n    stBs, enBs = f(Bs)\\n\\n    imoss = [0] * (2*N+1)\\n    for v in range(1, N+1):\\n        if stAs[v] == -1 or stBs[v] == -1: continue\\n        L = stAs[v] - enBs[v] + N\\n        R = enAs[v] - stBs[v] + N\\n        imoss[L] += 1\\n        imoss[R+1] -= 1\\n\\n    imoss = list(accumulate(imoss))\\n\\n    Cs = [imoss[i] + imoss[i+N] for i in range(N)]\\n\\n    numShift = -1\\n    for i in range(N):\\n        if Cs[i] == 0:\\n            numShift = i\\n            break\\n\\n    if numShift == -1:\\n        print('No')\\n    else:\\n        print('Yes')\\n        anss = [Bs[(i-numShift)%N] for i in range(N)]\\n        print((' '.join(map(str, anss))))\\n\\n\\nsolve()\\n\", \"N=int(input())\\nA=list(map(int, input().split()))\\nB=list(map(int, input().split()))\\nfrom collections import Counter as co\\nfrom collections import defaultdict\\nD,E=co(A),co(B)\\nfor i in D:\\n  if D[i]+E[i]>N:\\n    print('No')\\n    return\\n\\nd=defaultdict(int)\\nfor i,e in enumerate(A):\\n  d[e]=i\\nans=0\\nfor i,e in enumerate(B):\\n  ans=max(ans,(d[e]-i+1))\\ns=B[-ans:]+B[:-ans]\\nprint('Yes')\\nprint(*s)\", \"from itertools import groupby\\n\\nn = int(input())\\naaa = list(map(int, input().split()))\\nbbb = list(map(int, input().split()))\\n\\nidx_a = {}\\ncnt_a = {}\\ni = 0\\nfor a, itr in groupby(aaa):\\n    cnt = len(list(itr))\\n    i += cnt\\n    idx_a[a] = i\\n    cnt_a[a] = cnt\\n\\nidx_b = {}\\ncnt_b = {}\\ni = 0\\nfor b, itr in groupby(bbb):\\n    cnt = len(list(itr))\\n    idx_b[b] = i\\n    cnt_b[b] = cnt\\n    i += cnt\\n\\nslide = 0\\nfor a in idx_a:\\n    if a not in idx_b:\\n        continue\\n    if cnt_a[a] + cnt_b[a] > n:\\n        print('No')\\n        return\\n    slide = max(slide, idx_a[a] - idx_b[a])\\n\\nprint('Yes')\\nif slide > 0:\\n    bbb = bbb[-slide:] + bbb[:-slide]\\nprint((*bbb))\\n\", \"from collections import Counter, defaultdict\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nca = Counter(a)\\ncb = Counter(b)\\n\\nfor ka, va in list(ca.items()):\\n    vb = cb[ka]\\n    if va + vb > n:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\\nend = defaultdict(int)\\nfor i, e in enumerate(a):\\n    end[e] = i\\n\\nmx = 0\\nfor i, e in enumerate(b):\\n    diff = end[e] - i + 1\\n    mx = max(mx, diff)\\n\\nans = b[-mx:] + b[:-mx]\\nprint((*ans))\\n\", \"def main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    B = list(map(int, input().split()))\\n    cnt = [0] * (N + 1)\\n    for n in (A + B):\\n        cnt[n] += 1\\n    if max(cnt) > N:\\n        print('No')\\n        return\\n    # B\\u3092\\u9006\\u9806\\u306b\\u3059\\u308b\\u3068\\u3001\\u771f\\u3093\\u4e2d\\u3042\\u305f\\u308a\\u3067\\u91cd\\u8907\\u306e\\u30da\\u30a2\\u304c\\u751f\\u3058\\u3046\\u308b\\u3002\\u305d\\u3053\\u3092\\u89e3\\u6d88\\u3059\\u308b\\u3002\\n    B = B[::-1]\\n    dup, dup_indices = -1, list()\\n    for i in range(N):\\n        if A[i] == B[i]:\\n            dup = A[i]\\n            dup_indices.append(i)\\n    if dup == -1:\\n        # \\u540c\\u3058\\u6570\\u5b57\\u306e\\u30da\\u30a2\\u304c\\u306a\\u3044\\u306e\\u3067\\u3001\\u305d\\u306e\\u307e\\u307e\\u51fa\\u529b\\n        print('Yes')\\n        print(' '.join(map(str, B)))\\n        return\\n    # \\u771f\\u3093\\u4e2d\\u3042\\u305f\\u308a\\u306e\\u91cd\\u8907\\u30da\\u30a2\\u90e8\\u5206\\u3092\\u4ed6\\u3068\\u5165\\u308c\\u66ff\\u3048\\u308b\\n    indices = list()\\n    for i in range(N):\\n        if A[i] != dup and B[i] != dup:\\n            indices.append(i)\\n    indices = indices[:len(dup_indices)]\\n    for i, j in zip(dup_indices, indices):\\n        B[i], B[j] = B[j], B[i]\\n    print('Yes')\\n    print(' '.join(map(str, B)))\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"N = int(input())\\nA = list(map(int, input().split()))\\nB = list(map(int, input().split()))\\n\\nAB = [(a, i, 0) for i, a in enumerate(A)] + [(b, i, 1) for i, b in enumerate(B)]\\nAB.sort()\\n\\nX = AB[:N]\\nY = AB[N:]\\n\\nif any(x[0] == y[0] for x, y in zip(X, Y)):\\n    print('No')\\n    return\\n\\nswapA = []\\nswapB = []\\nans = [-1] * N\\n\\nfor (_, i, sx), (_, j, sy) in zip(X, Y):\\n    if sx == sy == 0:\\n        swapA.append((i, j))\\n    elif sx == sy == 1:\\n        swapB.append((i, j))\\n    else:\\n        if sx == 0:\\n            ans[i] = B[j]\\n        else:\\n            ans[j] = B[i]\\n\\nfor (i, j), (x, y) in zip(swapA, swapB):\\n    ans[i] = B[x]\\n    ans[j] = B[y]\\n\\n    if A[i] == ans[i] or A[j] == ans[j]:\\n        ans[i], ans[j] = ans[j], ans[i]\\n\\nprint('Yes')\\nprint((*ans))\\n\", \"def main():\\n    N = int(input())\\n    A = list(map(int, input().split()))\\n    B = list(map(int, input().split()))\\n\\n    B.reverse()\\n    l, r = 0, N - 1\\n\\n    for i in range(N):\\n        if A[i] != B[i]:\\n            continue\\n        if l < i and A[i] != B[l] and A[l] != B[i]:\\n            B[l], B[i] = B[i], B[l]\\n            l += 1\\n            continue\\n        if i < r and A[i] != B[r]:\\n            B[i], B[r] = B[r], B[i]\\n            r -= 1\\n            continue\\n        return None\\n    return B\\n\\nt = main()\\nif t is None:\\n    print('No')\\nelse:\\n    print('Yes')\\n    print((' '.join(map(str, t))))\\n\", \"N, *AB = map(int, open(0).read().split())\\nA, B = AB[:N], AB[N:]\\n\\nC = [0] * (N + 1)\\nD = [0] * (N + 1)\\n\\nfor i, (a, b) in enumerate(zip(A, B)):\\n    C[a] += 1\\n    D[b] += 1\\n\\nif any(c + d > N for c, d in zip(C, D)):\\n    print(\\\"No\\\")\\n    return\\n\\nfor i in range(1, N + 1):\\n    C[i] += C[i - 1]\\n    D[i] += D[i - 1]\\n\\nx = max(C[i] - D[i - 1] for i in range(1, N + 1))\\n\\nprint(\\\"Yes\\\")\\nprint(*[B[(i + N - x) % N] for i in range(N)])\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nreadline = sys.stdin.readline\\nread = sys.stdin.read\\n\\nn, = map(int,readline().split())\\n*a, = map(int,readline().split())\\n*b, = map(int,readline().split())\\nb = b[::-1]\\n\\nsame = [i for i in range(n) if a[i] == b[i]]\\nif same:\\n    v = a[same[0]] # b \\u3092\\u9006\\u9806\\u306b\\u3057\\u305f\\u306e\\u3067\\u3001\\u91cd\\u306a\\u308b\\u5024\\u306f\\u4e00\\u7a2e\\u985e\\u3057\\u304b\\u306a\\u3044\\u3002\\u3053\\u308c\\u3092 v \\u3068\\u304a\\u304f\\u3002\\n    notv = [i for i in range(n) if a[i]!=v and b[i]!=v] # \\u3069\\u3063\\u3061\\u3082v\\u3068\\u304b\\u3076\\u3089\\u306a\\u3044 index\\n    if len(same) > len(notv):\\n        print(\\\"No\\\")\\n        return\\n    for i,j in zip(same,notv):\\n        b[i],b[j] = b[j],b[i]\\n\\nprint(\\\"Yes\\\")\\nprint(*b)\", \"from collections import Counter\\nimport heapq\\n\\nn = int(input())\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\ncur = n-1\\nbit = 1\\nfor i in range(n):\\n    if a[i] == b[i]:\\n        while a[i]==b[cur] or a[cur]==b[i]:\\n            if cur == 0:\\n                bit = -1\\n            if bit == -1 and cur == n-1:\\n                print('No')\\n                return\\n            cur-=bit\\n        b[i], b[cur] = b[cur], b[i]\\nprint('Yes')\\nprint((' '.join(list(map(str, b)))))\\n    \\n    \\n\", \"import numpy as np\\n\\nN = int(input())\\nA = np.array(list(map(int, input().split())))\\nB = np.array(list(map(int, input().split())))\\n\\nl, r = 0, N + 1\\nwhile r - l > 1:\\n    m = (r + l) // 2\\n    if np.all(B[N - m:] > A[:m]):\\n        l = m\\n    else:\\n        r = m\\n\\nif np.all(B[:N - l] < A[l:]):\\n    print('Yes')\\n    print((*np.roll(B, l)))\\nelse:\\n    print('No')\\n\", \"n = int(input()); a = list(map(int, input().split())); b = list(map(int, input().split()))\\nc = [0]*n; d = [0]*n; g = 0\\nfor i in range(n): c[a[i]-1] += 1; d[b[i]-1] += 1\\nfor i in range(n): g = max(g, c[i]+d[i])\\ne = [c[0]]; f = [d[0]]; h = e[0]\\nfor i in range(1, n): e.append(c[i]+e[-1]); f.append(d[i]+f[-1])\\nfor i in range(n-1): h = max(h, e[i+1]-f[i])\\nif g > n: print(\\\"No\\\")\\nelse: print(\\\"Yes\\\"); print(*(b[n-h:]+b[:n-h]))\"]",
        "difficulty": "interview",
        "input": "4\n1 1 2 3\n1 2 3 3\n",
        "output": "Yes\n3 3 1 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://atcoder.jp/contests/abc178/tasks/abc178_f"
    },
    {
        "id": 1968,
        "task_id": 2542,
        "test_case_id": 1,
        "question": "Let's call left cyclic shift of some string $t_1 t_2 t_3 \\dots t_{n - 1} t_n$ as string $t_2 t_3 \\dots t_{n - 1} t_n t_1$.\n\nAnalogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \\dots t_{n - 1}$.\n\nLet's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.\n\nYou are given string $s$ which consists of digits 0–9.\n\nWhat is the minimum number of characters you need to erase from $s$ to make it good?\n\n\n-----Input-----\n\nThe first line contains single integer $t$ ($1 \\le t \\le 1000$) — the number of test cases.\n\nNext $t$ lines contains test cases — one per line. The first and only line of each test case contains string $s$ ($2 \\le |s| \\le 2 \\cdot 10^5$). Each character $s_i$ is digit 0–9.\n\nIt's guaranteed that the total length of strings doesn't exceed $2 \\cdot 10^5$.\n\n\n-----Output-----\n\nFor each test case, print the minimum number of characters you need to erase from $s$ to make it good.\n\n\n-----Example-----\nInput\n3\n95831\n100120013\n252525252525\n\nOutput\n3\n5\n0\n\n\n\n-----Note-----\n\nIn the first test case, you can erase any $3$ characters, for example, the $1$-st, the $3$-rd, and the $4$-th. You'll get string 51 and it is good.\n\nIn the second test case, we can erase all characters except 0: the remaining string is 0000 and it's good.\n\nIn the third test case, the given string $s$ is already good.",
        "solutions": "[\"def det(s, i, j):\\n    ans = 0\\n    curr = i\\n    for a in s:\\n        if a == curr:\\n            ans += 1\\n            if curr == i: curr = j\\n            else: curr = i\\n\\n    if i == j: return ans\\n    return ans // 2 * 2\\n\\nfor t in range(int(input())):\\n    s = list(map(int, list(input())))\\n    ans = 0\\n    \\n    for i in range(10):\\n        for j in range(10):\\n            ans = max(ans, det(s, i, j))\\n\\n    print(len(s)-ans)\\n\", \"for _ in range(int(input())):\\n    s=input()\\n    n=len(s)\\n    s=[int(s[i]) for i in range(n)]\\n    ans=2\\n    for a in range(10):\\n        for b in range(10):\\n            temp=0\\n            sign=\\\"a\\\"\\n            for i in range(n):\\n                if sign==\\\"a\\\":\\n                    if s[i]==a:\\n                        temp+=1\\n                        sign=\\\"b\\\"\\n                else:\\n                    if s[i]==b:\\n                        temp+=1\\n                        sign=\\\"a\\\"\\n            if a==b:\\n                ans=max(ans,temp)\\n            else:\\n                temp-=temp%2\\n                ans=max(ans,temp)\\n    print(n-ans)\\n\", \"from collections import Counter\\n\\nt = int(input())\\n\\nfor _ in range(t):\\n    s = input()\\n    best = len(s) - max(Counter(s).values())\\n    longest = [[0 for _ in range(10)] for _ in range(10)]\\n    for c in s:\\n        ci = int(c)\\n        for j in range(10):\\n            if longest[ci][j] % 2 == 0:\\n                longest[ci][j] += 1\\n            if longest[j][ci] % 2:\\n                longest[j][ci] += 1\\n\\n    # print(longest)\\n    best = min(best, len(s) - max(longest[i][j] - (longest[i][j] % 2) for i in range(10) for j in range(10) if i != j))\\n    print(best)\\n\", \"import math\\nimport sys\\ninput = sys.stdin.readline\\n\\nT = int(input())\\n\\nfor t in range(T):\\n    s = input()[:-1]\\n\\n    answer = math.inf\\n    for n1 in range(10):\\n        sn1 = str(n1)\\n        for n2 in range(10):\\n            sn2 = str(n2)\\n            lookn1 = True\\n            current = 0\\n            for c in s:\\n                if c == sn1 and lookn1:\\n                    lookn1 = False\\n                    current += 1\\n                elif c == sn2 and not lookn1:\\n                    lookn1 = True\\n                    current += 1\\n            if current % 2 and n1 != n2:\\n                current -= 1\\n\\n            answer = min(answer, len(s)-current)\\n\\n    print(answer)\\n\"]",
        "difficulty": "interview",
        "input": "3\n95831\n100120013\n252525252525\n",
        "output": "3\n5\n0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1389/C"
    },
    {
        "id": 1969,
        "task_id": 2542,
        "test_case_id": 2,
        "question": "Let's call left cyclic shift of some string $t_1 t_2 t_3 \\dots t_{n - 1} t_n$ as string $t_2 t_3 \\dots t_{n - 1} t_n t_1$.\n\nAnalogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \\dots t_{n - 1}$.\n\nLet's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift.\n\nYou are given string $s$ which consists of digits 0–9.\n\nWhat is the minimum number of characters you need to erase from $s$ to make it good?\n\n\n-----Input-----\n\nThe first line contains single integer $t$ ($1 \\le t \\le 1000$) — the number of test cases.\n\nNext $t$ lines contains test cases — one per line. The first and only line of each test case contains string $s$ ($2 \\le |s| \\le 2 \\cdot 10^5$). Each character $s_i$ is digit 0–9.\n\nIt's guaranteed that the total length of strings doesn't exceed $2 \\cdot 10^5$.\n\n\n-----Output-----\n\nFor each test case, print the minimum number of characters you need to erase from $s$ to make it good.\n\n\n-----Example-----\nInput\n3\n95831\n100120013\n252525252525\n\nOutput\n3\n5\n0\n\n\n\n-----Note-----\n\nIn the first test case, you can erase any $3$ characters, for example, the $1$-st, the $3$-rd, and the $4$-th. You'll get string 51 and it is good.\n\nIn the second test case, we can erase all characters except 0: the remaining string is 0000 and it's good.\n\nIn the third test case, the given string $s$ is already good.",
        "solutions": "[\"def det(s, i, j):\\n    ans = 0\\n    curr = i\\n    for a in s:\\n        if a == curr:\\n            ans += 1\\n            if curr == i: curr = j\\n            else: curr = i\\n\\n    if i == j: return ans\\n    return ans // 2 * 2\\n\\nfor t in range(int(input())):\\n    s = list(map(int, list(input())))\\n    ans = 0\\n    \\n    for i in range(10):\\n        for j in range(10):\\n            ans = max(ans, det(s, i, j))\\n\\n    print(len(s)-ans)\\n\", \"for _ in range(int(input())):\\n    s=input()\\n    n=len(s)\\n    s=[int(s[i]) for i in range(n)]\\n    ans=2\\n    for a in range(10):\\n        for b in range(10):\\n            temp=0\\n            sign=\\\"a\\\"\\n            for i in range(n):\\n                if sign==\\\"a\\\":\\n                    if s[i]==a:\\n                        temp+=1\\n                        sign=\\\"b\\\"\\n                else:\\n                    if s[i]==b:\\n                        temp+=1\\n                        sign=\\\"a\\\"\\n            if a==b:\\n                ans=max(ans,temp)\\n            else:\\n                temp-=temp%2\\n                ans=max(ans,temp)\\n    print(n-ans)\\n\", \"from collections import Counter\\n\\nt = int(input())\\n\\nfor _ in range(t):\\n    s = input()\\n    best = len(s) - max(Counter(s).values())\\n    longest = [[0 for _ in range(10)] for _ in range(10)]\\n    for c in s:\\n        ci = int(c)\\n        for j in range(10):\\n            if longest[ci][j] % 2 == 0:\\n                longest[ci][j] += 1\\n            if longest[j][ci] % 2:\\n                longest[j][ci] += 1\\n\\n    # print(longest)\\n    best = min(best, len(s) - max(longest[i][j] - (longest[i][j] % 2) for i in range(10) for j in range(10) if i != j))\\n    print(best)\\n\", \"import math\\nimport sys\\ninput = sys.stdin.readline\\n\\nT = int(input())\\n\\nfor t in range(T):\\n    s = input()[:-1]\\n\\n    answer = math.inf\\n    for n1 in range(10):\\n        sn1 = str(n1)\\n        for n2 in range(10):\\n            sn2 = str(n2)\\n            lookn1 = True\\n            current = 0\\n            for c in s:\\n                if c == sn1 and lookn1:\\n                    lookn1 = False\\n                    current += 1\\n                elif c == sn2 and not lookn1:\\n                    lookn1 = True\\n                    current += 1\\n            if current % 2 and n1 != n2:\\n                current -= 1\\n\\n            answer = min(answer, len(s)-current)\\n\\n    print(answer)\\n\"]",
        "difficulty": "interview",
        "input": "1\n1111\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1389/C"
    },
    {
        "id": 1970,
        "task_id": 2562,
        "test_case_id": 1,
        "question": "Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers.\n\nHe has created a method to know how strong his army is. Let the i-th soldier’s strength be a_{i}. For some k he calls i_1, i_2, ..., i_{k} a clan if i_1 < i_2 < i_3 < ... < i_{k} and gcd(a_{i}_1, a_{i}_2, ..., a_{i}_{k}) > 1 . He calls the strength of that clan k·gcd(a_{i}_1, a_{i}_2, ..., a_{i}_{k}). Then he defines the strength of his army by the sum of strengths of all possible clans.\n\nYour task is to find the strength of his army. As the number may be very large, you have to print it modulo 1000000007 (10^9 + 7).\n\nGreatest common divisor (gcd) of a sequence of integers is the maximum possible integer so that each element of the sequence is divisible by it.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 200000) — the size of the army.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000000) — denoting the strengths of his soldiers.\n\n\n-----Output-----\n\nPrint one integer — the strength of John Snow's army modulo 1000000007 (10^9 + 7).\n\n\n-----Examples-----\nInput\n3\n3 3 1\n\nOutput\n12\n\nInput\n4\n2 3 4 6\n\nOutput\n39\n\n\n\n-----Note-----\n\nIn the first sample the clans are {1}, {2}, {1, 2} so the answer will be 1·3 + 1·3 + 2·3 = 12",
        "solutions": "[\"n,N,MOD,ans=int(input()),int(1e6+5),int(1e9+7),0\\ncnt,pw,f=[0]*int(N),[1]*(n+1),[0]*int(N)\\nfor i in range(n):\\n\\tpw[i+1]=pw[i]*2%MOD\\nfor i in input().split():\\n\\tcnt[int(i)]+=1\\nfor i in reversed(range(2,N)):\\n\\tt=sum([cnt[j] for j in range(i,N,i)])\\n\\tif t:\\n\\t\\tf[i]=t*pw[t-1]%MOD\\n\\t\\tfor j in range(i*2,N,i):\\n\\t\\t\\tf[i]=(f[i]-f[j])%MOD\\n\\t\\tans+=i*f[i]%MOD\\nprint(ans%MOD)\", \"n = int(input())\\nMAX = 1000005\\nmod = 1e9 + 7\\npo2 = [0]*(n+1)\\npo2[0] = 1\\nfor v in range(1,n+1):\\n\\tpo2[v] = (po2[v-1]*2)%mod\\na = list(map(int,input().split()))\\nta = [0]*MAX\\nfor i in a:\\n\\tta[i] += 1\\ncnt = [0]*MAX\\nfor i in range(2,MAX):\\n\\tfor j in range(i,MAX,i):\\n\\t\\tcnt[i] += ta[j]\\n#print(ta[0:5],cnt[0:5])\\nans = [0]*MAX\\nfor i in range(MAX-1,0,-1):\\n\\tif cnt[i] == 0:\\n\\t\\tcontinue\\n\\tans[i] = (cnt[i]*po2[cnt[i]-1])%mod\\n\\tfor j in range(i+i,MAX,i):\\n\\t\\tans[i] = (ans[i]+mod-ans[j])%mod\\n#print(ans[0:5])\\nendans = 0\\nfor v in range(2,MAX):\\n\\tendans = (endans+v*ans[v])%mod\\n#print(po2)\\nprint(int(endans))\\n\", \"n, m = int(input()) + 1, 1000001\\nd, s = 1000000007, 0\\nt, b, c = [0] * m, [1] * n, [0] * m\\nfor i in range(2, n): b[i] = b[i - 1] * 2 % d\\nfor i in input().split(): c[int(i)] += 1\\nfor i in range(m, 1, -1):\\n    k = sum(c[i::i])\\n    if k:\\n        t[i] = (k * b[k] - sum(t[i::i])) % d\\n        s += i * t[i]\\nprint(s % d)\", \"n, m = int(input()) + 1, 1000001\\nd, s = 1000000007, 0\\nt, c = [0] * m, [0] * m\\nfor i in input().split(): c[int(i)] += 1\\nfor i in range(m, 1, -1):\\n    k = sum(c[i::i])\\n    if k:\\n        t[i] = (k * pow(2, k - 1, d) - sum(t[i::i])) % d\\n        s += i * t[i]\\nprint(s % d)\", \"(input())\\na=list(map(int,input().split()))\\nn,p=1000001,1000000007\\ncnt=[0]*n\\ncurr=1\\nfor i in a:\\n\\tcnt[i]+=1\\nans=[0]*n\\ntot=0\\nfor i in range(n-1,1,-1):\\n\\tk=sum(cnt[i::i])\\n\\tif k>0:\\n\\t\\tans[i]=(k*pow(2,k-1,p)-sum(ans[i::i]))%p\\n\\t\\ttot=(tot+i*ans[i])%p\\nprint(tot)\\n\\n\", \"n=int(input())\\nnum=[0 for i in range(1000000+1)]\\nmx=0\\nfor i in input().split(' '):\\n\\ti=int(i)\\n\\tmx=max(mx,i)\\n\\tnum[i]+=1\\nf=[0 for i in range(mx+1)]\\np=[0 for i in range(mx+1)]\\nmod=1e9+7\\np[0]=1\\nfor i in range(1,mx+1):\\n\\tp[i]=2*p[i-1]%mod\\nans=0\\nfor i in range(mx,1,-1):\\n\\tm=sum(num[i::i])\\n\\tif m:\\n\\t\\tf[i]=(m*p[m-1]%mod-sum(f[i::i]))%mod\\n\\t\\tans=(ans+f[i]*i)%mod\\nprint(int(ans%mod))\", \"n=int(input())\\n#num=[0 for i in range(1000000+1)]\\nnum=[0]*(1000000+1)\\nmx=0\\nfor i in input().split(' '):\\n\\ti=int(i)\\n\\tmx=max(mx,i)\\n\\tnum[i]+=1\\n#f=[0 for i in range(mx+1)]\\n#p=[0 for i in range(mx+1)]\\nf,p=[0]*(mx+1),[0]*(mx+1)\\nmod=1e9+7\\np[0]=1\\nfor i in range(1,mx+1):\\n\\tp[i]=2*p[i-1]%mod\\nans=0\\nfor i in range(mx,1,-1):\\n\\tm=sum(num[i::i])\\n\\tif m:\\n\\t\\tf[i]=(m*p[m-1]%mod-sum(f[i::i]))%mod\\n\\t\\tans=(ans+f[i]*i)%mod\\nprint(int(ans%mod))\", \"import sys\\nuseless = sys.stdin.readline()\\na = list(map(int,sys.stdin.readline().split()))\\nn = 1000001\\nmod = 1000000007\\ncnt = [0]*n\\nfor i in a:\\n    cnt[i]+=1\\narr = [0]*n\\nans = 0\\nfor i in range(n-1,1,-1):\\n    j = sum(cnt[i::i])\\n    if j > 0:\\n        arr[i]= (j*pow(2,j-1,mod)-sum(arr[i::i]))%mod\\n        ans=(ans+i*arr[i])%mod\\nsys.stdout.write(str(ans))\\n\\n\"]",
        "difficulty": "interview",
        "input": "3\n3 3 1\n",
        "output": "12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/839/D"
    },
    {
        "id": 1971,
        "task_id": 2588,
        "test_case_id": 1,
        "question": "You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string consisting of $n$ characters, where character 0 means that current interval doesn't contain a crossroad, and 1 means that there is a crossroad.\n\nUsually, we can install the pipeline along the road on height of $1$ unit with supporting pillars in each integer point (so, if we are responsible for $[0, n]$ road, we must install $n + 1$ pillars). But on crossroads we should lift the pipeline up to the height $2$, so the pipeline won't obstruct the way for cars.\n\nWe can do so inserting several zig-zag-like lines. Each zig-zag can be represented as a segment $[x, x + 1]$ with integer $x$ consisting of three parts: $0.5$ units of horizontal pipe + $1$ unit of vertical pipe + $0.5$ of horizontal. Note that if pipeline is currently on height $2$, the pillars that support it should also have length equal to $2$ units.\n\n [Image] \n\nEach unit of gas pipeline costs us $a$ bourles, and each unit of pillar — $b$ bourles. So, it's not always optimal to make the whole pipeline on the height $2$. Find the shape of the pipeline with minimum possible cost and calculate that cost.\n\nNote that you must start and finish the pipeline on height $1$ and, also, it's guaranteed that the first and last characters of the input string are equal to 0.\n\n\n-----Input-----\n\nThe fist line contains one integer $T$ ($1 \\le T \\le 100$) — the number of queries. Next $2 \\cdot T$ lines contain independent queries — one query per two lines.\n\nThe first line contains three integers $n$, $a$, $b$ ($2 \\le n \\le 2 \\cdot 10^5$, $1 \\le a \\le 10^8$, $1 \\le b \\le 10^8$) — the length of the road, the cost of one unit of the pipeline and the cost of one unit of the pillar, respectively.\n\nThe second line contains binary string $s$ ($|s| = n$, $s_i \\in \\{0, 1\\}$, $s_1 = s_n = 0$) — the description of the road.\n\nIt's guaranteed that the total length of all strings $s$ doesn't exceed $2 \\cdot 10^5$.\n\n\n-----Output-----\n\nPrint $T$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.\n\n\n-----Example-----\nInput\n4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00\n\nOutput\n94\n25\n2900000000\n13\n\n\n\n-----Note-----\n\nThe optimal pipeline for the first query is shown at the picture above.\n\nThe optimal pipeline for the second query is pictured below:\n\n [Image] \n\nThe optimal (and the only possible) pipeline for the third query is shown below:\n\n [Image] \n\nThe optimal pipeline for the fourth query is shown below:\n\n [Image]",
        "solutions": "[\"for _ in range(int(input())):\\n    n, a, b = map(int, input().split())\\n    s = input().strip()\\n    ans = (n + 1) * b + n * a\\n    \\n    if '1' in s:\\n        ans += 2 * a\\n        s = s[s.find('1'):s.rfind('1') + 1]\\n        t = [0] * (len(s) + 1)\\n        for i in range(len(s)):\\n            x = int(s[i])\\n            t[i] = max(t[i], x)\\n            t[i + 1] = max(t[i + 1], x)\\n        i = 0\\n        while i < len(t):\\n            j = i + 1\\n            while j < len(t) and t[i] == t[j]:\\n                j += 1\\n            if t[i]:\\n                ans += b * (j - i)\\n            else:\\n                ans += min(b * (j - i), 2 * a) \\n            i = j\\n    \\n    print(ans)\", \"from sys import stdin\\nt=int(stdin.readline().strip())\\nfor Ta in range(t):\\n    n,a,b=list(map(int,stdin.readline().strip().split()))\\n    s=stdin.readline().strip()\\n    dp=[[10**15,10**15] for i in range(n)]\\n    dp[0][0]=a+b\\n    dp[0][1]=b+2*a\\n    for i in range(1,n):\\n        if s[i]=='0':\\n            dp[i][0]=min(dp[i-1][0]+a+b,dp[i-1][1]+2*a+2*b)\\n            dp[i][1]=min(dp[i-1][0]+b+2*a,dp[i-1][1]+2*b+a)\\n        else:\\n            dp[i][1]=dp[i-1][1]+2*b+a\\n    print(dp[-1][0]+b)\\n\", \"def mp():\\n    return map(int, input().split())\\n\\ndef f(i, j):\\n    return a[i][j] == a[i + 1][j] == a[i][j + 1] == a[i + 1][j + 1] == 1\\n\\nq = int(input())\\n\\nfor qq in range(q):\\n    n, a, b = mp()\\n    s = input()\\n    dp_u = [0] * (n + 1)\\n    dp_d = [0] * (n + 1)\\n    dp_u[0] = 10 ** 20\\n    dp_d[0] = b\\n    \\n    for i in range(1, n):\\n        dp_u[i] = min(dp_u[i - 1] + a, dp_d[i - 1] + 2 * a) + 2 * b\\n        if s[i] == '0' and s[i - 1] == '0':\\n            dp_d[i] = min(dp_u[i - 1] + 2 * a, dp_d[i - 1] + a) + b\\n        else:\\n            dp_d[i] = 10 ** 20\\n    \\n    #print(dp_u)\\n    #print(dp_d)\\n    print(min(dp_d[n - 1] + a, dp_u[n - 1] + 2 * a) + b)\", \"q = int(input())\\nfor query in range(q):\\n    n, a, b = map(int, input().split())\\n    s = input()\\n    pod = []\\n    count = 1\\n    for i in range(1, n):\\n        if s[i] != s[i - 1]:\\n            pod.append(count)\\n            count = 1\\n        else:\\n            count += 1\\n    pod.append(count)\\n    wyn = n * a + 2 * n * b + 2 * b\\n    for i in range(len(pod)):\\n        if i % 2 == 0:\\n            if i == 0 or i == len(pod) - 1:\\n                wyn -= (b * pod[i]-a)\\n            else:\\n                wyn -= max(0, b * (pod[i] -1) - 2 * a)\\n    if len(pod) == 1:\\n        print((n + 1) * b + n * a)\\n    else:\\n        print(wyn)\", \"for _ in range(int(input())):\\n    n, a, b = list(map(int, input().split()))\\n    s = input()+'0'\\n    min1, min2 = b, float('inf')\\n    for q in range(n):\\n        min3 = min(min1+2*a+b*2, min2+a+b*2)\\n        if s[q+1] == '0' and s[q] == '0':\\n            min1 = min(min1+a+b, min2+2*a+b)\\n        else:\\n            min1 = float('inf')\\n        min2 = min3\\n    print(min1)\\n\", \"T = int(input())\\nfor i in range(T):\\n    n, a, b = list(map(int, input().split()))\\n    s = input()\\n    dp = [[1000000000000000001 for i in range(2)] for j in range(n+1)]\\n    dp[0][0] = a + 2*b\\n    dp[0][1] = 2*a + 3*b\\n    for i in range(n-1):\\n        if s[i] == \\\"0\\\":\\n            if s[i+1] == \\\"1\\\":\\n                dp[i+1][1] = dp[i][1] + a + 2*b\\n            else:\\n                dp[i+1][1] = min(dp[i][1] + a + 2*b, dp[i][0] + 2*a + 2*b)\\n                dp[i+1][0] = min(dp[i][1] + 2*a + b, dp[i][0] + a + b)\\n        else:\\n            if s[i+1] == \\\"1\\\":\\n                dp[i+1][1] = dp[i][1] + a + 2*b\\n            else:\\n                dp[i+1][1] = dp[i][1] + a + 2*b\\n                dp[i+1][0] = dp[i][1] + 2*a + b\\n    print(dp[n-1][0])\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nT=int(input())\\nfor testcases in range(T):\\n    n,a,b=list(map(int,input().split()))\\n    S=list(map(int,list(input().strip())))\\n    S.append(0)\\n\\n    ANS=(n+1)*b+n*a\\n\\n    DP=[[1<<50,1<<50] for i in range(n+1)]\\n    DP[0][0]=0\\n\\n    for i in range(1,n+1):\\n        if S[i-1]==S[i]==0:\\n            DP[i][0]=min(DP[i-1][0],DP[i-1][1]+a)\\n            DP[i][1]=min(DP[i-1][0]+a+b,DP[i-1][1]+b)\\n\\n        else:\\n            DP[i][1]=min(DP[i-1][0]+a+b,DP[i-1][1]+b)\\n\\n    #print(DP)\\n\\n    print(ANS+DP[-1][0])\\n            \\n\", \"T = int(input())\\nfor _ in range(T):\\n\\tn, a, b = map(int, input().split())\\n\\ts = input()\\n\\tres = 0\\n\\ti = 0\\n\\twhile i < n and s[i] == '0':\\n\\t\\tres += a + b\\n\\t\\ti += 1\\n\\tif i < n:\\n\\t\\tres += 2*a\\n\\t\\twhile s[n-1] == '0':\\n\\t\\t\\tres += a + b\\n\\t\\t\\tn -= 1\\n\\t\\tres += (n-i+1)*2*b + (n-i)*a\\n\\t\\tnz = 0\\n\\t\\twhile i < n:\\n\\t\\t\\tif s[i] == '1':\\n\\t\\t\\t\\tif nz > 1 and 2*a-(nz-1)*b < 0:\\n\\t\\t\\t\\t\\tres += 2*a-(nz-1)*b\\n\\t\\t\\t\\tnz = 0\\n\\t\\t\\telse:\\n\\t\\t\\t\\tnz += 1\\n\\t\\t\\ti += 1\\n\\telse:\\n\\t\\tres += b\\n\\tprint(res)\", \"for _ in range(int(input())):\\n    n, a, b = map(int, input().split())\\n    s = input()\\n    if '1' not in s:\\n        print((n + 1) * b + a * n)\\n    else:\\n        cg = 0\\n        for i in range(len(s) - 1):\\n            if s[i] == '1' and s[i - 1] == '0':\\n                cg += 1\\n            if s[i] == '1':\\n                cg += 1\\n        ans = (n + 1) * b + n * a + cg * b\\n        c = 0\\n        D = []\\n        F = 1\\n        for i in s:\\n            if i == '0':\\n                c += 1\\n            elif F:\\n                ans += max(0, a)\\n                c = 0\\n                F = 0\\n            else:\\n                ans += max(0, min(2 * a, (c - 1) * b))\\n                c = 0\\n        ans += max(0, a)\\n        print(ans)\", \"#E71_C\\n\\nT = int(input())\\n\\nfor i in range(0, T):\\n    ln = [int(j) for j in input().split(\\\" \\\")]\\n    n = ln[0]\\n    a = ln[1]\\n    b = ln[2]\\n    st = list(input())\\n    ct = 0\\n    zct = 0\\n    pls = 0\\n    pip = 0\\n    seg = []\\n    ft = False\\n    for j in range(0, len(st)):\\n        if st[j] == \\\"1\\\":\\n            ft = False\\n            if ct == 0:\\n                seg.append(j - 1)\\n            ct += 1\\n            zct = 0\\n        elif zct == 0 and ct:\\n            ct += 1\\n            ft = True\\n            zct += 1\\n        else:\\n            if ft:\\n                ft = False\\n                ct -= 1\\n            zct += 1\\n            if zct == 2 and ct:\\n                seg.append(j - 1)\\n                pls += ct + 1\\n                zct = 0\\n                ct = 0\\n    if zct == 1 and ct:\\n        seg.append(j)\\n        if ft:\\n            ct -= 1\\n        pls += ct + 1\\n    cost = pls * (b * 2) + (n + 1 - pls) * (b)\\n    cost += (n + len(seg)) * a\\n    if len(seg) > 2:\\n        for j in range(1, len(seg) - 1,2):\\n            plc = (seg[j + 1] - seg[j]) * b\\n            pipc = 2 * a\\n            if plc < pipc:\\n                cost -= (pipc - plc)\\n    print(cost)\\n\", \"import sys\\ndef input():\\n\\treturn sys.stdin.readline()[:-1]\\n\\nt = int(input())\\nans = []\\nfor _ in range(t):\\n\\tn, a, b = map(int, input().split())\\n\\ts = input()\\n\\tres = [b, 10**30]\\n\\tfor i in range(n):\\n\\t\\ttmp = []\\n\\t\\tif s[i] == \\\"0\\\":\\n\\t\\t\\ttmp.append(min(res[0]+a+b, res[1]+2*a+b))\\n\\t\\t\\ttmp.append(min(res[1]+a+2*b, res[0]+2*a+2*b))\\n\\t\\telse:\\n\\t\\t\\ttmp.append(10**30)\\n\\t\\t\\ttmp.append(res[1]+a+2*b)\\n\\t\\tres = tmp\\n\\tans.append(res[0])\\nprint(*ans, sep=\\\"\\\\n\\\")\", \"def mi():\\n        return list(map(int, input().split()))\\n'''\\n4\\n8 2 5\\n00110010\\n8 1 1\\n00110010\\n9 100000000 100000000\\n010101010\\n2 5 1\\n00\\n'''\\nfor _ in range(int(input())):\\n    n,a,b = mi()\\n    s = list(map(int, input()))\\n    ans = (a+b)*n+b\\n    if 1 not in s:\\n        print (ans)\\n        continue\\n    i1 = s.index(1)\\n    i2 = n-1-s[::-1].index(1)\\n    ans+= 2*a + (i2-i1+2)*b\\n    i = i1\\n    while i<i2:\\n        enter = False\\n        while i<i2 and s[i]==1:\\n            enter = True\\n            i+=1\\n        start = i\\n        while i<i2 and s[i]==0:\\n            enter = True\\n            i+=1\\n        if i<n and s[i]==1 and s[i-1]==0:\\n            enter = True\\n            if 2*a-b*(i-start-1)<0:\\n                ans+=2*a-b*(i-start-1)\\n        if not enter:\\n            break\\n    print (ans)\\n\", \"def main():\\n    import sys\\n    input = sys.stdin.readline\\n    \\n    def solve():\\n        n, a, b = map(int, input().split())\\n        s = input()\\n        \\n        arr = [0] * (n + 1)\\n        for i in range(1, n):\\n            if s[i] == '1' or s[i - 1] == '1':\\n                arr[i] = 1\\n        \\n        cnts = []\\n        cnt = 1\\n        for i in range(1, n + 1):\\n            if arr[i] != arr[i - 1]:\\n                cnts.append(cnt)\\n                cnt = 1\\n            else:\\n                cnt += 1\\n        cnts.append(cnt)\\n        \\n        l = len(cnts)\\n        cost = n * a + (l - 1) * a + (n + 1) * b + sum(cnts[1:l:2]) * b\\n        for i in range(2, l - 2, 2):\\n            now = 2 * a + cnts[i] * b\\n            new = cnts[i] * 2 * b\\n            if new < now:\\n                cost += new - now\\n        \\n        print(cost)\\n    \\n    for _ in range(int(input())):\\n        solve()\\n    \\n    return 0\\n\\nmain()\", \"for _ in range(int(input())):\\n    n, a, b = list(map(int, input().split()))\\n    s = input()\\n    if s == \\\"0\\\" * n:\\n        print(a * n + b * n + b)\\n        continue\\n    ans = 0\\n    ind = 0\\n    ind2 = n - 1\\n    pref = 0\\n    suf = 0\\n    while ind2 >= 0 and s[ind2] == \\\"0\\\":\\n        ind2 -= 1\\n        suf += 1\\n    while ind < n and s[ind] == \\\"0\\\":\\n        ind += 1\\n        pref += 1\\n    while ind <= ind2:\\n        if s[ind] == \\\"0\\\":\\n            size = 0\\n            while ind <= ind2 and s[ind] == \\\"0\\\":\\n                ind+=1\\n                size += 1\\n            ans += min((size - 1) * b + size * a + 2 * a, size * a + 2 * b * (size - 1))\\n        else:\\n            size = 0\\n            while ind <= ind2 and s[ind] == \\\"1\\\":\\n                ind+=1\\n                size += 1\\n            ans += (size + 1) * b * 2 + size * a\\n    ans += pref * b + pref * a + a\\n    ans += suf * b + suf * a + a\\n    print(ans)\", \"t = int(input())\\nfor i in range(t):\\n    n, a, b = list(map(int, input().split()))\\n    s = input()\\n    arr = []\\n    c = \\\"0\\\"\\n    k = 0\\n    for i in range(n):\\n        if s[i] == c:\\n            k += 1\\n        else:\\n            arr.append(k)\\n            k = 1\\n            c = s[i]\\n    if len(arr) == 0:\\n        print(n * a + b * n + b)\\n    else:\\n        ans = k * (a + b) + (a + b) * arr[0] + a\\n        for i in range(1, len(arr)):\\n            if i % 2 == 1:\\n                ans += (arr[i] + 1) * (2 * b + a)\\n            else:\\n                ans += min((arr[i] + 1) * a + b * (arr[i] - 1), 2 * b * (arr[i] - 1) + a * (arr[i] - 1))\\n        print(ans)\\n                    \\n\", \"t = int(input())\\nfor _ in range(t):\\n    n,pipeCost,pillarCost = map(int,input().split())\\n    road = input()\\n    cost = 0\\n\\n    # get consequtive frequence, guranteed to start and end with one\\n    freq = []\\n    curr = \\\"0\\\"\\n    currFreq = 0\\n    for i in road:\\n        if i == curr:\\n            currFreq += 1\\n        else:\\n            freq.append(currFreq)\\n            curr = i\\n            currFreq = 1\\n    freq.append(currFreq)\\n\\n    # If only a single sequence of 1's\\n    if len(freq) == 3:\\n        cost += pillarCost*freq[0]\\n        cost += pillarCost*2*(freq[1]+1)\\n        cost += pillarCost*freq[2]\\n        cost += pipeCost*(sum(freq)+2)\\n\\n    elif len(freq) == 1:\\n        cost += pillarCost*(freq[0]+1)\\n        cost += pipeCost*(freq[0])\\n\\n    else:\\n        # represents ground level\\n        level = True\\n        switch = 0\\n\\n        cost += pipeCost*(sum(freq))\\n        for i in range(len(freq)):\\n            # zero at 0,2,4...\\n            if i%2 == 0:\\n                if level:\\n                    if i==0 or i==len(freq)-1:\\n                        cost += pillarCost*freq[i]\\n                    else:\\n                        cost += pillarCost*(freq[i]-1)\\n                else:\\n                    if i == len(freq)-1:\\n                        level = True\\n                        cost += pillarCost*freq[i]\\n                    else:\\n                        if (freq[i]-1)*pillarCost > 2*pipeCost:\\n                            level = True\\n                            cost += pillarCost*(freq[i]-1)\\n                        else:\\n                            cost += pillarCost*2*(freq[i]-1)\\n            else:\\n                if level:\\n                    level = False\\n                    switch += 1\\n                    cost += pillarCost*2*(freq[i]+1)\\n                else:\\n                    cost += pillarCost*2*(freq[i]+1)\\n        \\n        cost += 2*switch*pipeCost\\n    \\n    print(cost)\", \"T = int(input())\\nfor _ in range(T):\\n    n, a, b = map(int, input().split())\\n    s = list(map(int, input()))\\n    if 1 not in s:\\n        print(a*n + b*(n+1))\\n        continue\\n    min_lower_length = 2*a/b + 1\\n    start = 0\\n    while s[start] == 0:\\n        start += 1\\n    end = n-1\\n    while s[end] == 0:\\n        end -= 1\\n    cost = (n+2)*a + (n+1)*b + (end-start+2)*b\\n    c = 0\\n    for i in range(start, end+1):\\n        if s[i] == 0:\\n            c += 1\\n        else:\\n            if c>=min_lower_length:\\n                cost += 2*a - (c-1)*b\\n            c = 0\\n    print(cost)\", \"s = lambda: list(map(int, input().split()))\\n\\nT = int(input())\\nfor tc in range(T):\\n    n, a, b = s()\\n    string = list(map(lambda x: x == '1', input()))\\n    cost = a*n + b*(n+1)\\n    isBeginning = True\\n    # state machine\\n    zeros = 0\\n    for x in string:\\n        if x:\\n            if zeros==0:\\n                cost+=b\\n            else:\\n                if not isBeginning and b*(zeros-1) < 2*a:\\n                    cost -= 2*a\\n                    cost += b*(zeros-1)\\n                isBeginning=False\\n                zeros=0\\n                cost+=a+b\\n        else:\\n            if zeros==0:\\n                cost+=a+b\\n            zeros+=1\\n    print(cost-a-b) # first number\", \"import sys\\n\\nT = int(sys.stdin.readline())\\nfor t in range (0, T):\\n    n, a, b = list(map(int, sys.stdin.readline().strip().split()))\\n    s = sys.stdin.readline().strip()\\n    i = 0\\n    c = n * a + (n + 1) * b\\n    v = 0\\n    for j in range (0, n-1):\\n        if s[j] == \\\"1\\\" or s[j+1] == \\\"1\\\":\\n            c = c + b\\n            v = 1\\n    if v == 1:\\n        c = c + 2 * a\\n        while s[i] == \\\"0\\\":\\n            i = i + 1\\n        j = n - 1\\n        while s[j] == \\\"0\\\":\\n            j = j - 1\\n        v = 0\\n        while i <= j:\\n            if s[i] == \\\"1\\\":\\n                if v > 0:\\n                    c = c + min([(v-1) * b, 2 * a])\\n                v = 0\\n            if s[i] == \\\"0\\\":\\n                v = v + 1\\n            i = i + 1\\n    print(c)\\n\\n            \\n\", \"import sys\\n\\ndef solve(A, n, a, b):    \\n    cost = n*a + (n+1)*b\\n    num_ones = 0\\n    groups_ones = 0\\n    groups_zeros = [0]\\n    on_zeros = True\\n    for i in A:\\n        if i == 0:\\n            if on_zeros:\\n                groups_zeros[-1] += 1\\n            else:\\n                on_zeros = True\\n                groups_zeros.append(1)\\n        else:\\n            if on_zeros:\\n                on_zeros = False\\n                groups_ones += 1\\n            num_ones += 1\\n    cost += (groups_ones+num_ones)*b\\n    for i in range(1, len(groups_zeros)-1):\\n        z = groups_zeros[i]\\n        cost += min(2*a, (z-1)*b)\\n    if num_ones >0 :\\n        cost += 2*a\\n    return cost\\n           \\n           \\n\\nin_file = sys.stdin#open(\\\"C.txt\\\", \\\"r\\\") \\n\\nt = int(in_file.readline().strip())\\nfor _ in range(t):\\n    n, a, b = map(int, in_file.readline().strip().split())\\n    A = list(map(int, in_file.readline().strip()))\\n    sys.stdout.write(str(solve(A, n, a, b)) + \\\"\\\\n\\\")\\nsys.stdout.flush() \", \"test = int(input())\\nfor _ in range(test):\\n    n,a,b = map(int,input().split())\\n    s = input()\\n    ans = a*n+b*(n+1)\\n    for i in range(n):\\n        if s[n-i-1]=='1':\\n            s=s[:n-i]\\n            break\\n    for i in range(len(s)):\\n        if s[i]=='1':\\n            s=s[i:]\\n            break\\n    if s.count('1')==0:\\n        print(ans)\\n        continue\\n    dp = []\\n    c = 1\\n    for i in range(len(s)-1):\\n        if s[i+1]==s[i]:\\n            c+=1\\n        else:\\n            dp.append(c)\\n            c=1\\n    dp.append(c)\\n    for i in dp[::2]:\\n        ans += (i+1)*b\\n    ans+=len(dp[::2])*a*2\\n    for i in dp[1::2]:\\n        if (i-1)*b<2*a:\\n            ans += (i-1)*b\\n            ans-=2*a\\n    print(ans)\", \"t=int(input())\\nfor i in range(t):\\n    n,a,b=[int(x) for x in input().split()]\\n    s=[int(x) for x in list(input())]\\n    gas=n\\n    h=n+1\\n    index=-1\\n    one=-1\\n    for i in range(n):\\n        if s[i]==0:\\n            if index!=-1:\\n                h+=i-index+1\\n                gas+=2\\n                index=-1\\n                one=i-1\\n        else:\\n            if index==-1:\\n                index=i\\n                if one!=-1 and 2*a>(i-one-2)*b:\\n                    gas-=2\\n                    h+=i-one-2\\n    print(gas*a+h*b)\\n\\n                \\n    \\n        \\n\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nfor t in range(int(input())):\\n  n, a, b = list(map(int, input().split()))\\n  s = input()\\n  arr = [['0', 1]]\\n  for i in range(1, n):\\n    if s[i] == arr[-1][0]:\\n      arr[-1][1] += 1\\n    else:\\n      arr.append([s[i], 1])\\n  \\n  if len(arr) == 1:\\n    pipe = n\\n    pillar = n + 1\\n  else:\\n    pipe = n + 2\\n    pillar = arr[0][1] + arr[-1][1] + 2 * (n + 1 - arr[0][1] - arr[-1][1])\\n    for i, j in arr[1:-1]:\\n      if i == '0' and j >= 2 and (j-1)*b > 2*a:\\n        pipe += 2\\n        pillar -= j-1\\n        \\n  print(pipe*a + pillar*b)\\n\\n\\n\\n      \\n\\n      \\n        \\n\\n\", \"T = int(input())\\nfor _ in range(T):\\n    n, a, b = list(map( int, input().split() ))\\n    s = input()\\n    ans = n * a + ( n + 1 ) * b\\n    li = s.find('1')\\n    if li >= 0:\\n        ri = s.rfind('1')\\n        ans += a + a + ( ri - li + 2 ) * b\\n        lens = []\\n        for i in range( li + 1, ri ):\\n            if s[ i ] == '0':\\n                if( s[ i - 1 ] == '1' ):\\n                    lens.append(0)\\n                lens[-1] += 1\\n        for l in lens:\\n            sm = a + a - ( l - 1 ) * b\\n            if l > 1 and sm < 0:\\n                ans += sm\\n    print( ans )\\n\\n\", \"def main():\\n    def solve():\\n        n,a,b = map(int,input().split())\\n        ss = input()\\n        cost = 0\\n        for i in range(n):\\n            if ss[i] == '1':\\n                last = i\\n                cost += a*(i+1)+b*i\\n                break\\n        else:\\n            print(a*n+b*(n+1))\\n            return\\n        for i in range(last, n):\\n            if ss[i] == '1' or ss[i-1] == '1':\\n                high = (i-last) * (a+2*b)\\n                low = (i-last) * (a + b) + a*2 + b\\n                cost += min(high, low)\\n                last = i\\n        cost += (n+1-last) * (a+b) +b\\n        print(cost)\\n\\n\\n    q = int(input())\\n    for _ in range(q):\\n        solve()\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00\n",
        "output": "94\n25\n2900000000\n13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1207/C"
    },
    {
        "id": 1972,
        "task_id": 2588,
        "test_case_id": 2,
        "question": "You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string consisting of $n$ characters, where character 0 means that current interval doesn't contain a crossroad, and 1 means that there is a crossroad.\n\nUsually, we can install the pipeline along the road on height of $1$ unit with supporting pillars in each integer point (so, if we are responsible for $[0, n]$ road, we must install $n + 1$ pillars). But on crossroads we should lift the pipeline up to the height $2$, so the pipeline won't obstruct the way for cars.\n\nWe can do so inserting several zig-zag-like lines. Each zig-zag can be represented as a segment $[x, x + 1]$ with integer $x$ consisting of three parts: $0.5$ units of horizontal pipe + $1$ unit of vertical pipe + $0.5$ of horizontal. Note that if pipeline is currently on height $2$, the pillars that support it should also have length equal to $2$ units.\n\n [Image] \n\nEach unit of gas pipeline costs us $a$ bourles, and each unit of pillar — $b$ bourles. So, it's not always optimal to make the whole pipeline on the height $2$. Find the shape of the pipeline with minimum possible cost and calculate that cost.\n\nNote that you must start and finish the pipeline on height $1$ and, also, it's guaranteed that the first and last characters of the input string are equal to 0.\n\n\n-----Input-----\n\nThe fist line contains one integer $T$ ($1 \\le T \\le 100$) — the number of queries. Next $2 \\cdot T$ lines contain independent queries — one query per two lines.\n\nThe first line contains three integers $n$, $a$, $b$ ($2 \\le n \\le 2 \\cdot 10^5$, $1 \\le a \\le 10^8$, $1 \\le b \\le 10^8$) — the length of the road, the cost of one unit of the pipeline and the cost of one unit of the pillar, respectively.\n\nThe second line contains binary string $s$ ($|s| = n$, $s_i \\in \\{0, 1\\}$, $s_1 = s_n = 0$) — the description of the road.\n\nIt's guaranteed that the total length of all strings $s$ doesn't exceed $2 \\cdot 10^5$.\n\n\n-----Output-----\n\nPrint $T$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.\n\n\n-----Example-----\nInput\n4\n8 2 5\n00110010\n8 1 1\n00110010\n9 100000000 100000000\n010101010\n2 5 1\n00\n\nOutput\n94\n25\n2900000000\n13\n\n\n\n-----Note-----\n\nThe optimal pipeline for the first query is shown at the picture above.\n\nThe optimal pipeline for the second query is pictured below:\n\n [Image] \n\nThe optimal (and the only possible) pipeline for the third query is shown below:\n\n [Image] \n\nThe optimal pipeline for the fourth query is shown below:\n\n [Image]",
        "solutions": "[\"for _ in range(int(input())):\\n    n, a, b = map(int, input().split())\\n    s = input().strip()\\n    ans = (n + 1) * b + n * a\\n    \\n    if '1' in s:\\n        ans += 2 * a\\n        s = s[s.find('1'):s.rfind('1') + 1]\\n        t = [0] * (len(s) + 1)\\n        for i in range(len(s)):\\n            x = int(s[i])\\n            t[i] = max(t[i], x)\\n            t[i + 1] = max(t[i + 1], x)\\n        i = 0\\n        while i < len(t):\\n            j = i + 1\\n            while j < len(t) and t[i] == t[j]:\\n                j += 1\\n            if t[i]:\\n                ans += b * (j - i)\\n            else:\\n                ans += min(b * (j - i), 2 * a) \\n            i = j\\n    \\n    print(ans)\", \"from sys import stdin\\nt=int(stdin.readline().strip())\\nfor Ta in range(t):\\n    n,a,b=list(map(int,stdin.readline().strip().split()))\\n    s=stdin.readline().strip()\\n    dp=[[10**15,10**15] for i in range(n)]\\n    dp[0][0]=a+b\\n    dp[0][1]=b+2*a\\n    for i in range(1,n):\\n        if s[i]=='0':\\n            dp[i][0]=min(dp[i-1][0]+a+b,dp[i-1][1]+2*a+2*b)\\n            dp[i][1]=min(dp[i-1][0]+b+2*a,dp[i-1][1]+2*b+a)\\n        else:\\n            dp[i][1]=dp[i-1][1]+2*b+a\\n    print(dp[-1][0]+b)\\n\", \"def mp():\\n    return map(int, input().split())\\n\\ndef f(i, j):\\n    return a[i][j] == a[i + 1][j] == a[i][j + 1] == a[i + 1][j + 1] == 1\\n\\nq = int(input())\\n\\nfor qq in range(q):\\n    n, a, b = mp()\\n    s = input()\\n    dp_u = [0] * (n + 1)\\n    dp_d = [0] * (n + 1)\\n    dp_u[0] = 10 ** 20\\n    dp_d[0] = b\\n    \\n    for i in range(1, n):\\n        dp_u[i] = min(dp_u[i - 1] + a, dp_d[i - 1] + 2 * a) + 2 * b\\n        if s[i] == '0' and s[i - 1] == '0':\\n            dp_d[i] = min(dp_u[i - 1] + 2 * a, dp_d[i - 1] + a) + b\\n        else:\\n            dp_d[i] = 10 ** 20\\n    \\n    #print(dp_u)\\n    #print(dp_d)\\n    print(min(dp_d[n - 1] + a, dp_u[n - 1] + 2 * a) + b)\", \"q = int(input())\\nfor query in range(q):\\n    n, a, b = map(int, input().split())\\n    s = input()\\n    pod = []\\n    count = 1\\n    for i in range(1, n):\\n        if s[i] != s[i - 1]:\\n            pod.append(count)\\n            count = 1\\n        else:\\n            count += 1\\n    pod.append(count)\\n    wyn = n * a + 2 * n * b + 2 * b\\n    for i in range(len(pod)):\\n        if i % 2 == 0:\\n            if i == 0 or i == len(pod) - 1:\\n                wyn -= (b * pod[i]-a)\\n            else:\\n                wyn -= max(0, b * (pod[i] -1) - 2 * a)\\n    if len(pod) == 1:\\n        print((n + 1) * b + n * a)\\n    else:\\n        print(wyn)\", \"for _ in range(int(input())):\\n    n, a, b = list(map(int, input().split()))\\n    s = input()+'0'\\n    min1, min2 = b, float('inf')\\n    for q in range(n):\\n        min3 = min(min1+2*a+b*2, min2+a+b*2)\\n        if s[q+1] == '0' and s[q] == '0':\\n            min1 = min(min1+a+b, min2+2*a+b)\\n        else:\\n            min1 = float('inf')\\n        min2 = min3\\n    print(min1)\\n\", \"T = int(input())\\nfor i in range(T):\\n    n, a, b = list(map(int, input().split()))\\n    s = input()\\n    dp = [[1000000000000000001 for i in range(2)] for j in range(n+1)]\\n    dp[0][0] = a + 2*b\\n    dp[0][1] = 2*a + 3*b\\n    for i in range(n-1):\\n        if s[i] == \\\"0\\\":\\n            if s[i+1] == \\\"1\\\":\\n                dp[i+1][1] = dp[i][1] + a + 2*b\\n            else:\\n                dp[i+1][1] = min(dp[i][1] + a + 2*b, dp[i][0] + 2*a + 2*b)\\n                dp[i+1][0] = min(dp[i][1] + 2*a + b, dp[i][0] + a + b)\\n        else:\\n            if s[i+1] == \\\"1\\\":\\n                dp[i+1][1] = dp[i][1] + a + 2*b\\n            else:\\n                dp[i+1][1] = dp[i][1] + a + 2*b\\n                dp[i+1][0] = dp[i][1] + 2*a + b\\n    print(dp[n-1][0])\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nT=int(input())\\nfor testcases in range(T):\\n    n,a,b=list(map(int,input().split()))\\n    S=list(map(int,list(input().strip())))\\n    S.append(0)\\n\\n    ANS=(n+1)*b+n*a\\n\\n    DP=[[1<<50,1<<50] for i in range(n+1)]\\n    DP[0][0]=0\\n\\n    for i in range(1,n+1):\\n        if S[i-1]==S[i]==0:\\n            DP[i][0]=min(DP[i-1][0],DP[i-1][1]+a)\\n            DP[i][1]=min(DP[i-1][0]+a+b,DP[i-1][1]+b)\\n\\n        else:\\n            DP[i][1]=min(DP[i-1][0]+a+b,DP[i-1][1]+b)\\n\\n    #print(DP)\\n\\n    print(ANS+DP[-1][0])\\n            \\n\", \"T = int(input())\\nfor _ in range(T):\\n\\tn, a, b = map(int, input().split())\\n\\ts = input()\\n\\tres = 0\\n\\ti = 0\\n\\twhile i < n and s[i] == '0':\\n\\t\\tres += a + b\\n\\t\\ti += 1\\n\\tif i < n:\\n\\t\\tres += 2*a\\n\\t\\twhile s[n-1] == '0':\\n\\t\\t\\tres += a + b\\n\\t\\t\\tn -= 1\\n\\t\\tres += (n-i+1)*2*b + (n-i)*a\\n\\t\\tnz = 0\\n\\t\\twhile i < n:\\n\\t\\t\\tif s[i] == '1':\\n\\t\\t\\t\\tif nz > 1 and 2*a-(nz-1)*b < 0:\\n\\t\\t\\t\\t\\tres += 2*a-(nz-1)*b\\n\\t\\t\\t\\tnz = 0\\n\\t\\t\\telse:\\n\\t\\t\\t\\tnz += 1\\n\\t\\t\\ti += 1\\n\\telse:\\n\\t\\tres += b\\n\\tprint(res)\", \"for _ in range(int(input())):\\n    n, a, b = map(int, input().split())\\n    s = input()\\n    if '1' not in s:\\n        print((n + 1) * b + a * n)\\n    else:\\n        cg = 0\\n        for i in range(len(s) - 1):\\n            if s[i] == '1' and s[i - 1] == '0':\\n                cg += 1\\n            if s[i] == '1':\\n                cg += 1\\n        ans = (n + 1) * b + n * a + cg * b\\n        c = 0\\n        D = []\\n        F = 1\\n        for i in s:\\n            if i == '0':\\n                c += 1\\n            elif F:\\n                ans += max(0, a)\\n                c = 0\\n                F = 0\\n            else:\\n                ans += max(0, min(2 * a, (c - 1) * b))\\n                c = 0\\n        ans += max(0, a)\\n        print(ans)\", \"#E71_C\\n\\nT = int(input())\\n\\nfor i in range(0, T):\\n    ln = [int(j) for j in input().split(\\\" \\\")]\\n    n = ln[0]\\n    a = ln[1]\\n    b = ln[2]\\n    st = list(input())\\n    ct = 0\\n    zct = 0\\n    pls = 0\\n    pip = 0\\n    seg = []\\n    ft = False\\n    for j in range(0, len(st)):\\n        if st[j] == \\\"1\\\":\\n            ft = False\\n            if ct == 0:\\n                seg.append(j - 1)\\n            ct += 1\\n            zct = 0\\n        elif zct == 0 and ct:\\n            ct += 1\\n            ft = True\\n            zct += 1\\n        else:\\n            if ft:\\n                ft = False\\n                ct -= 1\\n            zct += 1\\n            if zct == 2 and ct:\\n                seg.append(j - 1)\\n                pls += ct + 1\\n                zct = 0\\n                ct = 0\\n    if zct == 1 and ct:\\n        seg.append(j)\\n        if ft:\\n            ct -= 1\\n        pls += ct + 1\\n    cost = pls * (b * 2) + (n + 1 - pls) * (b)\\n    cost += (n + len(seg)) * a\\n    if len(seg) > 2:\\n        for j in range(1, len(seg) - 1,2):\\n            plc = (seg[j + 1] - seg[j]) * b\\n            pipc = 2 * a\\n            if plc < pipc:\\n                cost -= (pipc - plc)\\n    print(cost)\\n\", \"import sys\\ndef input():\\n\\treturn sys.stdin.readline()[:-1]\\n\\nt = int(input())\\nans = []\\nfor _ in range(t):\\n\\tn, a, b = map(int, input().split())\\n\\ts = input()\\n\\tres = [b, 10**30]\\n\\tfor i in range(n):\\n\\t\\ttmp = []\\n\\t\\tif s[i] == \\\"0\\\":\\n\\t\\t\\ttmp.append(min(res[0]+a+b, res[1]+2*a+b))\\n\\t\\t\\ttmp.append(min(res[1]+a+2*b, res[0]+2*a+2*b))\\n\\t\\telse:\\n\\t\\t\\ttmp.append(10**30)\\n\\t\\t\\ttmp.append(res[1]+a+2*b)\\n\\t\\tres = tmp\\n\\tans.append(res[0])\\nprint(*ans, sep=\\\"\\\\n\\\")\", \"def mi():\\n        return list(map(int, input().split()))\\n'''\\n4\\n8 2 5\\n00110010\\n8 1 1\\n00110010\\n9 100000000 100000000\\n010101010\\n2 5 1\\n00\\n'''\\nfor _ in range(int(input())):\\n    n,a,b = mi()\\n    s = list(map(int, input()))\\n    ans = (a+b)*n+b\\n    if 1 not in s:\\n        print (ans)\\n        continue\\n    i1 = s.index(1)\\n    i2 = n-1-s[::-1].index(1)\\n    ans+= 2*a + (i2-i1+2)*b\\n    i = i1\\n    while i<i2:\\n        enter = False\\n        while i<i2 and s[i]==1:\\n            enter = True\\n            i+=1\\n        start = i\\n        while i<i2 and s[i]==0:\\n            enter = True\\n            i+=1\\n        if i<n and s[i]==1 and s[i-1]==0:\\n            enter = True\\n            if 2*a-b*(i-start-1)<0:\\n                ans+=2*a-b*(i-start-1)\\n        if not enter:\\n            break\\n    print (ans)\\n\", \"def main():\\n    import sys\\n    input = sys.stdin.readline\\n    \\n    def solve():\\n        n, a, b = map(int, input().split())\\n        s = input()\\n        \\n        arr = [0] * (n + 1)\\n        for i in range(1, n):\\n            if s[i] == '1' or s[i - 1] == '1':\\n                arr[i] = 1\\n        \\n        cnts = []\\n        cnt = 1\\n        for i in range(1, n + 1):\\n            if arr[i] != arr[i - 1]:\\n                cnts.append(cnt)\\n                cnt = 1\\n            else:\\n                cnt += 1\\n        cnts.append(cnt)\\n        \\n        l = len(cnts)\\n        cost = n * a + (l - 1) * a + (n + 1) * b + sum(cnts[1:l:2]) * b\\n        for i in range(2, l - 2, 2):\\n            now = 2 * a + cnts[i] * b\\n            new = cnts[i] * 2 * b\\n            if new < now:\\n                cost += new - now\\n        \\n        print(cost)\\n    \\n    for _ in range(int(input())):\\n        solve()\\n    \\n    return 0\\n\\nmain()\", \"for _ in range(int(input())):\\n    n, a, b = list(map(int, input().split()))\\n    s = input()\\n    if s == \\\"0\\\" * n:\\n        print(a * n + b * n + b)\\n        continue\\n    ans = 0\\n    ind = 0\\n    ind2 = n - 1\\n    pref = 0\\n    suf = 0\\n    while ind2 >= 0 and s[ind2] == \\\"0\\\":\\n        ind2 -= 1\\n        suf += 1\\n    while ind < n and s[ind] == \\\"0\\\":\\n        ind += 1\\n        pref += 1\\n    while ind <= ind2:\\n        if s[ind] == \\\"0\\\":\\n            size = 0\\n            while ind <= ind2 and s[ind] == \\\"0\\\":\\n                ind+=1\\n                size += 1\\n            ans += min((size - 1) * b + size * a + 2 * a, size * a + 2 * b * (size - 1))\\n        else:\\n            size = 0\\n            while ind <= ind2 and s[ind] == \\\"1\\\":\\n                ind+=1\\n                size += 1\\n            ans += (size + 1) * b * 2 + size * a\\n    ans += pref * b + pref * a + a\\n    ans += suf * b + suf * a + a\\n    print(ans)\", \"t = int(input())\\nfor i in range(t):\\n    n, a, b = list(map(int, input().split()))\\n    s = input()\\n    arr = []\\n    c = \\\"0\\\"\\n    k = 0\\n    for i in range(n):\\n        if s[i] == c:\\n            k += 1\\n        else:\\n            arr.append(k)\\n            k = 1\\n            c = s[i]\\n    if len(arr) == 0:\\n        print(n * a + b * n + b)\\n    else:\\n        ans = k * (a + b) + (a + b) * arr[0] + a\\n        for i in range(1, len(arr)):\\n            if i % 2 == 1:\\n                ans += (arr[i] + 1) * (2 * b + a)\\n            else:\\n                ans += min((arr[i] + 1) * a + b * (arr[i] - 1), 2 * b * (arr[i] - 1) + a * (arr[i] - 1))\\n        print(ans)\\n                    \\n\", \"t = int(input())\\nfor _ in range(t):\\n    n,pipeCost,pillarCost = map(int,input().split())\\n    road = input()\\n    cost = 0\\n\\n    # get consequtive frequence, guranteed to start and end with one\\n    freq = []\\n    curr = \\\"0\\\"\\n    currFreq = 0\\n    for i in road:\\n        if i == curr:\\n            currFreq += 1\\n        else:\\n            freq.append(currFreq)\\n            curr = i\\n            currFreq = 1\\n    freq.append(currFreq)\\n\\n    # If only a single sequence of 1's\\n    if len(freq) == 3:\\n        cost += pillarCost*freq[0]\\n        cost += pillarCost*2*(freq[1]+1)\\n        cost += pillarCost*freq[2]\\n        cost += pipeCost*(sum(freq)+2)\\n\\n    elif len(freq) == 1:\\n        cost += pillarCost*(freq[0]+1)\\n        cost += pipeCost*(freq[0])\\n\\n    else:\\n        # represents ground level\\n        level = True\\n        switch = 0\\n\\n        cost += pipeCost*(sum(freq))\\n        for i in range(len(freq)):\\n            # zero at 0,2,4...\\n            if i%2 == 0:\\n                if level:\\n                    if i==0 or i==len(freq)-1:\\n                        cost += pillarCost*freq[i]\\n                    else:\\n                        cost += pillarCost*(freq[i]-1)\\n                else:\\n                    if i == len(freq)-1:\\n                        level = True\\n                        cost += pillarCost*freq[i]\\n                    else:\\n                        if (freq[i]-1)*pillarCost > 2*pipeCost:\\n                            level = True\\n                            cost += pillarCost*(freq[i]-1)\\n                        else:\\n                            cost += pillarCost*2*(freq[i]-1)\\n            else:\\n                if level:\\n                    level = False\\n                    switch += 1\\n                    cost += pillarCost*2*(freq[i]+1)\\n                else:\\n                    cost += pillarCost*2*(freq[i]+1)\\n        \\n        cost += 2*switch*pipeCost\\n    \\n    print(cost)\", \"T = int(input())\\nfor _ in range(T):\\n    n, a, b = map(int, input().split())\\n    s = list(map(int, input()))\\n    if 1 not in s:\\n        print(a*n + b*(n+1))\\n        continue\\n    min_lower_length = 2*a/b + 1\\n    start = 0\\n    while s[start] == 0:\\n        start += 1\\n    end = n-1\\n    while s[end] == 0:\\n        end -= 1\\n    cost = (n+2)*a + (n+1)*b + (end-start+2)*b\\n    c = 0\\n    for i in range(start, end+1):\\n        if s[i] == 0:\\n            c += 1\\n        else:\\n            if c>=min_lower_length:\\n                cost += 2*a - (c-1)*b\\n            c = 0\\n    print(cost)\", \"s = lambda: list(map(int, input().split()))\\n\\nT = int(input())\\nfor tc in range(T):\\n    n, a, b = s()\\n    string = list(map(lambda x: x == '1', input()))\\n    cost = a*n + b*(n+1)\\n    isBeginning = True\\n    # state machine\\n    zeros = 0\\n    for x in string:\\n        if x:\\n            if zeros==0:\\n                cost+=b\\n            else:\\n                if not isBeginning and b*(zeros-1) < 2*a:\\n                    cost -= 2*a\\n                    cost += b*(zeros-1)\\n                isBeginning=False\\n                zeros=0\\n                cost+=a+b\\n        else:\\n            if zeros==0:\\n                cost+=a+b\\n            zeros+=1\\n    print(cost-a-b) # first number\", \"import sys\\n\\nT = int(sys.stdin.readline())\\nfor t in range (0, T):\\n    n, a, b = list(map(int, sys.stdin.readline().strip().split()))\\n    s = sys.stdin.readline().strip()\\n    i = 0\\n    c = n * a + (n + 1) * b\\n    v = 0\\n    for j in range (0, n-1):\\n        if s[j] == \\\"1\\\" or s[j+1] == \\\"1\\\":\\n            c = c + b\\n            v = 1\\n    if v == 1:\\n        c = c + 2 * a\\n        while s[i] == \\\"0\\\":\\n            i = i + 1\\n        j = n - 1\\n        while s[j] == \\\"0\\\":\\n            j = j - 1\\n        v = 0\\n        while i <= j:\\n            if s[i] == \\\"1\\\":\\n                if v > 0:\\n                    c = c + min([(v-1) * b, 2 * a])\\n                v = 0\\n            if s[i] == \\\"0\\\":\\n                v = v + 1\\n            i = i + 1\\n    print(c)\\n\\n            \\n\", \"import sys\\n\\ndef solve(A, n, a, b):    \\n    cost = n*a + (n+1)*b\\n    num_ones = 0\\n    groups_ones = 0\\n    groups_zeros = [0]\\n    on_zeros = True\\n    for i in A:\\n        if i == 0:\\n            if on_zeros:\\n                groups_zeros[-1] += 1\\n            else:\\n                on_zeros = True\\n                groups_zeros.append(1)\\n        else:\\n            if on_zeros:\\n                on_zeros = False\\n                groups_ones += 1\\n            num_ones += 1\\n    cost += (groups_ones+num_ones)*b\\n    for i in range(1, len(groups_zeros)-1):\\n        z = groups_zeros[i]\\n        cost += min(2*a, (z-1)*b)\\n    if num_ones >0 :\\n        cost += 2*a\\n    return cost\\n           \\n           \\n\\nin_file = sys.stdin#open(\\\"C.txt\\\", \\\"r\\\") \\n\\nt = int(in_file.readline().strip())\\nfor _ in range(t):\\n    n, a, b = map(int, in_file.readline().strip().split())\\n    A = list(map(int, in_file.readline().strip()))\\n    sys.stdout.write(str(solve(A, n, a, b)) + \\\"\\\\n\\\")\\nsys.stdout.flush() \", \"test = int(input())\\nfor _ in range(test):\\n    n,a,b = map(int,input().split())\\n    s = input()\\n    ans = a*n+b*(n+1)\\n    for i in range(n):\\n        if s[n-i-1]=='1':\\n            s=s[:n-i]\\n            break\\n    for i in range(len(s)):\\n        if s[i]=='1':\\n            s=s[i:]\\n            break\\n    if s.count('1')==0:\\n        print(ans)\\n        continue\\n    dp = []\\n    c = 1\\n    for i in range(len(s)-1):\\n        if s[i+1]==s[i]:\\n            c+=1\\n        else:\\n            dp.append(c)\\n            c=1\\n    dp.append(c)\\n    for i in dp[::2]:\\n        ans += (i+1)*b\\n    ans+=len(dp[::2])*a*2\\n    for i in dp[1::2]:\\n        if (i-1)*b<2*a:\\n            ans += (i-1)*b\\n            ans-=2*a\\n    print(ans)\", \"t=int(input())\\nfor i in range(t):\\n    n,a,b=[int(x) for x in input().split()]\\n    s=[int(x) for x in list(input())]\\n    gas=n\\n    h=n+1\\n    index=-1\\n    one=-1\\n    for i in range(n):\\n        if s[i]==0:\\n            if index!=-1:\\n                h+=i-index+1\\n                gas+=2\\n                index=-1\\n                one=i-1\\n        else:\\n            if index==-1:\\n                index=i\\n                if one!=-1 and 2*a>(i-one-2)*b:\\n                    gas-=2\\n                    h+=i-one-2\\n    print(gas*a+h*b)\\n\\n                \\n    \\n        \\n\", \"import sys \\nfrom collections import defaultdict\\ninput = lambda : sys.stdin.readline().rstrip()\\n\\nfor t in range(int(input())):\\n  n, a, b = list(map(int, input().split()))\\n  s = input()\\n  arr = [['0', 1]]\\n  for i in range(1, n):\\n    if s[i] == arr[-1][0]:\\n      arr[-1][1] += 1\\n    else:\\n      arr.append([s[i], 1])\\n  \\n  if len(arr) == 1:\\n    pipe = n\\n    pillar = n + 1\\n  else:\\n    pipe = n + 2\\n    pillar = arr[0][1] + arr[-1][1] + 2 * (n + 1 - arr[0][1] - arr[-1][1])\\n    for i, j in arr[1:-1]:\\n      if i == '0' and j >= 2 and (j-1)*b > 2*a:\\n        pipe += 2\\n        pillar -= j-1\\n        \\n  print(pipe*a + pillar*b)\\n\\n\\n\\n      \\n\\n      \\n        \\n\\n\", \"T = int(input())\\nfor _ in range(T):\\n    n, a, b = list(map( int, input().split() ))\\n    s = input()\\n    ans = n * a + ( n + 1 ) * b\\n    li = s.find('1')\\n    if li >= 0:\\n        ri = s.rfind('1')\\n        ans += a + a + ( ri - li + 2 ) * b\\n        lens = []\\n        for i in range( li + 1, ri ):\\n            if s[ i ] == '0':\\n                if( s[ i - 1 ] == '1' ):\\n                    lens.append(0)\\n                lens[-1] += 1\\n        for l in lens:\\n            sm = a + a - ( l - 1 ) * b\\n            if l > 1 and sm < 0:\\n                ans += sm\\n    print( ans )\\n\\n\", \"def main():\\n    def solve():\\n        n,a,b = map(int,input().split())\\n        ss = input()\\n        cost = 0\\n        for i in range(n):\\n            if ss[i] == '1':\\n                last = i\\n                cost += a*(i+1)+b*i\\n                break\\n        else:\\n            print(a*n+b*(n+1))\\n            return\\n        for i in range(last, n):\\n            if ss[i] == '1' or ss[i-1] == '1':\\n                high = (i-last) * (a+2*b)\\n                low = (i-last) * (a + b) + a*2 + b\\n                cost += min(high, low)\\n                last = i\\n        cost += (n+1-last) * (a+b) +b\\n        print(cost)\\n\\n\\n    q = int(input())\\n    for _ in range(q):\\n        solve()\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "interview",
        "input": "2\n2 3 5\n00\n12 4 7\n011101011100\n",
        "output": "21\n217\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1207/C"
    },
    {
        "id": 1973,
        "task_id": 2717,
        "test_case_id": 1,
        "question": "It is finally Bobby’s birthday, and all of his Acquaintances, Buddies and Colleagues have gathered for a board game night. They are going to play a board game which is played in up to three big teams. Bobby decided to split his guests into groups based on how well he knows them: the Acquaintances on team $A$, the Buddies on team $B$, and the Colleagues on team $C$.\n\nWhile Bobby was busy explaining the rules to everyone, all his guests already took seats around his large, circular living room table. However, for the game it is crucial that all people sitting on a team are sitting next to each other. Otherwise, members of other teams could easily eavesdrop on their planning, ruining the game. So some people may need to change seats to avoid this from happening.\n\nBobby wants to start playing the game as soon as possible, so he wants people to switch seats as efficiently as possible. Given the current arrangement around the circular table, can you figure out the minimal number of people that must switch seats so that the teams are lined up correctly?\n\n-----Input-----\n - The first line of the input contains the integer $n$, where $1 \\leq n \\leq 10^5$ is the number of players (as well as seats).\n - The second line contains a string of length $n$, consisting only of the characters in ABC. This indicates the teams of the people sitting around the table in order.\n\n-----Output-----\nPrint a single integer: the minimal number of people you have to ask to move seats to make sure the teams sit together.\n\n-----Examples-----\nSample Input 1:\n5\nABABC\nSample Output 1:\n2\n\nSample Input 2:\n12\nABCABCABCABC\nSample Output 2:\n6\n\nSample Input 3:\n4\nACBA\nSample Output 3:\n0\n\nSample Input 4:\n6\nBABABA\nSample Output 4:\n2",
        "solutions": "",
        "difficulty": "interview",
        "input": "5\nABABC\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/gamenight"
    },
    {
        "id": 1974,
        "task_id": 2717,
        "test_case_id": 2,
        "question": "It is finally Bobby’s birthday, and all of his Acquaintances, Buddies and Colleagues have gathered for a board game night. They are going to play a board game which is played in up to three big teams. Bobby decided to split his guests into groups based on how well he knows them: the Acquaintances on team $A$, the Buddies on team $B$, and the Colleagues on team $C$.\n\nWhile Bobby was busy explaining the rules to everyone, all his guests already took seats around his large, circular living room table. However, for the game it is crucial that all people sitting on a team are sitting next to each other. Otherwise, members of other teams could easily eavesdrop on their planning, ruining the game. So some people may need to change seats to avoid this from happening.\n\nBobby wants to start playing the game as soon as possible, so he wants people to switch seats as efficiently as possible. Given the current arrangement around the circular table, can you figure out the minimal number of people that must switch seats so that the teams are lined up correctly?\n\n-----Input-----\n - The first line of the input contains the integer $n$, where $1 \\leq n \\leq 10^5$ is the number of players (as well as seats).\n - The second line contains a string of length $n$, consisting only of the characters in ABC. This indicates the teams of the people sitting around the table in order.\n\n-----Output-----\nPrint a single integer: the minimal number of people you have to ask to move seats to make sure the teams sit together.\n\n-----Examples-----\nSample Input 1:\n5\nABABC\nSample Output 1:\n2\n\nSample Input 2:\n12\nABCABCABCABC\nSample Output 2:\n6\n\nSample Input 3:\n4\nACBA\nSample Output 3:\n0\n\nSample Input 4:\n6\nBABABA\nSample Output 4:\n2",
        "solutions": "",
        "difficulty": "interview",
        "input": "12\nABCABCABCABC\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/gamenight"
    },
    {
        "id": 1975,
        "task_id": 2717,
        "test_case_id": 3,
        "question": "It is finally Bobby’s birthday, and all of his Acquaintances, Buddies and Colleagues have gathered for a board game night. They are going to play a board game which is played in up to three big teams. Bobby decided to split his guests into groups based on how well he knows them: the Acquaintances on team $A$, the Buddies on team $B$, and the Colleagues on team $C$.\n\nWhile Bobby was busy explaining the rules to everyone, all his guests already took seats around his large, circular living room table. However, for the game it is crucial that all people sitting on a team are sitting next to each other. Otherwise, members of other teams could easily eavesdrop on their planning, ruining the game. So some people may need to change seats to avoid this from happening.\n\nBobby wants to start playing the game as soon as possible, so he wants people to switch seats as efficiently as possible. Given the current arrangement around the circular table, can you figure out the minimal number of people that must switch seats so that the teams are lined up correctly?\n\n-----Input-----\n - The first line of the input contains the integer $n$, where $1 \\leq n \\leq 10^5$ is the number of players (as well as seats).\n - The second line contains a string of length $n$, consisting only of the characters in ABC. This indicates the teams of the people sitting around the table in order.\n\n-----Output-----\nPrint a single integer: the minimal number of people you have to ask to move seats to make sure the teams sit together.\n\n-----Examples-----\nSample Input 1:\n5\nABABC\nSample Output 1:\n2\n\nSample Input 2:\n12\nABCABCABCABC\nSample Output 2:\n6\n\nSample Input 3:\n4\nACBA\nSample Output 3:\n0\n\nSample Input 4:\n6\nBABABA\nSample Output 4:\n2",
        "solutions": "",
        "difficulty": "interview",
        "input": "4\nACBA\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/gamenight"
    },
    {
        "id": 1976,
        "task_id": 2717,
        "test_case_id": 4,
        "question": "It is finally Bobby’s birthday, and all of his Acquaintances, Buddies and Colleagues have gathered for a board game night. They are going to play a board game which is played in up to three big teams. Bobby decided to split his guests into groups based on how well he knows them: the Acquaintances on team $A$, the Buddies on team $B$, and the Colleagues on team $C$.\n\nWhile Bobby was busy explaining the rules to everyone, all his guests already took seats around his large, circular living room table. However, for the game it is crucial that all people sitting on a team are sitting next to each other. Otherwise, members of other teams could easily eavesdrop on their planning, ruining the game. So some people may need to change seats to avoid this from happening.\n\nBobby wants to start playing the game as soon as possible, so he wants people to switch seats as efficiently as possible. Given the current arrangement around the circular table, can you figure out the minimal number of people that must switch seats so that the teams are lined up correctly?\n\n-----Input-----\n - The first line of the input contains the integer $n$, where $1 \\leq n \\leq 10^5$ is the number of players (as well as seats).\n - The second line contains a string of length $n$, consisting only of the characters in ABC. This indicates the teams of the people sitting around the table in order.\n\n-----Output-----\nPrint a single integer: the minimal number of people you have to ask to move seats to make sure the teams sit together.\n\n-----Examples-----\nSample Input 1:\n5\nABABC\nSample Output 1:\n2\n\nSample Input 2:\n12\nABCABCABCABC\nSample Output 2:\n6\n\nSample Input 3:\n4\nACBA\nSample Output 3:\n0\n\nSample Input 4:\n6\nBABABA\nSample Output 4:\n2",
        "solutions": "",
        "difficulty": "interview",
        "input": "6\nBABABA\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/gamenight"
    },
    {
        "id": 1977,
        "task_id": 2717,
        "test_case_id": 5,
        "question": "It is finally Bobby’s birthday, and all of his Acquaintances, Buddies and Colleagues have gathered for a board game night. They are going to play a board game which is played in up to three big teams. Bobby decided to split his guests into groups based on how well he knows them: the Acquaintances on team $A$, the Buddies on team $B$, and the Colleagues on team $C$.\n\nWhile Bobby was busy explaining the rules to everyone, all his guests already took seats around his large, circular living room table. However, for the game it is crucial that all people sitting on a team are sitting next to each other. Otherwise, members of other teams could easily eavesdrop on their planning, ruining the game. So some people may need to change seats to avoid this from happening.\n\nBobby wants to start playing the game as soon as possible, so he wants people to switch seats as efficiently as possible. Given the current arrangement around the circular table, can you figure out the minimal number of people that must switch seats so that the teams are lined up correctly?\n\n-----Input-----\n - The first line of the input contains the integer $n$, where $1 \\leq n \\leq 10^5$ is the number of players (as well as seats).\n - The second line contains a string of length $n$, consisting only of the characters in ABC. This indicates the teams of the people sitting around the table in order.\n\n-----Output-----\nPrint a single integer: the minimal number of people you have to ask to move seats to make sure the teams sit together.\n\n-----Examples-----\nSample Input 1:\n5\nABABC\nSample Output 1:\n2\n\nSample Input 2:\n12\nABCABCABCABC\nSample Output 2:\n6\n\nSample Input 3:\n4\nACBA\nSample Output 3:\n0\n\nSample Input 4:\n6\nBABABA\nSample Output 4:\n2",
        "solutions": "",
        "difficulty": "interview",
        "input": "9\nABABCBCAC\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/gamenight"
    },
    {
        "id": 1978,
        "task_id": 2730,
        "test_case_id": 1,
        "question": "Yes! You’ve finally been chosen to participate in the \"Great Geek Game-show 3000\". This is the moment you’ve been waiting for, ever since you puzzled out how to maximise your chances of winning. You will finally be rich, and able to buy all the algorithm books you want! Of course you will have to share the winnings with the other contestants, but since your algorithm is vastly superior to the randomness of all the other numb-skulls you are certain you will be able to keep most of the prize money for yourself, in exchange for telling them how you can all maximise your chances of winning. \n\nThe rules of the game are the following: There is a stage with $N$ boxes, each containing the name of one of the $N$ contestants, and such that each contestant has their name in exactly one box. The contestants enter the stage one at a time, and each one is allowed to peek inside $K$ of the boxes. If they find their own name inside one of these boxes they can get off the stage, and the game continues with the next contestant. If all contestants find their own name, everyone wins. But if one contestant fails to find theirs, everyone loses. After the game has begun, no communication between the contestants is allowed. However you are all allowed to agree upon a strategy before the game begins, and this is where you explain to all the others that the algorithm of everyone choosing $K$ boxes at random is a very bad one, since it gives a chance of winning only equal to $\\left(\\frac{K}{N}\\right)^N$. Instead you suggest the following algorithm:\n\nAssign to each player and each box a unique number in the range $1, \\dots , N$. Then each player starts with opening the box with the same number as themselves. The next box the player opens is the box whose number is found inside the first box, then the box whose number is found inside the second box, and so on. The process goes on until the player has opened $K$ boxes, or found their own number.\n\nNow to bring home your point of how superior your algorithm is, you will need to calculate the exact odds of winning if all the contestants follow your directions. Unfortunately, this is the only thing you haven’t figured out yet\n\n-----Input-----\nOne line with the following integers:\n\n$1 \\leq N \\leq 10000000$ – the number of contestants.\n\n$1 \\leq K \\leq N$ – the number of boxes each contestant may check.\n\n-----Output-----\nThe chances you have of winning if everyone follows your algorithm. The answer should be accurate to an absolute or relative error of at most $10^{-6}$.\n\n-----Examples-----\nSample Input 1:\n4 2\nSample Output 1:\n0.416667\n\nSample Input 2:\n6 5\nSample Output 2:\n0.833333\n\nSample Input 3:\n137 42\nSample Output 3:\n0.029351",
        "solutions": "",
        "difficulty": "interview",
        "input": "4 2\n",
        "output": "0.416667\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/greatgeekgameshow"
    },
    {
        "id": 1979,
        "task_id": 2730,
        "test_case_id": 2,
        "question": "Yes! You’ve finally been chosen to participate in the \"Great Geek Game-show 3000\". This is the moment you’ve been waiting for, ever since you puzzled out how to maximise your chances of winning. You will finally be rich, and able to buy all the algorithm books you want! Of course you will have to share the winnings with the other contestants, but since your algorithm is vastly superior to the randomness of all the other numb-skulls you are certain you will be able to keep most of the prize money for yourself, in exchange for telling them how you can all maximise your chances of winning. \n\nThe rules of the game are the following: There is a stage with $N$ boxes, each containing the name of one of the $N$ contestants, and such that each contestant has their name in exactly one box. The contestants enter the stage one at a time, and each one is allowed to peek inside $K$ of the boxes. If they find their own name inside one of these boxes they can get off the stage, and the game continues with the next contestant. If all contestants find their own name, everyone wins. But if one contestant fails to find theirs, everyone loses. After the game has begun, no communication between the contestants is allowed. However you are all allowed to agree upon a strategy before the game begins, and this is where you explain to all the others that the algorithm of everyone choosing $K$ boxes at random is a very bad one, since it gives a chance of winning only equal to $\\left(\\frac{K}{N}\\right)^N$. Instead you suggest the following algorithm:\n\nAssign to each player and each box a unique number in the range $1, \\dots , N$. Then each player starts with opening the box with the same number as themselves. The next box the player opens is the box whose number is found inside the first box, then the box whose number is found inside the second box, and so on. The process goes on until the player has opened $K$ boxes, or found their own number.\n\nNow to bring home your point of how superior your algorithm is, you will need to calculate the exact odds of winning if all the contestants follow your directions. Unfortunately, this is the only thing you haven’t figured out yet\n\n-----Input-----\nOne line with the following integers:\n\n$1 \\leq N \\leq 10000000$ – the number of contestants.\n\n$1 \\leq K \\leq N$ – the number of boxes each contestant may check.\n\n-----Output-----\nThe chances you have of winning if everyone follows your algorithm. The answer should be accurate to an absolute or relative error of at most $10^{-6}$.\n\n-----Examples-----\nSample Input 1:\n4 2\nSample Output 1:\n0.416667\n\nSample Input 2:\n6 5\nSample Output 2:\n0.833333\n\nSample Input 3:\n137 42\nSample Output 3:\n0.029351",
        "solutions": "",
        "difficulty": "interview",
        "input": "6 5\n",
        "output": "0.833333\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/greatgeekgameshow"
    },
    {
        "id": 1980,
        "task_id": 2730,
        "test_case_id": 3,
        "question": "Yes! You’ve finally been chosen to participate in the \"Great Geek Game-show 3000\". This is the moment you’ve been waiting for, ever since you puzzled out how to maximise your chances of winning. You will finally be rich, and able to buy all the algorithm books you want! Of course you will have to share the winnings with the other contestants, but since your algorithm is vastly superior to the randomness of all the other numb-skulls you are certain you will be able to keep most of the prize money for yourself, in exchange for telling them how you can all maximise your chances of winning. \n\nThe rules of the game are the following: There is a stage with $N$ boxes, each containing the name of one of the $N$ contestants, and such that each contestant has their name in exactly one box. The contestants enter the stage one at a time, and each one is allowed to peek inside $K$ of the boxes. If they find their own name inside one of these boxes they can get off the stage, and the game continues with the next contestant. If all contestants find their own name, everyone wins. But if one contestant fails to find theirs, everyone loses. After the game has begun, no communication between the contestants is allowed. However you are all allowed to agree upon a strategy before the game begins, and this is where you explain to all the others that the algorithm of everyone choosing $K$ boxes at random is a very bad one, since it gives a chance of winning only equal to $\\left(\\frac{K}{N}\\right)^N$. Instead you suggest the following algorithm:\n\nAssign to each player and each box a unique number in the range $1, \\dots , N$. Then each player starts with opening the box with the same number as themselves. The next box the player opens is the box whose number is found inside the first box, then the box whose number is found inside the second box, and so on. The process goes on until the player has opened $K$ boxes, or found their own number.\n\nNow to bring home your point of how superior your algorithm is, you will need to calculate the exact odds of winning if all the contestants follow your directions. Unfortunately, this is the only thing you haven’t figured out yet\n\n-----Input-----\nOne line with the following integers:\n\n$1 \\leq N \\leq 10000000$ – the number of contestants.\n\n$1 \\leq K \\leq N$ – the number of boxes each contestant may check.\n\n-----Output-----\nThe chances you have of winning if everyone follows your algorithm. The answer should be accurate to an absolute or relative error of at most $10^{-6}$.\n\n-----Examples-----\nSample Input 1:\n4 2\nSample Output 1:\n0.416667\n\nSample Input 2:\n6 5\nSample Output 2:\n0.833333\n\nSample Input 3:\n137 42\nSample Output 3:\n0.029351",
        "solutions": "",
        "difficulty": "interview",
        "input": "137 42\n",
        "output": "0.029351\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/greatgeekgameshow"
    },
    {
        "id": 1981,
        "task_id": 2730,
        "test_case_id": 4,
        "question": "Yes! You’ve finally been chosen to participate in the \"Great Geek Game-show 3000\". This is the moment you’ve been waiting for, ever since you puzzled out how to maximise your chances of winning. You will finally be rich, and able to buy all the algorithm books you want! Of course you will have to share the winnings with the other contestants, but since your algorithm is vastly superior to the randomness of all the other numb-skulls you are certain you will be able to keep most of the prize money for yourself, in exchange for telling them how you can all maximise your chances of winning. \n\nThe rules of the game are the following: There is a stage with $N$ boxes, each containing the name of one of the $N$ contestants, and such that each contestant has their name in exactly one box. The contestants enter the stage one at a time, and each one is allowed to peek inside $K$ of the boxes. If they find their own name inside one of these boxes they can get off the stage, and the game continues with the next contestant. If all contestants find their own name, everyone wins. But if one contestant fails to find theirs, everyone loses. After the game has begun, no communication between the contestants is allowed. However you are all allowed to agree upon a strategy before the game begins, and this is where you explain to all the others that the algorithm of everyone choosing $K$ boxes at random is a very bad one, since it gives a chance of winning only equal to $\\left(\\frac{K}{N}\\right)^N$. Instead you suggest the following algorithm:\n\nAssign to each player and each box a unique number in the range $1, \\dots , N$. Then each player starts with opening the box with the same number as themselves. The next box the player opens is the box whose number is found inside the first box, then the box whose number is found inside the second box, and so on. The process goes on until the player has opened $K$ boxes, or found their own number.\n\nNow to bring home your point of how superior your algorithm is, you will need to calculate the exact odds of winning if all the contestants follow your directions. Unfortunately, this is the only thing you haven’t figured out yet\n\n-----Input-----\nOne line with the following integers:\n\n$1 \\leq N \\leq 10000000$ – the number of contestants.\n\n$1 \\leq K \\leq N$ – the number of boxes each contestant may check.\n\n-----Output-----\nThe chances you have of winning if everyone follows your algorithm. The answer should be accurate to an absolute or relative error of at most $10^{-6}$.\n\n-----Examples-----\nSample Input 1:\n4 2\nSample Output 1:\n0.416667\n\nSample Input 2:\n6 5\nSample Output 2:\n0.833333\n\nSample Input 3:\n137 42\nSample Output 3:\n0.029351",
        "solutions": "",
        "difficulty": "interview",
        "input": "2 1\n",
        "output": "0.500000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/greatgeekgameshow"
    },
    {
        "id": 1982,
        "task_id": 2750,
        "test_case_id": 1,
        "question": "Consider a sequence $A$ of integers, containing $N$ integers between $1$ and $N$. Each integer appears exactly once in the sequence.\n\nA subsequence of $A$ is a sequence obtained by removing some (possibly none) numbers from the beginning of $A$, and then from the end of $A$.\n\nCalculate how many different subsequences of $A$ of odd length have their median equal to $B$. The median of a sequence is the element in the middle of the sequence after it is sorted. For example, the median of the sequence $(5, 1, 3)$ is $3$.\n\n-----Input-----\nThe first line contains two integers, $N$ ($1 \\le N \\le 100000$) and $B$ ($1 \\le B \\le N$).\n\nThe second line contains $N$ integers separated by spaces, the elements of sequence $A$.\n\n-----Output-----\nOutput the number of subsequences of $A$ whose median is $B$.\n\n-----Explanation of Sample Input-----\nIn Sample Input 3, the four subsequences of $A$ with median $4$ are $(4)$, $(7, 2, 4)$, $(5, 7, 2, 4, 3)$ and $(5, 7, 2, 4, 3, 1, 6)$.\n\n-----Examples-----\nSample Input 1:\n5 4\n1 2 3 4 5\nSample Output 1:\n2\n\nSample Input 2:\n6 3\n1 2 4 5 6 3\nSample Output 2:\n1",
        "solutions": "",
        "difficulty": "interview",
        "input": "5 4\n1 2 3 4 5\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/srednji"
    },
    {
        "id": 1983,
        "task_id": 2750,
        "test_case_id": 2,
        "question": "Consider a sequence $A$ of integers, containing $N$ integers between $1$ and $N$. Each integer appears exactly once in the sequence.\n\nA subsequence of $A$ is a sequence obtained by removing some (possibly none) numbers from the beginning of $A$, and then from the end of $A$.\n\nCalculate how many different subsequences of $A$ of odd length have their median equal to $B$. The median of a sequence is the element in the middle of the sequence after it is sorted. For example, the median of the sequence $(5, 1, 3)$ is $3$.\n\n-----Input-----\nThe first line contains two integers, $N$ ($1 \\le N \\le 100000$) and $B$ ($1 \\le B \\le N$).\n\nThe second line contains $N$ integers separated by spaces, the elements of sequence $A$.\n\n-----Output-----\nOutput the number of subsequences of $A$ whose median is $B$.\n\n-----Explanation of Sample Input-----\nIn Sample Input 3, the four subsequences of $A$ with median $4$ are $(4)$, $(7, 2, 4)$, $(5, 7, 2, 4, 3)$ and $(5, 7, 2, 4, 3, 1, 6)$.\n\n-----Examples-----\nSample Input 1:\n5 4\n1 2 3 4 5\nSample Output 1:\n2\n\nSample Input 2:\n6 3\n1 2 4 5 6 3\nSample Output 2:\n1",
        "solutions": "",
        "difficulty": "interview",
        "input": "6 3\n1 2 4 5 6 3\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/srednji"
    },
    {
        "id": 1984,
        "task_id": 2750,
        "test_case_id": 3,
        "question": "Consider a sequence $A$ of integers, containing $N$ integers between $1$ and $N$. Each integer appears exactly once in the sequence.\n\nA subsequence of $A$ is a sequence obtained by removing some (possibly none) numbers from the beginning of $A$, and then from the end of $A$.\n\nCalculate how many different subsequences of $A$ of odd length have their median equal to $B$. The median of a sequence is the element in the middle of the sequence after it is sorted. For example, the median of the sequence $(5, 1, 3)$ is $3$.\n\n-----Input-----\nThe first line contains two integers, $N$ ($1 \\le N \\le 100000$) and $B$ ($1 \\le B \\le N$).\n\nThe second line contains $N$ integers separated by spaces, the elements of sequence $A$.\n\n-----Output-----\nOutput the number of subsequences of $A$ whose median is $B$.\n\n-----Explanation of Sample Input-----\nIn Sample Input 3, the four subsequences of $A$ with median $4$ are $(4)$, $(7, 2, 4)$, $(5, 7, 2, 4, 3)$ and $(5, 7, 2, 4, 3, 1, 6)$.\n\n-----Examples-----\nSample Input 1:\n5 4\n1 2 3 4 5\nSample Output 1:\n2\n\nSample Input 2:\n6 3\n1 2 4 5 6 3\nSample Output 2:\n1",
        "solutions": "",
        "difficulty": "interview",
        "input": "7 4\n5 7 2 4 3 1 6\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/srednji"
    },
    {
        "id": 1985,
        "task_id": 2887,
        "test_case_id": 2,
        "question": "Ash like soup very much! So, on the Raksha Bandhan day, his sister gave him a soup maker as a gift. Soup maker in the ith hour will make volume  Vi liters of soup and pours it in a bowl.\nEach hour, the Volume of soup in every bowl is reduced due to evaporation. More precisely, when the temperature on a given hour is Ti, the Volume of soup in every bowl will reduce its volume by Ti. If this would reduce the volume of soup to or below zero, Bowl gets empty. All bowls are independent of each other.\nNote that the Volume of soup in every bowl made in an hour i already lose part of its volume at the same hour. In an extreme case, this may mean that there is no soup left in the bowl at the end of a particular hour.\nYou are given the initial volumes of soup in bowls and the temperature on each hour. Determine the total volume of soup evaporated in each hour.\nInput\nThe first line contains a single integer N (1 ≤ N ≤ 10^5) — the number of hours.\nThe second line contains N integers V 1, V 2, …, V N (0 ≤ V i ≤ 10^9), where V i is the initial volume of soup made in an hour i.\nThe third line contains N integers T 1, T 2, …, T N (0 ≤ T i ≤ 10^9), where T i is the temperature in an hour i.\nOutput\nOutput a single line with N integers, where the i-th integer represents the total volume of soup melted in an hour i.\nExamples\nInput\n3\n10 10 5\n5 7 2\nOutput\n5 12 4\nInput\n5\n30 25 20 15 10\n9 10 12 4 13\nOutput\n9 20 35 11 25\nNote\nIn the first sample, In the first hour, 10 liters of soup is prepared, which evaporates to the size of 5 at the same hour. In the second hour, another 10 liters of soup is made. Since it is a bit warmer than the hour before, the first bowl gets empty while the second bowl shrinks to 3. At the end of the second hour, only one bowl with 3 liters soup is left. In the third hour, another bowl with less volume of soup is made, but as the temperature dropped too, both bowls survive till the end of the hour.",
        "solutions": "[\"def solve():\\r\\n\\tn=int(input())\\r\\n\\tl1=list(map(int,input().split()))\\r\\n\\tl2=list(map(int,input().split()))\\r\\n\\tans=[]\\r\\n\\tfor i in range (n):\\r\\n\\t\\tc=0\\r\\n\\t\\tfor j in range (i+1):\\r\\n\\t\\t\\tif l1[j]<=l2[i]:\\r\\n\\t\\t\\t\\tc+=l1[j]\\r\\n\\t\\t\\t\\tl1[j]=0\\r\\n\\t\\t\\telse:\\r\\n\\t\\t\\t\\tl1[j]-=l2[i]\\r\\n\\t\\t\\t\\tc+=l2[i]\\r\\n\\t\\tans.append(c)\\r\\n\\tprint(*ans)\\r\\nsolve()\", \"# cook your dish here\\nn=int(input())\\nv=[int(x) for x in input().split()]\\nt=[int(x) for x in input().split()]\\na=[]\\nfor i in range(n):\\n    a.append(v[i])\\n    c=0\\n    for j in range(len(a)):\\n        k=a[j]-t[i]\\n        if k>=0:\\n            c+=t[i]\\n            a[j]=k\\n        else: \\n            c+=a[j]\\n            a[j]=0\\n    print(c,end=\\\" \\\")        \\n    \\n    \", \"# cook your dish here\\nx=int(input())\\n\\nsop=[int(i) for i in input().split()]\\ntem=[int(j) for j in input().split()]\\nfor i in range(x):\\n    sm=0\\n    for j in range(i+1):\\n        if (sop[j] >= tem[i]):\\n            sm+=tem[i]\\n            sop[j]-=tem[i]\\n        else:\\n            sm+=sop[j]\\n            sop[j]=0\\n    print(sm,end=\\\" \\\")\", \"# cook your dish here\\nt=int(input())\\ns=list(map(int,input().split()))\\ne=list(map(int,input().split()))\\nif t==0 or t==1:\\n    print(0)\\nelse:\\n    for i in range(t):\\n        c=0\\n        p=s[0:i+1]\\n        for j in range(len(p)):\\n            if p[j]>=e[i]:\\n                c+=e[i]\\n                s[j]-=e[i]\\n            else:\\n                c+=p[j]\\n                s[j]=0\\n        print(c,end=\\\" \\\")\", \"# cook your dish here\\nn=int(input())\\ns=[int(j) for j in input().split()]\\nt=[int(j) for j in input().split()]\\nl=[]\\nfor i in range(n):\\n  te=t[i]\\n  l.append(s[i])\\n  l1=[]\\n  ans=0\\n  for i in l:\\n      if(i>te):\\n          ans+=te\\n          l1.append(i-te)\\n      else:\\n          ans+=i\\n  l=l1\\n  print(ans,end=\\\" \\\")  \", \"n=int(input())\\r\\nvol = list(map(int,input().split()))\\r\\ntemp = list(map(int,input().split()))\\r\\n\\r\\ni=0\\r\\ncount=0\\r\\n\\r\\nwhile i < len(temp):\\r\\n    j = i\\r\\n    count = 0\\r\\n    while j>=0 and i<len(temp):\\r\\n        \\r\\n        if vol[j] < temp[i] and vol[j] != 0:\\r\\n            count += vol[j]\\r\\n            vol[j] = 0\\r\\n            #print(count,end= ' ')\\r\\n            \\r\\n        elif vol[j] >= temp[i] and vol[j] != 0:\\r\\n            vol[j] = vol[j] - temp[i]\\r\\n            count += temp[i]\\r\\n        j -= 1\\r\\n    print(count, end=\\\" \\\")\\r\\n    \\r\\n    i+=1\\r\\n\\r\\n\\r\\n\\r\\n\", \"# cook your dish here\\nn=int(input())\\nv=[int(x) for x in input().split()]\\nt=[int(x) for x in input().split()]\\na=[]\\nfor i in range(n):\\n    a.append(v[i])\\n    c=0\\n    for j in range(len(a)):\\n        k=a[j]-t[i]\\n        if k>=0:\\n            c+=t[i]\\n            a[j]=k\\n        else: \\n            c+=a[j]\\n            a[j]=0\\n    print(c,end=\\\" \\\")        \\n    \\n    \", \"n=int(input())\\nv=list(map(int,input().split()))\\nt=list(map(int,input().split()))\\nfor i in range(n):\\n    ans=0\\n    for j in range(0,i+1):\\n        if v[j]<=0:\\n            continue\\n        if t[i]<=v[j]:\\n            ans+=t[i]\\n            v[j]=v[j]-t[i]\\n        else:\\n            ans+=v[j]\\n            v[j]=0\\n    print(ans,end=' ')\\n    \\n\", \"# cook your dish here\\nimport sys\\n\\nlist_of_lists = []\\n\\nfor line in sys.stdin:\\n    new_list = [int(elem) for elem in line.split()]\\n    list_of_lists.append(new_list)\\n    \\n\\nvolume = list_of_lists[1]\\ntemperature = list_of_lists[2]\\n\\nafter_volume = []\\ntemp_deduction = 0\\ntotal_reduction = []\\n\\nfor i in range(list_of_lists[0][0]):\\n    for x in range(len(after_volume)):\\n        if (after_volume[x] - temperature[i] < 0):\\n            temp_deduction += after_volume[x]\\n            after_volume[x] = 0\\n        else:\\n            temp_deduction += temperature[i]\\n            after_volume[x] = after_volume[x] - temperature[i]\\n    if (volume[i] - temperature[i] < 0):\\n        temp_deduction += volume[i]\\n        after_volume[x] = 0\\n    else:\\n        # print(i)\\n        temp_deduction += temperature[i]\\n        after_volume.append(volume[i] - temperature[i])\\n        # print(after_volume)\\n       \\n    total_reduction.append(temp_deduction)\\n    temp_deduction = 0\\n  \\n    # print(after_volume)\\nprint(*total_reduction)\", \"n=int(input())\\r\\nv=list(map(int,input().split()))\\r\\nt=list(map(int,input().split()))\\r\\nfor i in range(len(t)):\\r\\n    vap=0\\r\\n    for j in range(0,i+1):\\r\\n        if v[j]<=0:\\r\\n            continue\\r\\n        if v[j]-t[i]<=0:\\r\\n            vap+=v[j]\\r\\n            v[j]=0\\r\\n        else:\\r\\n            vap+=t[i]\\r\\n            v[j]-=t[i]\\r\\n    print(vap,end=\\\" \\\")\\r\\n            \\r\\n        \\r\\n        \\r\\n        \\r\\n\", \"# cook your dish here\\nt=1\\nfor t_cases in range(t):\\n    n=int(input())\\n    v=list(map(int,input().split()))\\n    t=list(map(int,input().split()))\\n    for i in range(0,n):\\n        temp=0\\n        for j in range(0,i+1):\\n            if(v[j]>=t[i]):\\n                temp+=t[i]\\n            else:\\n                temp+=v[j]\\n            v[j]=max(0,v[j]-t[i])\\n        print(temp,end=' ')\", \"n=int(input())\\r\\nB=[int(i) for i in input().split()]\\r\\nt=[int(i) for i in input().split()]\\r\\no=[]\\r\\nfor i in range(n):\\r\\n     x=t[i]\\r\\n     s=0\\r\\n     for j in range(i+1):\\r\\n          if(B[j]>x):\\r\\n               B[j]=B[j]-x\\r\\n               s+=x\\r\\n          else:\\r\\n               s+=B[j]\\r\\n               B[j]=0\\r\\n     o.append(s)\\r\\nfor i in o:\\r\\n     print(i,end=\\\" \\\")\\r\\n               \\r\\n          \\r\\n          \\r\\n          \\r\\n     \\r\\n\\r\\n\", \"# cook your dish here\\nn=int(input())\\ns=[int(j) for j in input().split()]\\nt=[int(j) for j in input().split()]\\nl=[]\\nfor i in range(n):\\n  te=t[i]\\n  l.append(s[i])\\n  l1=[]\\n  ans=0\\n  for i in l:\\n      if(i>te):\\n          ans+=te\\n          l1.append(i-te)\\n      else:\\n          ans+=i\\n  l=l1\\n  print(ans,end=\\\" \\\")  \", \"# cook your dish here\\nn=int(input())\\nv=list(map(int,input().split()))\\nt=list(map(int,input().split()))\\nm=[]\\nfor i in range(n):\\n    s=0\\n    for j in range(i+1):\\n        e=v[j]\\n        v[j]=v[j]-t[i]\\n        if(v[j]<0):\\n            v[j]=0\\n        loss=e-v[j]\\n        s=s+loss\\n    m.append(s)\\nprint(*m)\\n        \\n            \\n\", \"n=int(input())\\nv=list(map(int,input().split()))\\nt=list(map(int,input().split()))\\nfor i in range(n):\\n    ans=0\\n    for j in range(0,i+1):\\n        if t[i]<=v[j]:\\n            ans+=t[i]\\n            v[j]=v[j]-t[i]\\n        else:\\n            ans+=v[j]\\n            v[j]=0\\n    print(ans,end=' ')\\n    \\n\", \"def __starting_point():\\r\\n\\tn = int(input())\\r\\n\\tv = list(map(int, input().split()))\\r\\n\\tt = list(map(int, input().split()))\\r\\n\\tl = []\\r\\n\\tans = []\\r\\n\\tfor i in range (n):\\r\\n\\t\\tcancel = 0\\r\\n\\t\\tif i == 0:\\r\\n\\t\\t\\tif v[i] <= t[i]:\\r\\n\\t\\t\\t\\tcancel+=v[i]\\r\\n\\t\\t\\t\\tv[i]-=v[i]\\r\\n\\t\\t\\telse:\\r\\n\\t\\t\\t\\tcancel +=t[i]\\r\\n\\t\\t\\t\\tv[i]-=t[i]\\r\\n\\t\\t\\tl.append(v[i])\\r\\n\\t\\t\\tans.append(cancel)\\r\\n\\t\\telse:\\r\\n\\t\\t\\tl.append(v[i])\\r\\n\\t\\t\\tj = 0\\r\\n\\t\\t\\twhile j < len(l):\\r\\n\\t\\t\\t\\tif l[j] == 0:\\r\\n\\t\\t\\t\\t\\tl.pop(j)\\r\\n\\t\\t\\t\\t\\tj-=1\\r\\n\\t\\t\\t\\telif l[j] <= t[i]:\\r\\n\\t\\t\\t\\t\\tcancel += l[j]\\r\\n\\t\\t\\t\\t\\tl[j]-=l[j]\\r\\n\\t\\t\\t\\telse:\\r\\n\\t\\t\\t\\t\\tcancel+=t[i]\\r\\n\\t\\t\\t\\t\\tl[j]-=t[i]\\r\\n\\t\\t\\t\\tj+=1\\r\\n\\t\\t\\tans.append(cancel)\\r\\n\\tprint(*ans)\\n__starting_point()\", \"# cook your dish here\\r\\nimport sys\\r\\n\\r\\nlist_of_lists = []\\r\\n\\r\\nfor line in sys.stdin:\\r\\n    new_list = [int(elem) for elem in line.split()]\\r\\n    list_of_lists.append(new_list)\\r\\n    \\r\\n\\r\\nvolume = list_of_lists[1]\\r\\ntemperature = list_of_lists[2]\\r\\n\\r\\nafter_volume = []\\r\\ntemp_deduction = 0\\r\\ntotal_reduction = []\\r\\n\\r\\nfor i in range(list_of_lists[0][0]):\\r\\n    for x in range(len(after_volume)):\\r\\n        if (after_volume[x] - temperature[i] < 0):\\r\\n            temp_deduction += after_volume[x]\\r\\n            after_volume[x] = 0\\r\\n        else:\\r\\n            temp_deduction += temperature[i]\\r\\n            after_volume[x] = after_volume[x] - temperature[i]\\r\\n    if (volume[i] - temperature[i] < 0):\\r\\n        temp_deduction += volume[i]\\r\\n        after_volume[x] = 0\\r\\n    else:\\r\\n        # print(i)\\r\\n        temp_deduction += temperature[i]\\r\\n        after_volume.append(volume[i] - temperature[i])\\r\\n        # print(after_volume)\\r\\n       \\r\\n    total_reduction.append(temp_deduction)\\r\\n    temp_deduction = 0\\r\\n  \\r\\n    # print(after_volume)\\r\\nprint(*total_reduction)\\r\\n        \\r\\n    \\r\\n    \", \"# cook your dish here\\nt=int(input())\\ns=list(map(int,input().split()))\\ne=list(map(int,input().split()))\\nif t==0 or t==1:\\n    print(0)\\nelse:\\n    for i in range(t):\\n        c=0\\n        p=s[0:i+1]\\n        for j in range(len(p)):\\n            if p[j]>=e[i]:\\n                c+=e[i]\\n                s[j]-=e[i]\\n            else:\\n                c+=p[j]\\n                s[j]=0\\n        print(c,end=\\\" \\\")\", \"'''\\r\\nName: Devansh\\r\\nUsername: singhdevansh\\r\\nGithub: https://github.com/Devansh3712\\r\\n'''\\r\\n\\r\\nimport os\\r\\nimport sys\\r\\nimport math\\r\\nfrom itertools import *\\r\\nfrom io import BytesIO, IOBase\\r\\nfrom collections import *\\r\\n\\r\\n#<fast I/O>\\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\\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\\r\\n#</fast I/O>\\r\\n\\r\\n#<template>\\r\\nmod=(10**9)+7\\r\\npi=3.14159265358979323846264338327950\\r\\n\\r\\ndef i1():\\t#int(input())\\r\\n\\treturn int(sys.stdin.readline())\\r\\n\\r\\ndef sf():\\t#input()\\r\\n\\treturn sys.stdin.readline()\\r\\n\\r\\ndef mi():\\t#map(int(input()))\\r\\n\\treturn map(int,sys.stdin.readline().split())\\r\\n\\r\\ndef arr():\\t#list(map(int,input().split()))\\r\\n\\treturn list(map(int,sys.stdin.readline().split()))\\r\\n\\r\\ndef pf(ans): #print(x)\\r\\n\\treturn sys.stdout.write(str(ans)+\\\"\\\\n\\\")\\r\\n\\r\\ndef gcd(a,b):\\r\\n\\tif a==0:\\r\\n\\t\\treturn b\\r\\n\\telif b==0:\\r\\n\\t\\treturn a\\r\\n\\tif a>b:\\r\\n\\t\\treturn gcd(a%b,b)\\r\\n\\telse:\\r\\n\\t\\treturn gcd(a,b%a)\\r\\n\\r\\ndef lcm(a,b):\\r\\n\\treturn (a*b)//gcd(a,b)\\r\\n\\r\\ndef LogN(a,b):\\r\\n\\treturn math.log(a)/math.log(b)\\r\\n\\r\\ndef fpow(a,b):\\r\\n\\tres=1\\r\\n\\twhile (b>0):\\r\\n\\t\\tif b&1:\\r\\n\\t\\t\\tres=res*a \\r\\n\\t\\ta=a*a\\r\\n\\t\\tb>>=1\\r\\n\\treturn res\\r\\n\\r\\ndef sieve(n):\\r\\n    m=(n-1)//2\\r\\n    b=[True]*m\\r\\n    i,p,ps = 0,3,[2]\\r\\n    while p*p < n:\\r\\n        if b[i]:\\r\\n            ps.append(p)\\r\\n            j = 2*i*i + 6*i + 3\\r\\n            while j < m:\\r\\n                b[j] = False\\r\\n                j = j + 2*i + 3\\r\\n        i+=1; p+=2\\r\\n    while i < m:\\r\\n        if b[i]:\\r\\n            ps.append(p)\\r\\n        i+=1; p+=2\\r\\n    return ps\\r\\n#</template>\\r\\n\\r\\n#<solve>\\r\\ndef solve():\\r\\n\\tn=i1()\\r\\n\\tl1=arr()\\r\\n\\tl2=arr()\\r\\n\\tans=[]\\r\\n\\tfor i in range (n):\\r\\n\\t\\tc=0\\r\\n\\t\\tfor j in range (i+1):\\r\\n\\t\\t\\tif l1[j]<=l2[i]:\\r\\n\\t\\t\\t\\tc+=l1[j]\\r\\n\\t\\t\\t\\tl1[j]=0\\r\\n\\t\\t\\telse:\\r\\n\\t\\t\\t\\tl1[j]-=l2[i]\\r\\n\\t\\t\\t\\tc+=l2[i]\\r\\n\\t\\tans.append(c)\\r\\n\\tprint(*ans)\\r\\nsolve()\\r\\n#</solve>\\r\\n\\r\\n#<solution>\\r\\n# tc=i1()\\r\\n# for t in range (tc):\\r\\n# \\tsolve()\\r\\n#<solution>\", \"t=int(input())\\nlst=list(map(int,input().split()))\\nlst1=list(map(int,input().split()))\\nfor i in range(len(lst)):\\n    q=0\\n    for j in range(i+1):\\n        if lst[j]<=lst1[i]:\\n            q+=lst[j]\\n            lst[j]=0\\n        else:\\n            q+=lst1[i]\\n            lst[j]-=lst1[i]\\n    print(q,end=\\\" \\\")\", \"# cook your dish here\\nn=int(input())\\nv=list(map(int,input().split()))\\nt=list(map(int,input().split()))\\nm=[]\\nfor i in range(n):\\n    s=0\\n    for j in range(i+1):\\n        e=v[j]\\n        v[j]=v[j]-t[i]\\n        if(v[j]<0):\\n            v[j]=0\\n        loss=e-v[j]\\n        s=s+loss\\n    m.append(s)\\nprint(*m)\\n        \\n            \\n\", \"# cook your dish here\\nn = int(input())\\nsoup = list(map(int , input().split()))\\nevap = list(map(int , input().split()))\\nfor i in range(n) :\\n    summ= 0\\n    for j in range(i+1) :\\n        if(soup[j]>=evap[i]) :\\n            summ+=evap[i]\\n            soup[j]-=evap[i]\\n        else :\\n            summ +=soup[j]\\n            soup[j] = 0\\n    print(summ , end =\\\" \\\")\", \"n = int(input())\\n \\nimport heapq as hq\\n \\nheap = []\\n\\ntemp = 0\\n \\nans = [-1 for _ in range(n)]\\n \\nV = [int(x) for x in input().split()]\\nT = [int(x) for x in input().split()]\\n \\n\\nfor i in range(n):\\n    \\n \\n    prevtemp = temp\\n    temp += T[i]\\n \\n    hq.heappush(heap, V[i] + prevtemp)\\n \\n \\n    curr = 0\\n    while len(heap) and heap[0] <= temp:\\n        m = hq.heappop(heap)\\n        curr += m - prevtemp\\n    curr += (len(heap) * T[i])\\n    ans[i] = curr\\n \\nprint(' '.join([str(x) for x in ans]))\", \"# cook your dish here\\nimport sys\\n\\nlist_of_lists = []\\n\\nfor line in sys.stdin:\\n    new_list = [int(elem) for elem in line.split()]\\n    list_of_lists.append(new_list)\\n    \\n\\nvolume = list_of_lists[1]\\ntemperature = list_of_lists[2]\\n\\nafter_volume = []\\ntemp_deduction = 0\\ntotal_reduction = []\\n\\nfor i in range(list_of_lists[0][0]):\\n    for x in range(len(after_volume)):\\n        if (after_volume[x] - temperature[i] < 0):\\n            temp_deduction += after_volume[x]\\n            after_volume[x] = 0\\n        else:\\n            temp_deduction += temperature[i]\\n            after_volume[x] = after_volume[x] - temperature[i]\\n    if (volume[i] - temperature[i] < 0):\\n        temp_deduction += volume[i]\\n        after_volume[x] = 0\\n    else:\\n        # print(i)\\n        temp_deduction += temperature[i]\\n        after_volume.append(volume[i] - temperature[i])\\n        # print(after_volume)\\n       \\n    total_reduction.append(temp_deduction)\\n    temp_deduction = 0\\n  \\n    # print(after_volume)\\nprint(*total_reduction)\\n        \\n    \\n    \", \"n=int(input())\\nv=list(map(int,input().split()))\\nt=list(map(int,input().split()))\\nfor i in range(n):\\n    ans=0\\n    for j in range(0,i+1):\\n        if t[i]<=v[j]:\\n            ans+=t[i]\\n            v[j]=v[j]-t[i]\\n        else:\\n            ans+=v[j]\\n            v[j]=0\\n    print(ans,end=' ')\\n    \\n\"]",
        "difficulty": "interview",
        "input": [
            "5",
            "30 25 20 15 10",
            "9 10 12 4 13"
        ],
        "output": [
            "9 20 35 11 25",
            "Note",
            "In the first sample, In the first hour, 10 liters of soup is prepared, which evaporates to the size of 5 at the same hour. In the second hour, another 10 liters of soup is made. Since it is a bit warmer than the hour before, the first bowl gets empty while the second bowl shrinks to 3. At the end of the second hour, only one bowl with 3 liters soup is left. In the third hour, another bowl with less volume of soup is made, but as the temperature dropped too, both bowls survive till the end of the hour."
        ],
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://www.codechef.com/GACE2020/problems/CCH1"
    },
    {
        "id": 1986,
        "task_id": 2966,
        "test_case_id": 1,
        "question": "Quido and Hugo are making a chocolate cake. The central ingredient of the cake is a large chocolate bar, lying unwrapped on the kitchen table. The bar is an $M \\times N$ rectangular grid of chocolate blocks. All of the $MN$ blocks are rectangles of identical shape and size. The chocolate bar is of top quality and the friends want to eat part of it, before the rest is used in the cake.\n\n“OK,” says Quido, “let’s divide the whole bar into two triangular chunks by a straight diagonal cut from its upper-left corner to its lower-right corner. We will then eat all of the blocks which have been cut exactly in half, into two equal-area pieces. You will eat one half and I will eat the other half of each such block. All other blocks, that is, the blocks which are either uncut or cut into two parts of different sizes, will go directly into the cake. Of course, we will make sure the cut is perfectly precise.\n\nLet’s see how much chocolate we get to eat!”\n\n-----Input-----\nThe input consists of two space-separated integers $M$ and $N$ given on a single line, (where $1 \\leq M, N \\leq 10^{18}$). The numbers $M$ and $N$ denote the number of blocks in one column and in one row, respectively, in the chocolate bar.\n\n-----Output-----\nPrint the number of blocks of the chocolate bar which are cut into exactly two pieces of equal area.\n\n-----Examples-----\nSample Input:\n6 10\nSample Output:\n2",
        "solutions": "",
        "difficulty": "interview",
        "input": "6 10\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/diagonalcut"
    },
    {
        "id": 1987,
        "task_id": 2982,
        "test_case_id": 2,
        "question": "Your friend Tóti is an aspiring musician. He has written $n$ songs, each of which has a hype rating of either $1$, $2$, or $3$. A higher hype rating means the song has more energy. Tóti is planning his first live performance and needs your help. He wants to know how many setlists he can make. A setlist consist of at least three songs, the first song must have hype rating $1$, the last song must have hype rating $3$, and all other songs must have hype rating $2$. Tóti also wants to play the songs in the same order he wrote them. \n\nGiven the hype rating of each of Tóti’s songs in the order he wrote them, how many setlists can he make?\n\n-----Input-----\nThe first line of input consists of an integer $n$ ($1 \\leq n \\leq 10^6$), the number of songs Tóti has written. The second line consists of $n$ integers, each in $\\{ 1, 2, 3\\} $, giving the hype ratings of the $n$ songs in the order they were written.\n\n-----Output-----\nOutput the number of setlists Tóti can make. Since this number can be large, print it modulo $10^9 + 7$.\n\n-----Examples-----\nSample Input:\n9\n1 1 1 2 2 2 3 3 3\nSample Output:\n63",
        "solutions": "",
        "difficulty": "interview",
        "input": "8\n1 2 1 2 3 1 2 3\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/gigcombinatorics"
    },
    {
        "id": 1988,
        "task_id": 3079,
        "test_case_id": 1,
        "question": "Having solved a tedious assignment, Mirko decided to play a game with his good friend Slavko.\n\nThey have written a sequence of $N$ letters on a piece of paper. Each one of them is trying to put together a word using letters from the sequence. They alternate taking turns consisting of removing a single letter from the sequence and appending it to the end of their word. Mirko has the first turn. The game ends when no letters are remaining in the sequence.\n\nWe define a word to be more beautiful than another word if it comes first alphabetically. The player who has the more beautiful word at the end of the game wins. If both players have equal words, they both lose.\n\nMirko is a much better player than Slavko, so he has decided to make it easier for Slavko by always selecting the rightmost remaining letter in the sequence. Knowing this, Slavko wants to find out if it is possible for him to win and which is the most beautiful word he can end the game with.\n\n-----Input-----\nThe first line of input contains an even positive integer $N$ ($2 \\le N \\le 100 000$).\n\nThe second line of input contains $N$ characters, the starting letter sequence. All characters are lower case letters from the English alphabet.\n\n-----Output-----\nThe first line of output must contain “DA” if it is possible for Slavko to win, and “NE” otherwise.\n\nThe second line of output must contain the most beautiful word that Slavko can have at the end of the game.\n\n-----Examples-----\nSample Input 1:\n2\nne\nSample Output 1:\nNE\nn\n\nSample Input 2:\n4\nkava\nSample Output 2:\nDA\nak",
        "solutions": "",
        "difficulty": "competition",
        "input": "2\nne\n",
        "output": "NE\nn\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/igra"
    },
    {
        "id": 1989,
        "task_id": 3079,
        "test_case_id": 2,
        "question": "Having solved a tedious assignment, Mirko decided to play a game with his good friend Slavko.\n\nThey have written a sequence of $N$ letters on a piece of paper. Each one of them is trying to put together a word using letters from the sequence. They alternate taking turns consisting of removing a single letter from the sequence and appending it to the end of their word. Mirko has the first turn. The game ends when no letters are remaining in the sequence.\n\nWe define a word to be more beautiful than another word if it comes first alphabetically. The player who has the more beautiful word at the end of the game wins. If both players have equal words, they both lose.\n\nMirko is a much better player than Slavko, so he has decided to make it easier for Slavko by always selecting the rightmost remaining letter in the sequence. Knowing this, Slavko wants to find out if it is possible for him to win and which is the most beautiful word he can end the game with.\n\n-----Input-----\nThe first line of input contains an even positive integer $N$ ($2 \\le N \\le 100 000$).\n\nThe second line of input contains $N$ characters, the starting letter sequence. All characters are lower case letters from the English alphabet.\n\n-----Output-----\nThe first line of output must contain “DA” if it is possible for Slavko to win, and “NE” otherwise.\n\nThe second line of output must contain the most beautiful word that Slavko can have at the end of the game.\n\n-----Examples-----\nSample Input 1:\n2\nne\nSample Output 1:\nNE\nn\n\nSample Input 2:\n4\nkava\nSample Output 2:\nDA\nak",
        "solutions": "",
        "difficulty": "competition",
        "input": "4\nkava\n",
        "output": "DA\nak\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/igra"
    },
    {
        "id": 1990,
        "task_id": 3079,
        "test_case_id": 3,
        "question": "Having solved a tedious assignment, Mirko decided to play a game with his good friend Slavko.\n\nThey have written a sequence of $N$ letters on a piece of paper. Each one of them is trying to put together a word using letters from the sequence. They alternate taking turns consisting of removing a single letter from the sequence and appending it to the end of their word. Mirko has the first turn. The game ends when no letters are remaining in the sequence.\n\nWe define a word to be more beautiful than another word if it comes first alphabetically. The player who has the more beautiful word at the end of the game wins. If both players have equal words, they both lose.\n\nMirko is a much better player than Slavko, so he has decided to make it easier for Slavko by always selecting the rightmost remaining letter in the sequence. Knowing this, Slavko wants to find out if it is possible for him to win and which is the most beautiful word he can end the game with.\n\n-----Input-----\nThe first line of input contains an even positive integer $N$ ($2 \\le N \\le 100 000$).\n\nThe second line of input contains $N$ characters, the starting letter sequence. All characters are lower case letters from the English alphabet.\n\n-----Output-----\nThe first line of output must contain “DA” if it is possible for Slavko to win, and “NE” otherwise.\n\nThe second line of output must contain the most beautiful word that Slavko can have at the end of the game.\n\n-----Examples-----\nSample Input 1:\n2\nne\nSample Output 1:\nNE\nn\n\nSample Input 2:\n4\nkava\nSample Output 2:\nDA\nak",
        "solutions": "",
        "difficulty": "competition",
        "input": "8\ncokolada\n",
        "output": "DA\nacko\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/igra"
    },
    {
        "id": 1991,
        "task_id": 3287,
        "test_case_id": 1,
        "question": "Two thieves (who strongly “recommended” us not to reveal their names) has broken into the central bank of Logland, where the country’s cash reserve is stored. In Logland, the currency has the $k$ denominations $1, 2, 4, 8, \\ldots , 2^{k - 1}$, and the bank currently stores $x_ i$ coins of denominations $2^i$.\n\nThieves live by a very strict honor code, which stipulates that any loot grabbed must be divided evenly between the theives. Unfortunately (for the thieves), this may mean that some loot must be left behind. For example, if the bank contained a single coin of denomination $8$, and two coins of denomination $2$, there is no way they could bring the $8$ coin. Instead, they would have to take one coin of value $2$ each, leaving more than half of the possible loot!\n\nSince neither leaving loot nor solving NP-hard problems are things thieves like to do, they have asked you to compute the minimum value of the loot they must leave behind, in order to be able to split the remaining loot evenly.\n\n-----Input-----\nThe first line of input contains the integer $1 \\le k \\le 10^6$ – the number of denominations in Logland. The next line contains the $k$ integers $0 \\le x_0, x_1, \\dots , x_{k-1} \\le 2^{30}$, the number of coins of the denominations $2^0, 2^1, \\dots , 2^{k - 1}$.\n\n-----Output-----\nOutput a single line, the minimum amount of money the thieves must leave behind. Since this number may be very large, output it modulo the prime number $10^9 + 7$.\n\n-----Examples-----\nSample Input 1:\n4\n0 2 0 1\nSample Output 1:\n8\n\nSample Input 2:\n5\n1000000 1 1 1 1\nSample Output 2:\n0",
        "solutions": "",
        "difficulty": "competition",
        "input": "4\n0 2 0 1\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/logland"
    },
    {
        "id": 1992,
        "task_id": 3287,
        "test_case_id": 3,
        "question": "Two thieves (who strongly “recommended” us not to reveal their names) has broken into the central bank of Logland, where the country’s cash reserve is stored. In Logland, the currency has the $k$ denominations $1, 2, 4, 8, \\ldots , 2^{k - 1}$, and the bank currently stores $x_ i$ coins of denominations $2^i$.\n\nThieves live by a very strict honor code, which stipulates that any loot grabbed must be divided evenly between the theives. Unfortunately (for the thieves), this may mean that some loot must be left behind. For example, if the bank contained a single coin of denomination $8$, and two coins of denomination $2$, there is no way they could bring the $8$ coin. Instead, they would have to take one coin of value $2$ each, leaving more than half of the possible loot!\n\nSince neither leaving loot nor solving NP-hard problems are things thieves like to do, they have asked you to compute the minimum value of the loot they must leave behind, in order to be able to split the remaining loot evenly.\n\n-----Input-----\nThe first line of input contains the integer $1 \\le k \\le 10^6$ – the number of denominations in Logland. The next line contains the $k$ integers $0 \\le x_0, x_1, \\dots , x_{k-1} \\le 2^{30}$, the number of coins of the denominations $2^0, 2^1, \\dots , 2^{k - 1}$.\n\n-----Output-----\nOutput a single line, the minimum amount of money the thieves must leave behind. Since this number may be very large, output it modulo the prime number $10^9 + 7$.\n\n-----Examples-----\nSample Input 1:\n4\n0 2 0 1\nSample Output 1:\n8\n\nSample Input 2:\n5\n1000000 1 1 1 1\nSample Output 2:\n0",
        "solutions": "",
        "difficulty": "competition",
        "input": "5\n3 3 3 3 3\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/logland"
    },
    {
        "id": 1993,
        "task_id": 3380,
        "test_case_id": 1,
        "question": "The people of Absurdistan discovered how to build roads only last year. After the discovery, each city decided to build its own road, connecting the city with some other city. Each newly built road can be used in both directions.\n\nAbsurdistan is full of absurd coincidences. It took all $N$ cities precisely one year to build their roads. And even more surprisingly, when the roads were finished it was possible to travel from every city to any other city using the newly built roads. We say that such a road network is connected. Being interested in mathematics and probability, you started wondering how unlikely this coincidence really is.\n\n-----Task-----\nEach city picked uniformly at random another city to which they built a road. Calculate the probability that the road network ends up being connected.\n\n-----Input-----\nThe first line contains an integer $N$ $(2\\le N\\le 140)$ – the number of cities.\n\n-----Output-----\nOutput one line containing a floating point number denoting the probability that the randomly built road network with $N$ cities and $N$ roads is connected. Your answer should have an absolute error of at most $10^{-8}$.\n\n-----Examples-----\nSample Input:\n4\nSample Output:\n0.962962962963",
        "solutions": "",
        "difficulty": "competition",
        "input": "4\n",
        "output": "0.962962962963\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/absurdistan2"
    },
    {
        "id": 1994,
        "task_id": 3679,
        "test_case_id": 1,
        "question": "It is Catmas time again, and that means a lot of stress for everyone. In the Kattis family everyone used to buy gifts for everyone else, but this becomes more and more expensive every year, since our family keeps growing. \n\nTo make things easier, we decided that this year each person will buy just one gift. We will then put all the gifts in a big bag and choose an order among ourselves, with all orderings being equally likely. Then, in this order, each person picks a gift from the bag, where each gift is chosen with equal probability. If it is their own gift (which they can easily recognize since everyone in the Kattis family is a creative individual making completely unique Catmas gift wrapping), they put it back in the bag and pick another gift. This can take some time, since it might happen that somebody picks their own gift a few times in a row.\n\nThis strategy is not perfect, because the last person might still end up with their own gift. When this happens, everyone has to put their gifts back in the bag, and then we restart the entire process all over from the beginning. Now the question is, how long will we have to wait until the process ends and we can start opening our Catmas gifts? Specifically, given the size $n$ of our family, what is the expected total number of gifts taken out of the bag until the process ends and everyone has gotten their gift?\n\n-----Input-----\nThe input contains one line with one integer $n$ ($2\\leq n\\leq 1000$) – the current size of the Kattis family.\n\n-----Output-----\nOutput the expected total number of gifts taken out of the bag, accurate to within an absolute error of at most $10^{-6}$.\n\n-----Examples-----\nSample Input:\n2\nSample Output:\n3.000000000",
        "solutions": "",
        "difficulty": "competition",
        "input": "2\n",
        "output": "3.000000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/catmasgifts"
    },
    {
        "id": 1995,
        "task_id": 3679,
        "test_case_id": 2,
        "question": "It is Catmas time again, and that means a lot of stress for everyone. In the Kattis family everyone used to buy gifts for everyone else, but this becomes more and more expensive every year, since our family keeps growing. \n\nTo make things easier, we decided that this year each person will buy just one gift. We will then put all the gifts in a big bag and choose an order among ourselves, with all orderings being equally likely. Then, in this order, each person picks a gift from the bag, where each gift is chosen with equal probability. If it is their own gift (which they can easily recognize since everyone in the Kattis family is a creative individual making completely unique Catmas gift wrapping), they put it back in the bag and pick another gift. This can take some time, since it might happen that somebody picks their own gift a few times in a row.\n\nThis strategy is not perfect, because the last person might still end up with their own gift. When this happens, everyone has to put their gifts back in the bag, and then we restart the entire process all over from the beginning. Now the question is, how long will we have to wait until the process ends and we can start opening our Catmas gifts? Specifically, given the size $n$ of our family, what is the expected total number of gifts taken out of the bag until the process ends and everyone has gotten their gift?\n\n-----Input-----\nThe input contains one line with one integer $n$ ($2\\leq n\\leq 1000$) – the current size of the Kattis family.\n\n-----Output-----\nOutput the expected total number of gifts taken out of the bag, accurate to within an absolute error of at most $10^{-6}$.\n\n-----Examples-----\nSample Input:\n2\nSample Output:\n3.000000000",
        "solutions": "",
        "difficulty": "competition",
        "input": "3\n",
        "output": "5.333333333\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/catmasgifts"
    },
    {
        "id": 1996,
        "task_id": 3712,
        "test_case_id": 1,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "5\n1 2 2 4 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 1997,
        "task_id": 3712,
        "test_case_id": 2,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "3\n4 1 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 1998,
        "task_id": 3712,
        "test_case_id": 3,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "4\n0 3 0 4\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 1999,
        "task_id": 3712,
        "test_case_id": 4,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "5\n4 4 3 3 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2000,
        "task_id": 3712,
        "test_case_id": 5,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "5\n4 3 4 2 4\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2001,
        "task_id": 3712,
        "test_case_id": 6,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "10\n2 1 2 3 4 1 3 4 4 4\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2002,
        "task_id": 3712,
        "test_case_id": 7,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "10\n2 3 3 1 3 1 3 2 2 4\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2003,
        "task_id": 3712,
        "test_case_id": 8,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "120\n1 1 1 1 1 1 1 4 4 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 4 1 1 4 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 2 4 1 1 3 1 1 1 2 1 0 3 1 1 1 2 1 4 1 1 1 1 1 1 1 1 1 1\n",
        "output": "69\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2004,
        "task_id": 3712,
        "test_case_id": 9,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "10\n2 4 1 3 1 2 2 2 2 2\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2005,
        "task_id": 3712,
        "test_case_id": 10,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "10\n3 4 2 2 1 1 3 1 1 2\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2006,
        "task_id": 3712,
        "test_case_id": 11,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "20\n4 1 4 4 2 1 4 3 2 3 1 1 2 2 2 4 4 2 4 2\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2007,
        "task_id": 3712,
        "test_case_id": 12,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "20\n4 3 4 2 1 1 3 1 4 2 1 4 3 3 4 3 1 1 1 3\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2008,
        "task_id": 3712,
        "test_case_id": 13,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "20\n4 1 1 1 4 2 3 3 2 1 1 4 4 3 1 1 2 4 2 3\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2009,
        "task_id": 3712,
        "test_case_id": 14,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "20\n4 4 2 4 3 2 3 1 4 1 1 4 1 4 3 4 4 3 3 3\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2010,
        "task_id": 3712,
        "test_case_id": 15,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "20\n4 2 3 3 1 3 2 3 1 4 4 4 2 1 4 2 1 3 4 4\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2011,
        "task_id": 3712,
        "test_case_id": 16,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "23\n2 3 1 1 1 1 4 3 2 2 3 3 4 1 4 2 4 1 4 2 3 1 1\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2012,
        "task_id": 3712,
        "test_case_id": 17,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "27\n0 2 4 1 4 2 1 2 3 4 2 4 1 2 3 2 3 2 2 1 0 4 3 0 3 0 1\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2013,
        "task_id": 3712,
        "test_case_id": 18,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "28\n2 0 4 2 3 4 1 1 4 3 0 3 0 3 2 3 2 4 1 2 4 3 3 3 0 1 0 1\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2014,
        "task_id": 3712,
        "test_case_id": 19,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "24\n4 2 4 3 1 3 4 1 3 4 2 4 0 2 3 4 1 1 4 3 1 2 2 4\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2015,
        "task_id": 3712,
        "test_case_id": 20,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "19\n2 4 4 2 0 0 1 4 1 0 2 2 4 2 0 1 1 1 4\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2016,
        "task_id": 3712,
        "test_case_id": 21,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "16\n3 3 3 1 3 0 1 4 4 4 1 4 3 1 1 4\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2017,
        "task_id": 3712,
        "test_case_id": 22,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "17\n3 3 1 0 1 3 1 1 1 3 0 2 2 2 3 2 2\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2018,
        "task_id": 3712,
        "test_case_id": 23,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "12\n2 2 2 1 1 0 2 0 1 1 2 1\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2019,
        "task_id": 3712,
        "test_case_id": 24,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "15\n4 0 1 0 0 4 1 1 0 4 1 4 4 1 0\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2020,
        "task_id": 3712,
        "test_case_id": 25,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "20\n0 4 4 0 0 0 2 3 3 3 2 0 3 2 3 2 4 4 2 4\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2021,
        "task_id": 3712,
        "test_case_id": 26,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "23\n1 1 3 2 0 3 1 2 2 2 1 3 3 4 1 0 0 3 1 2 2 0 3\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2022,
        "task_id": 3712,
        "test_case_id": 27,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "15\n0 2 4 2 0 4 4 2 4 4 1 2 4 2 2\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2023,
        "task_id": 3712,
        "test_case_id": 28,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "17\n0 4 3 0 2 2 4 2 4 4 2 4 2 1 0 0 0\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2024,
        "task_id": 3712,
        "test_case_id": 29,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "21\n0 3 2 3 0 2 3 4 3 0 1 3 2 2 3 3 3 0 2 2 0\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2025,
        "task_id": 3712,
        "test_case_id": 30,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "21\n1 1 3 1 0 3 3 3 3 0 1 3 0 3 1 1 1 3 2 0 0\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2026,
        "task_id": 3712,
        "test_case_id": 31,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "13\n1 1 1 2 1 1 4 1 3 1 1 1 0\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2027,
        "task_id": 3712,
        "test_case_id": 32,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "14\n4 2 4 4 0 4 4 0 1 0 0 4 3 4\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2028,
        "task_id": 3712,
        "test_case_id": 33,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "13\n2 1 2 2 3 4 0 2 2 2 2 2 2\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2029,
        "task_id": 3712,
        "test_case_id": 34,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "10\n2 2 2 0 0 0 0 0 2 2\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2030,
        "task_id": 3712,
        "test_case_id": 35,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "11\n2 2 2 2 0 2 2 2 2 2 2\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2031,
        "task_id": 3712,
        "test_case_id": 36,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "11\n1 1 1 1 1 1 1 1 1 1 1\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2032,
        "task_id": 3712,
        "test_case_id": 37,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "16\n0 0 1 1 1 1 1 1 1 1 1 0 1 1 0 1\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2033,
        "task_id": 3712,
        "test_case_id": 38,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "17\n1 1 4 1 1 0 1 1 1 1 0 1 0 1 0 0 1\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2034,
        "task_id": 3712,
        "test_case_id": 39,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "14\n1 0 0 1 1 1 0 1 1 1 1 1 3 0\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2035,
        "task_id": 3712,
        "test_case_id": 40,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "9\n1 1 1 2 1 1 1 1 1\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2036,
        "task_id": 3712,
        "test_case_id": 41,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "13\n2 2 0 4 2 2 2 2 2 1 2 2 2\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2037,
        "task_id": 3712,
        "test_case_id": 42,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "19\n2 2 3 2 0 0 1 1 2 0 0 2 1 2 2 2 0 2 2\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2038,
        "task_id": 3712,
        "test_case_id": 43,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "29\n3 1 3 3 0 2 2 3 3 2 0 3 3 2 3 0 3 3 0 2 2 2 3 2 0 3 2 2 3\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2039,
        "task_id": 3712,
        "test_case_id": 44,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "27\n0 1 2 2 3 3 2 0 2 3 2 0 2 3 2 2 2 2 3 3 1 3 2 3 1 2 2\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2040,
        "task_id": 3712,
        "test_case_id": 45,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "29\n3 3 2 0 1 1 1 2 2 2 1 3 2 0 2 3 3 2 2 3 2 2 2 2 1 2 2 2 4\n",
        "output": "12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2041,
        "task_id": 3712,
        "test_case_id": 46,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "13\n4 1 1 4 1 1 1 1 1 1 1 1 1\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2042,
        "task_id": 3712,
        "test_case_id": 47,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "30\n1 1 1 3 3 4 0 1 1 1 1 1 1 3 0 0 0 1 1 1 1 3 1 1 1 1 3 1 1 1\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2043,
        "task_id": 3712,
        "test_case_id": 48,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "32\n1 4 4 3 1 4 4 4 1 1 1 1 1 4 1 1 1 4 1 1 1 1 2 1 1 4 4 1 1 1 1 4\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2044,
        "task_id": 3712,
        "test_case_id": 49,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "48\n1 3 1 1 1 1 1 1 2 1 1 2 1 1 4 1 1 1 2 2 2 1 3 1 1 1 1 2 1 2 2 1 1 1 1 1 3 0 2 3 1 1 3 1 0 1 2 1\n",
        "output": "24\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2045,
        "task_id": 3712,
        "test_case_id": 50,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "49\n2 2 1 2 2 2 2 2 2 2 2 2 1 2 1 3 4 2 2 2 2 4 1 1 2 1 2 2 2 2 2 4 0 0 2 0 1 1 2 1 2 2 2 2 4 4 2 2 1\n",
        "output": "24\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2046,
        "task_id": 3712,
        "test_case_id": 51,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "165\n1 1 1 1 1 1 1 1 0 2 2 2 1 1 1 1 1 4 4 1 1 2 2 1 2 1 2 2 2 1 2 2 3 1 1 2 1 1 2 2 4 1 2 2 2 4 1 1 1 4 2 2 1 1 1 1 1 2 1 1 1 2 1 1 1 1 4 2 2 1 1 1 1 2 1 1 1 1 2 2 1 1 2 1 1 1 1 2 2 1 2 1 2 1 2 2 1 2 2 1 1 1 2 1 4 2 2 2 1 1 1 1 2 3 2 1 2 1 1 2 1 1 1 1 1 2 1 2 1 1 0 1 2 1 1 1 1 1 3 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 3 4 1 1 1\n",
        "output": "84\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2047,
        "task_id": 3712,
        "test_case_id": 52,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "197\n1 4 4 4 1 4 1 1 0 1 4 4 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 4 1 1 1 1 1 4 1 1 1 2 1 1 4 4 4 4 4 4 1 1 1 4 1 4 4 4 4 4 1 1 1 1 1 4 4 1 4 0 4 1 4 4 1 4 4 4 2 1 1 4 4 2 1 1 1 4 1 4 1 4 4 4 1 1 4 4 4 1 1 0 1 4 1 4 0 4 3 1 1 1 4 1 4 4 4 1 4 1 4 3 1 4 4 4 1 1 4 0 4 1 1 4 1 4 4 1 4 1 1 1 4 1 4 1 1 3 4 1 4 4 1 1 1 1 4 1 1 3 4 1 1 0 1 4 4 1 4 4 1 4 4 1 1 0 2 1 4 1 4 1 1 1 1 1 4 4 1 1 0 4 2 4 1 4 1 4 4\n",
        "output": "69\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2048,
        "task_id": 3712,
        "test_case_id": 53,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "177\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 4 2 2 2 2 4 2 0 2 2 2 2 2 3 2 2 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 4 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 2 4 2 2 2 2 2 2 4 2 2 2 2 2 3 2 1 2 2 2 2 2 2 4 4 2 2 2 4 2 2 2 2 2 2 2 2 4 2 4 2 2 4 2 2 2 2 2 2 2 2 0 2 3 2 2 2 2 2 2 2 0 2 2 4 2 2 2 2 3 2 2\n",
        "output": "103\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2049,
        "task_id": 3712,
        "test_case_id": 54,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "166\n2 3 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 3 2 2 2 2 2 2 2 2 2 4 2 2 2 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 3 2 2 2 2 2 2 2 2 2 3 2 0 2 0 3 2 2 2 0 2 0 2 2 2 2 2 2 3 0 2 2 2 2 2 3 3 2 2 2 3 2 2 2 3 3 2 2 2 2 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 0 2 2 2 2 3 2 2 2 2\n",
        "output": "93\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2050,
        "task_id": 3712,
        "test_case_id": 55,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "172\n2 2 2 0 1 3 2 1 0 3 3 1 0 1 2 3 4 2 2 4 2 1 4 0 3 2 2 3 3 3 0 0 3 1 1 0 1 2 2 0 1 4 4 0 3 3 2 0 1 4 4 1 4 2 2 3 0 1 2 2 1 1 4 4 4 4 0 1 0 2 4 0 2 0 0 2 2 1 4 2 2 2 2 2 0 2 3 0 2 1 0 2 1 0 2 2 0 2 2 0 2 2 2 1 1 0 2 1 2 1 0 2 2 0 2 2 3 2 4 2 4 3 2 3 1 2 2 4 0 2 0 2 2 1 0 1 2 1 4 1 0 3 2 2 1 0 0 2 0 4 2 2 0 0 4 1 3 2 1 1 0 2 3 2 0 2 2 2 2 2 3 0\n",
        "output": "53\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2051,
        "task_id": 3712,
        "test_case_id": 56,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "141\n2 1 1 1 1 1 4 2 3 1 1 1 1 1 1 4 1 1 1 1 1 1 1 4 4 1 1 1 1 2 1 4 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 2 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 3 1 1 1 1 1 4 4 1 3 4 1 1 1 1 1 1 1 1 1 4 2 1 0 1 1 4 1 1 1 1 2 1 0 1 1 2 1 1 1 1 4 4 1 2 4 4 1 1 3 1 1 1 3 1 1 4 4 1 1 1 4 1 1 1 1 1 1 2 0 1 0 0 1 0 4\n",
        "output": "69\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2052,
        "task_id": 3712,
        "test_case_id": 57,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "108\n2 2 1 4 2 2 1 2 2 2 2 2 2 4 2 2 4 2 4 2 2 2 2 4 2 4 2 2 2 1 2 1 2 2 2 4 2 2 2 2 2 2 4 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 2 1 2 2 2 2 2 2 2 2 2 2 1 2 2 4 2 2 2 2 4 2 2 2 1 2 2 2 2 2 4 1 2 2\n",
        "output": "61\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2053,
        "task_id": 3712,
        "test_case_id": 58,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "138\n3 1 3 1 3 3 3 1 1 1 1 1 1 3 3 1 1 1 3 3 1 1 3 1 1 1 1 1 1 1 3 3 3 1 3 1 1 1 1 1 3 1 1 3 1 3 1 3 1 1 1 1 3 1 3 1 1 3 1 1 1 3 1 1 1 1 1 1 1 1 3 1 1 1 1 3 1 3 1 3 3 3 3 3 3 1 1 1 3 1 1 3 1 1 1 1 1 1 1 1 3 1 1 3 3 1 3 3 1 3 1 1 1 3 1 1 1 1 1 1 3 1 1 1 1 3 1 1 1 3 1 1 3 1 1 3 1 1\n",
        "output": "62\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2054,
        "task_id": 3712,
        "test_case_id": 59,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "81\n2 2 2 3 2 3 2 2 2 2 2 3 2 2 2 2 2 2 0 2 4 2 3 4 2 3 2 3 2 0 2 2 0 2 2 3 2 2 4 3 3 2 2 2 2 2 2 2 3 2 2 2 2 2 2 3 3 2 2 3 2 0 2 0 2 2 2 2 2 2 4 0 2 3 2 4 2 2 2 2 2\n",
        "output": "38\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2055,
        "task_id": 3712,
        "test_case_id": 60,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "115\n2 2 2 2 4 2 2 2 2 2 2 2 2 2 2 2 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 4 2 4 2 4 2 2 2 2 2 2 2 2 2 2 2 4 4 3 2 2 2 2 2 2 2 4 2 2 2 3 2 2 2 2 2 2 4 2 2 2 2 2 2 2 4 2 2 2 2 2 2 2 3 2 2 2 2 2 4 4 4 2 2\n",
        "output": "65\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2056,
        "task_id": 3712,
        "test_case_id": 61,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "146\n1 1 1 1 1 4 1 1 0 1 4 4 1 4 1 1 1 1 1 4 1 1 1 1 1 1 1 4 1 1 1 1 4 1 4 1 1 1 0 1 4 1 4 1 4 4 1 1 1 1 1 1 1 1 1 4 4 1 1 4 1 4 4 4 1 1 4 4 1 4 1 1 1 1 0 1 1 1 1 1 1 4 1 4 1 1 4 1 1 4 4 4 1 1 4 1 1 1 1 1 1 1 4 1 1 1 4 1 4 1 1 1 1 1 1 1 4 1 1 4 4 4 1 1 1 1 1 1 1 4 1 1 1 1 4 1 4 1 1 1 4 4 4 4 1 1\n",
        "output": "68\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2057,
        "task_id": 3712,
        "test_case_id": 62,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "198\n1 2 1 2 2 1 2 1 1 1 3 2 1 1 2 1 2 2 1 1 1 4 1 1 1 1 0 1 1 1 1 4 1 1 3 1 2 1 1 1 2 1 2 0 1 1 1 1 1 1 1 1 1 2 4 4 1 0 1 1 1 1 1 1 1 1 2 1 1 1 4 0 1 2 1 2 1 1 2 2 1 1 1 1 3 2 2 2 1 1 4 1 2 2 2 1 1 2 2 1 2 2 2 1 1 1 1 3 1 3 1 1 0 1 4 1 2 2 1 1 1 2 2 1 1 1 1 3 2 1 2 1 1 2 1 2 1 2 1 0 4 1 2 1 1 1 1 3 1 1 2 0 1 1 1 1 1 3 2 1 2 1 1 0 1 1 3 1 1 2 1 1 1 1 1 1 4 4 1 1 0 1 1 1 2 1 1 1 3 0 2 1 2 1 1 1 1 1\n",
        "output": "97\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2058,
        "task_id": 3712,
        "test_case_id": 63,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "200\n4 1 1 4 3 1 1 3 1 1 1 4 3 3 3 2 3 3 1 3 3 4 4 2 2 2 3 1 2 2 2 3 1 1 3 2 2 4 1 3 4 3 2 4 2 2 4 2 2 3 4 2 3 2 2 1 2 4 4 2 4 4 2 3 2 4 1 4 2 1 3 4 1 3 1 1 2 1 4 1 3 3 3 4 1 4 4 1 4 4 2 3 1 3 3 2 2 1 4 2 4 4 3 3 3 1 3 4 3 1 1 1 1 4 2 1 2 3 2 2 2 3 2 1 2 1 1 1 2 4 1 3 3 3 2 3 3 2 3 4 4 3 3 4 3 2 1 4 1 4 2 1 3 2 4 4 1 4 1 1 1 3 2 3 4 2 2 4 1 4 4 4 4 3 1 3 1 4 3 2 1 2 1 1 2 4 1 3 3 4 4 2 2 4 4 3 2 1 2 4\n",
        "output": "50\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2059,
        "task_id": 3712,
        "test_case_id": 64,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "200\n2 1 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 2 1 1 1 2 2 2 2 2 2 1 2 2 1 1 1 1 2 1 2 2 1 2 2 2 2 1 2 2 1 1 1 1 2 2 1 1 1 1 1 2 2 2 2 1 2 1 2 2 2 2 1 1 1 2 1 2 2 2 2 1 1 1 1 1 1 2 2 2 1 2 2 2 1 2 2 2 1 1 1 2 2 1 1 1 1 2 2 1 2 1 1 1 2 2 1 1 2 2 2 1 2 2 0 1 2 1 1 2 2 2 1 2 2 1 1 1 2 2 2 1 2 1 2 1 2 1 1 2 2 1 1 1 1 1 2 2 1 1 1 1 1 2 1 2 2 1 1 1 1 1 1 2 2 1 1 1 1 2 2 1 1 1 2 2 2 2 1 1 1 1 1 1 2 1 1 2 2 1 1 2 1 0\n",
        "output": "100\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2060,
        "task_id": 3712,
        "test_case_id": 65,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "6\n1 1 1 2 2 1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2061,
        "task_id": 3712,
        "test_case_id": 66,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "10\n3 3 1 1 2 1 1 1 2 2\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2062,
        "task_id": 3712,
        "test_case_id": 67,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "10\n1 1 1 2 1 2 2 1 2 1\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2063,
        "task_id": 3712,
        "test_case_id": 68,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "15\n1 2 2 1 2 3 2 1 2 1 1 1 2 1 1\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2064,
        "task_id": 3712,
        "test_case_id": 69,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "13\n2 1 2 2 1 0 1 2 1 1 1 1 2\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2065,
        "task_id": 3712,
        "test_case_id": 70,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "3\n4 4 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2066,
        "task_id": 3712,
        "test_case_id": 71,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "5\n4 4 4 4 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2067,
        "task_id": 3712,
        "test_case_id": 72,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "1\n1\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2068,
        "task_id": 3712,
        "test_case_id": 73,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "4\n1 1 3 4\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2069,
        "task_id": 3712,
        "test_case_id": 74,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "7\n1 1 1 3 3 3 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2070,
        "task_id": 3712,
        "test_case_id": 75,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "6\n2 2 2 4 4 4\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2071,
        "task_id": 3712,
        "test_case_id": 76,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "3\n2 3 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2072,
        "task_id": 3712,
        "test_case_id": 77,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "9\n1 1 1 1 3 3 3 3 3\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2073,
        "task_id": 3712,
        "test_case_id": 78,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "3\n1 4 4\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2074,
        "task_id": 3712,
        "test_case_id": 79,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "3\n3 3 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2075,
        "task_id": 3712,
        "test_case_id": 80,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "5\n1 1 1 1 1\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2076,
        "task_id": 3712,
        "test_case_id": 81,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "2\n1 1\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2077,
        "task_id": 3712,
        "test_case_id": 82,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "3\n1 1 3\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2078,
        "task_id": 3712,
        "test_case_id": 83,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "4\n2 2 2 2\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2079,
        "task_id": 3712,
        "test_case_id": 84,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "6\n2 2 2 2 2 4\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2080,
        "task_id": 3712,
        "test_case_id": 85,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "3\n2 2 4\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2081,
        "task_id": 3712,
        "test_case_id": 86,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "2\n2 3\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2082,
        "task_id": 3712,
        "test_case_id": 87,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "2\n1 4\n",
        "output": "-1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2083,
        "task_id": 3712,
        "test_case_id": 88,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "4\n1 1 3 3\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2084,
        "task_id": 3712,
        "test_case_id": 89,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "4\n3 3 3 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2085,
        "task_id": 3712,
        "test_case_id": 90,
        "question": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.\n\nThe students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.\n\nHowever, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number. \n\nAfter all the swaps each compartment should either have no student left, or have a company of three or four students. \n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 10^6) — the number of compartments in the carriage. The second line contains n integers a_1, a_2, ..., a_{n} showing how many students ride in each compartment (0 ≤ a_{i} ≤ 4). It is guaranteed that at least one student is riding in the train.\n\n\n-----Output-----\n\nIf no sequence of swapping seats with other people leads to the desired result, print number \"-1\" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.\n\n\n-----Examples-----\nInput\n5\n1 2 2 4 3\n\nOutput\n2\n\nInput\n3\n4 1 1\n\nOutput\n2\n\nInput\n4\n0 3 0 4\n\nOutput\n0",
        "solutions": "[\"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\ns = 0\\nfor x in [int(x) for x in input().split()]:\\n    counts[x] += 1\\n    s += x\\n\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\", \"n = int(input())\\nA = [0, 0, 0, 0, 0]\\nB = list(map(int, input().split(' ')))\\n\\nfor i in B:\\n\\tA[i] += 1\\n\\nres = min(A[1], A[2])\\nA[1] -= res\\nA[2] -= res\\nA[3] += res\\n\\nres += 2 * (A[1] // 3)\\nA[3] += A[1] // 3\\nA[1] %= 3\\n\\nres += 2 * (A[2] // 3)\\nA[3] += 2 * (A[2] // 3)\\nA[2] %= 3\\n\\nassert(A[1] == 0 or A[2] == 0)\\n\\nif (A[1] == 1):\\n\\tif (A[3] > 0):\\n\\t\\tres += 1 #; A[1] = 0; A[3] -= 1; A[4] += 1\\n\\telif (A[4] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 2; A[3] += 3\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[1] == 2):\\n\\tif (A[4] > 0):\\n\\t\\tres += 2 #; A[1] = 0; A[4] -= 1; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2 #; A[1] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\n\\nif (A[2] == 1):\\n\\tif (A[4] > 0):\\n\\t\\tres += 1 #; A[4] -= 1; A[2] = 0; A[3] += 1\\n\\telif (A[3] > 1):\\n\\t\\tres += 2; #; A[2] = 0; A[3] -= 2; A[4] += 2\\n\\telse:\\n\\t\\tprint(-1)\\n\\t\\treturn\\nelif (A[2] == 2):\\n\\tres += 2 #; A[2] = 0; A[4] += 1\\n\\t\\nprint(res)\\n\\n\", \"#! /usr/bin/env python\\n\\nn = int(input())\\ncounts = [0] * 5\\nnums = [int(x) for x in input().split()]\\nfor x in nums:\\n    counts[x] += 1\\n\\ns = sum(nums)\\nif s > 2 and s != 5:\\n    ans = 0\\n    if counts[1] >= counts[2]:\\n        ans += counts[2]\\n        counts[3] += counts[2]\\n        counts[1] -= counts[2]\\n        ans += 2 * (counts[1] // 3)\\n        counts[3] += counts[1] // 3\\n        counts[1] %= 3\\n        if counts[3] > 0:\\n            ans += counts[1]\\n        elif counts[1] != 0:\\n            ans += 2\\n    else:\\n        ans += counts[1]\\n        counts[2] -= counts[1]\\n        ans += 2 * (counts[2] // 3)\\n        counts[2] %= 3\\n        if counts[4] > 0:\\n            ans += counts[2]\\n        elif counts[2] != 0:\\n            ans += 2\\n    print(ans)\\nelse:\\n    print(-1)\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"n = int(input())\\nseq = list(map(int, input().split(\\\" \\\")))\\n\\nif sum(seq) < 3 or sum(seq) == 5:\\n\\tprint(-1)\\n\\nelse:\\n\\tarr = [0,0,0,0,0]\\n\\tfor s in seq:\\n\\t\\tarr[s] += 1\\n\\t#print(arr)\\n\\t\\n\\tans = 0\\n\\tif arr[2] >= arr[1]:\\n\\t\\tans += arr[1]\\n\\t\\tarr[2] -= arr[1]\\n\\t\\tarr[3] += arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tans += arr[2]\\n\\t\\tarr[1] -= arr[2]\\n\\t\\tarr[3] += arr[2]\\n\\t\\tarr[2] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\n\\tans += 2*(arr[1]//3)\\n\\tarr[3] += arr[1]//3\\n\\tarr[1] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif (arr[3] >= arr[1]):\\n\\t\\tans += arr[1]\\n\\t\\tarr[4] += arr[1]\\n\\t\\tarr[3] -= arr[1]\\n\\t\\tarr[1] = 0\\n\\telse:\\n\\t\\tif arr[1] < 2:\\n\\t\\t\\tans += arr[3]\\n\\t\\t\\tarr[4] += arr[3]\\n\\t\\t\\tarr[1] -= arr[3]\\n\\t\\t\\tarr[3] = 0\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[1] > 0:\\n\\t\\tif arr[1] == 2:\\n\\t\\t\\tans += arr[1]\\n\\t\\t\\tarr[4] -= 1\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\telse:\\n\\t\\t\\tans += 2\\n\\t\\t\\tarr[4] -= 2\\n\\t\\t\\tarr[3] += 2\\n\\t\\t\\tarr[1] = 0\\n\\t\\n\\tans += 2*(arr[2]//3)\\n\\tarr[3] += 2*(arr[2]//3)\\n\\tarr[2] %= 3\\n\\t#print(arr, ans)\\n\\t\\n\\tif arr[2] > 0:\\n\\t\\tif (arr[4] >= arr[2]):\\n\\t\\t\\tans += arr[2]\\n\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\t\\t\\n\\t\\t\\tans += 2*(arr[2])\\n\\t\\t\\tarr[4] += 2*arr[2]\\n\\t\\t\\tarr[3] -= arr[2]\\n\\t\\t\\tarr[2] = 0\\n\\t\\t\\t#print(arr, ans)\\n\\t\\telse:\\n\\t\\t\\tif (arr[4] > 0):\\n\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\tarr[4] -= arr[2]\\n\\t\\t\\t\\tarr[3] += 2*arr[2]\\n\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\t#print(arr, ans)\\n\\t\\t\\telse:\\n\\t\\t\\t\\tif arr[2] == 1:\\n\\t\\t\\t\\t\\tans += 2*arr[2]\\n\\t\\t\\t\\t\\tarr[3] += 2\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tans += arr[2]\\n\\t\\t\\t\\t\\tarr[4] += 1\\n\\t\\t\\t\\t\\tarr[2] = 0\\n\\t\\n\\tprint(ans)\", \"a = [0] * 5\\ntot, ans = 0, 0\\n\\ninput()\\nfor x in list(map(int, input().split())):\\n  a[x] += 1\\n  tot += x\\n\\nif tot < 3 or tot == 5:\\n  print(-1);return()\\n\\nmn = min(a[1], a[2])\\na[1] -= mn\\na[2] -= mn\\na[3] += mn\\nans += mn\\n\\nif a[1]:\\n  add = a[1] // 3\\n  a[1] %= 3\\n  a[3] += add\\n  ans += 2 * add\\n  ans += 1 if a[1] == 1 and a[3] else 2 if a[1] else 0\\n\\nif a[2]:\\n  add = a[2] // 3\\n  a[2] %= 3\\n  a[3] += 2 * add\\n  ans += 2 * add\\n  ans += 1 if a[2] == 1 and a[4] else 2 if a[2] else 0\\n\\nprint(ans)\"]",
        "difficulty": "competition",
        "input": "1\n4\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/356/C"
    },
    {
        "id": 2086,
        "task_id": 3742,
        "test_case_id": 20,
        "question": "Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the garland. Now Vadim wants to put them back on.[Image]\n\nVadim wants to put all bulb back on the garland. Vadim defines complexity of a garland to be the number of pairs of adjacent bulbs with numbers with different parity (remainder of the division by $2$). For example, the complexity of 1 4 2 3 5 is $2$ and the complexity of 1 3 5 7 6 4 2 is $1$.\n\nNo one likes complexity, so Vadim wants to minimize the number of such pairs. Find the way to put all bulbs back on the garland, such that the complexity is as small as possible.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 100$) — the number of light bulbs on the garland.\n\nThe second line contains $n$ integers $p_1,\\ p_2,\\ \\ldots,\\ p_n$ ($0 \\le p_i \\le n$) — the number on the $i$-th bulb, or $0$ if it was removed.\n\n\n-----Output-----\n\nOutput a single number — the minimum complexity of the garland.\n\n\n-----Examples-----\nInput\n5\n0 5 0 2 3\n\nOutput\n2\n\nInput\n7\n1 0 0 5 0 0 2\n\nOutput\n1\n\n\n\n-----Note-----\n\nIn the first example, one should place light bulbs as 1 5 4 2 3. In that case, the complexity would be equal to 2, because only $(5, 4)$ and $(2, 3)$ are the pairs of adjacent bulbs that have different parity.\n\nIn the second case, one of the correct answers is 1 7 3 5 6 4 2.",
        "solutions": "[\"import sys\\nreadline = sys.stdin.readline\\n\\nN = int(readline())\\nS = list(map(int, readline().split()))\\nS = [0 if s == 0 else 1 if s & 1 else -1 for s in S]\\n\\nodd = -(-N//2)\\neven = N//2\\nfor s in S:\\n    if s:\\n        if s == 1:\\n            odd -= 1\\n        else:\\n            even -= 1\\n\\ninf = 10**9\\ndpe = [[inf]*(odd+1) for _ in range(even+1)]\\ndpo = [[inf]*(odd+1) for _ in range(even+1)]\\ndpe[0][0] = 0\\ndpo[0][0] = 0\\n\\nfor i in range(N):\\n    dp2e = [[inf]*(odd+1) for _ in range(even+1)]\\n    dp2o = [[inf]*(odd+1) for _ in range(even+1)]\\n    s = S[i]\\n    for e in range(even+1):\\n        for o in range(odd+1):\\n            if s == 1:\\n                dp2o[e][o] = min(dp2o[e][o], dpo[e][o], 1+dpe[e][o])\\n            elif s == -1:\\n                dp2e[e][o] = min(dp2e[e][o], dpe[e][o], 1+dpo[e][o])\\n            else:\\n                if o < odd:\\n                    dp2o[e][o+1] = min(dp2o[e][o+1], dpo[e][o], 1+dpe[e][o])\\n                if e < even:\\n                    dp2e[e+1][o] = min(dp2e[e+1][o], dpe[e][o], 1+dpo[e][o])\\n    dpe = [d[:] for d in dp2e]\\n    dpo = [d[:] for d in dp2o]\\n\\nprint(min(dpe[even][odd], dpo[even][odd]))\", \"n = int(input())\\na = list(map(int, input().split()))\\nINF = 10**5\\n\\ndp = [[[INF]*(n+1) for i in range(n+1)] for i in range(2)]\\ndp[0][0][0] = 0\\ndp[1][0][0] = 0\\n\\nfor i in range(n):\\n    if a[i] != 0:\\n        parity = a[i] % 2\\n        if parity % 2 == 0:\\n            for j in range(n+1):\\n                dp[0][i+1][j] = min(dp[0][i][j], dp[0][i+1][j])\\n                dp[0][i+1][j] = min(dp[1][i][j] + 1, dp[0][i+1][j])\\n        if parity % 2 == 1:\\n            for j in range(n):\\n                dp[1][i+1][j+1] = min(dp[1][i][j], dp[1][i+1][j+1])\\n                dp[1][i+1][j+1] = min(dp[0][i][j] + 1, dp[1][i+1][j+1])\\n    else:\\n        for j in range(n+1):\\n            dp[0][i+1][j] = min(dp[0][i][j], dp[0][i+1][j])\\n            dp[0][i+1][j] = min(dp[1][i][j] + 1, dp[0][i+1][j])\\n        for j in range(n):\\n            dp[1][i+1][j+1] = min(dp[1][i][j], dp[1][i+1][j+1])\\n            dp[1][i+1][j+1] = min(dp[0][i][j] + 1, dp[1][i+1][j+1])\\n\\nodd_cnt = (n+1) // 2\\neven_cnt = n // 2\\n\\nprint(min(dp[1][n][odd_cnt], dp[0][n][odd_cnt]))\\n\", \"import sys\\nreader = (s.rstrip() for s in sys.stdin)\\ninput = reader.__next__\\n\\nn = int(input())\\np = list(map(int, input().split()))\\nodd = (n+1)//2\\neven = n-odd\\nfor i in p:\\n    if i:\\n        if i%2 == 0:\\n            even -= 1\\n        else:\\n            odd -= 1\\n\\nif even == 0:\\n    p = [i if i else 1 for i in p]\\nif odd*even == 0:\\n    ans = 0\\n    prev = p[0]\\n    for pi in p:\\n        ans += (pi+prev)%2\\n        prev = pi\\n    print(ans)\\n    return\\n\\nDP = [[float(\\\"inf\\\")]*(even+1) for i in range(2)]\\nfor i in range(n):\\n    nxt = [[float(\\\"inf\\\")]*(even+1) for i in range(2)]\\n    if i == 0:\\n        if p[i]:\\n            if p[i]%2 == 0:\\n                nxt[0][0] = 0\\n            else:\\n                nxt[1][0] = 0\\n        else:\\n            nxt[0][1] = 0\\n            nxt[1][0] = 0\\n    else:\\n        if p[i]:\\n            if p[i]%2 == 0:\\n                for j in range(even+1):\\n                    nxt[0][j] = min(DP[0][j], DP[1][j]+1)\\n            else:\\n                for j in range(even+1):\\n                    nxt[1][j] = min(DP[0][j]+1, DP[1][j])\\n        else:\\n            for j in range(1, even+1):\\n                nxt[0][j] = min(DP[0][j-1], DP[1][j-1]+1)\\n            for j in range(even+1):\\n                nxt[1][j] = min(DP[0][j]+1, DP[1][j])\\n    DP = nxt\\nprint(min(DP[0][-1], DP[1][-1]))\\n\\n\", \"import sys\\n\\ninf = 2 ** 30\\n\\ndef solution(a):\\n    n = len(a)\\n    m = ((n + 1) >> 1) - sum([v & 1 for v in a])\\n    f = [[[inf for k in range(2)] for j in range(m +1)] for i in range(n + 1)]\\n    f[0][0][0], f[0][0][1] = 0, 0\\n    for i in range(n):\\n        for j in range(min(m, i) + 1):\\n            for k in range(2):\\n                #sys.stderr.write('f[%d][%d][%d] = %d\\\\n' % (i, j, k, f[i][j][k]));\\n                # fixed\\n                if a[i] != 0:\\n                    t = a[i] & 1 \\n                    w = 1 if t != k else 0\\n                    f[i + 1][j][t] = min(f[i][j][k] + w, f[i + 1][j][t])\\n                    continue\\n                # +1\\n                if j < m:\\n                    w = 1 if k != 1 else 0\\n                    f[i + 1][j + 1][1] = min(f[i][j][k] + w, f[i + 1][j + 1][1])\\n                # +0\\n                w = 1 if k != 0 else 0\\n                f[i + 1][j][0] = min(f[i][j][k] + w, f[i + 1][j][0])\\n    return min(f[n][m][0], f[n][m][1])\\n\\ndef main():\\n    while True:\\n        try:\\n            n = int(input().strip())\\n            a = [int(i) for i in input().strip().split()]\\n            sys.stdout.write('%d\\\\n' % solution(a))\\n        except ValueError:\\n            continue\\n        except EOFError:\\n            break\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\"]",
        "difficulty": "competition",
        "input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1286/A"
    },
    {
        "id": 2087,
        "task_id": 3744,
        "test_case_id": 1,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "5 2 2\n1 3 4 5 2\n5 3 2 1 4\n",
        "output": "18\n3 4 \n1 5 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2088,
        "task_id": 3744,
        "test_case_id": 3,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "5 3 1\n5 2 5 1 7\n6 3 1 6 3\n",
        "output": "23\n1 3 5 \n4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2089,
        "task_id": 3744,
        "test_case_id": 5,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "4 1 1\n100 100 1 50\n100 100 50 1\n",
        "output": "200\n1 \n2 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2090,
        "task_id": 3744,
        "test_case_id": 9,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "3 1 1\n5 4 2\n1 5 2\n",
        "output": "10\n1 \n2 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2091,
        "task_id": 3744,
        "test_case_id": 10,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "3 1 1\n10 5 5\n9 1 4\n",
        "output": "14\n1 \n3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2092,
        "task_id": 3744,
        "test_case_id": 11,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "3 1 1\n17 6 2\n2 19 19\n",
        "output": "36\n1 \n2 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2093,
        "task_id": 3744,
        "test_case_id": 12,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "4 1 2\n4 2 4 5\n3 2 5 3\n",
        "output": "13\n4 \n1 3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2094,
        "task_id": 3744,
        "test_case_id": 13,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "4 1 2\n8 7 8 6\n4 5 10 9\n",
        "output": "27\n1 \n3 4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2095,
        "task_id": 3744,
        "test_case_id": 15,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "5 1 1\n3 2 5 5 1\n3 1 5 4 2\n",
        "output": "10\n4 \n3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2096,
        "task_id": 3744,
        "test_case_id": 16,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "5 2 1\n9 10 1 7 10\n6 10 8 6 3\n",
        "output": "29\n1 5 \n2 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2097,
        "task_id": 3744,
        "test_case_id": 18,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "6 2 1\n4 3 4 3 3 2\n4 4 3 5 3 5\n",
        "output": "13\n1 3 \n4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2098,
        "task_id": 3744,
        "test_case_id": 19,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "6 1 4\n7 9 3 5 9 2\n10 9 10 10 10 1\n",
        "output": "49\n2 \n1 3 4 5 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2099,
        "task_id": 3744,
        "test_case_id": 21,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "7 2 1\n2 2 2 2 2 1 2\n4 2 5 5 2 5 1\n",
        "output": "9\n1 2 \n3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2100,
        "task_id": 3744,
        "test_case_id": 22,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "7 5 1\n1 8 8 6 4 3 9\n4 4 5 8 5 7 1\n",
        "output": "42\n2 3 4 5 7 \n6 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2101,
        "task_id": 3744,
        "test_case_id": 23,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "7 2 3\n15 1 5 17 16 9 1\n9 8 5 9 18 14 3\n",
        "output": "72\n1 4 \n2 5 6 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2102,
        "task_id": 3744,
        "test_case_id": 24,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "8 3 4\n5 5 4 2 4 1 3 2\n2 5 3 3 2 4 5 1\n",
        "output": "30\n1 3 5 \n2 4 6 7 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2103,
        "task_id": 3744,
        "test_case_id": 25,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "8 5 1\n2 4 1 5 8 5 9 7\n10 2 3 1 6 3 8 6\n",
        "output": "44\n4 5 6 7 8 \n1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2104,
        "task_id": 3744,
        "test_case_id": 26,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "8 1 1\n19 14 17 8 16 14 11 16\n12 12 10 4 3 11 10 8\n",
        "output": "31\n1 \n2 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2105,
        "task_id": 3744,
        "test_case_id": 27,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "9 1 1\n3 2 3 5 3 1 5 2 3\n1 4 5 4 2 5 4 4 5\n",
        "output": "10\n4 \n3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2106,
        "task_id": 3744,
        "test_case_id": 28,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "9 2 4\n4 3 3 1 1 10 9 8 5\n5 4 4 6 5 10 1 5 5\n",
        "output": "43\n7 8 \n1 4 5 6 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2107,
        "task_id": 3744,
        "test_case_id": 29,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "9 2 2\n20 7 6 7 19 15 2 7 8\n15 15 1 13 20 14 13 18 3\n",
        "output": "73\n1 6 \n5 8 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2108,
        "task_id": 3744,
        "test_case_id": 30,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "10 5 2\n4 5 3 1 1 5 2 4 1 5\n3 4 2 2 2 3 2 1 2 4\n",
        "output": "27\n1 2 6 8 10 \n3 4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2109,
        "task_id": 3744,
        "test_case_id": 32,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "10 3 1\n7 11 11 3 19 10 18 7 9 20\n13 9 19 15 13 14 7 12 15 16\n",
        "output": "76\n5 7 10 \n3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2110,
        "task_id": 3744,
        "test_case_id": 33,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "11 4 2\n2 2 4 2 3 5 4 4 5 5 4\n4 4 1 2 1 2 2 5 3 4 3\n",
        "output": "28\n3 6 9 10 \n1 8 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2111,
        "task_id": 3744,
        "test_case_id": 34,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "11 1 5\n7 10 1 2 10 8 10 9 5 5 9\n2 1 1 3 5 9 3 4 2 2 3\n",
        "output": "34\n2 \n4 5 6 7 8 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2112,
        "task_id": 3744,
        "test_case_id": 35,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "11 6 1\n7 4 7 2 2 12 16 2 5 15 2\n3 12 8 5 7 1 4 19 12 1 14\n",
        "output": "81\n1 3 6 7 9 10 \n8 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2113,
        "task_id": 3744,
        "test_case_id": 36,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "12 4 1\n4 5 1 4 3 3 2 4 3 4 3 2\n1 3 5 3 5 5 5 5 3 5 3 2\n",
        "output": "22\n1 2 4 8 \n3 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2114,
        "task_id": 3744,
        "test_case_id": 37,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "12 8 1\n4 3 3 5 6 10 10 10 10 8 4 5\n1 7 4 10 8 1 2 4 8 4 4 2\n",
        "output": "73\n1 5 6 7 8 9 10 12 \n4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2115,
        "task_id": 3744,
        "test_case_id": 38,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "12 2 4\n16 17 12 8 18 9 2 9 13 18 3 8\n18 20 9 12 11 19 20 3 13 1 6 9\n",
        "output": "113\n5 10 \n1 2 6 7 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2116,
        "task_id": 3744,
        "test_case_id": 39,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "13 1 10\n1 4 5 3 1 3 4 3 1 5 3 2 3\n2 3 5 1 4 3 5 4 2 1 3 4 2\n",
        "output": "40\n10 \n1 2 3 5 6 7 8 9 11 12 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2117,
        "task_id": 3744,
        "test_case_id": 40,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "13 2 2\n2 2 6 2 9 5 10 3 10 1 1 1 1\n10 8 3 8 6 6 8 1 4 10 10 1 8\n",
        "output": "40\n7 9 \n1 10 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2118,
        "task_id": 3744,
        "test_case_id": 41,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "13 3 1\n16 6 5 11 17 11 13 12 18 5 12 6 12\n12 20 9 9 19 4 19 4 1 12 1 12 4\n",
        "output": "71\n1 5 9 \n2 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2119,
        "task_id": 3744,
        "test_case_id": 42,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "14 1 3\n1 1 2 3 4 3 1 3 4 5 3 5 5 5\n3 2 1 1 1 4 2 2 1 4 4 4 5 4\n",
        "output": "18\n10 \n6 11 13 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2120,
        "task_id": 3744,
        "test_case_id": 43,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "14 2 1\n3 5 9 5 4 6 1 10 4 10 6 5 10 2\n10 8 8 6 1 8 9 1 6 1 4 5 9 4\n",
        "output": "30\n8 10 \n1 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2121,
        "task_id": 3744,
        "test_case_id": 44,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "14 2 8\n20 14 17 18 12 12 19 3 2 20 13 12 17 20\n20 10 3 15 8 15 12 12 14 2 1 15 7 10\n",
        "output": "153\n10 14 \n1 2 4 6 7 8 9 12 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2122,
        "task_id": 3744,
        "test_case_id": 45,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "15 7 6\n2 5 4 1 1 3 3 1 4 4 4 3 4 1 1\n5 5 2 5 4 1 4 5 1 5 4 1 4 4 4\n",
        "output": "55\n2 3 6 9 11 12 13 \n1 4 5 7 8 10 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2123,
        "task_id": 3744,
        "test_case_id": 46,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "15 1 10\n7 8 1 5 8 8 9 7 4 3 7 4 10 8 3\n3 8 6 5 10 1 9 2 3 8 1 9 3 6 10\n",
        "output": "84\n13 \n1 2 3 4 5 7 10 12 14 15 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2124,
        "task_id": 3744,
        "test_case_id": 47,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "15 3 7\n1 11 6 5 16 13 17 6 2 7 19 5 3 13 11\n11 9 6 9 19 4 16 20 11 19 1 10 20 4 7\n",
        "output": "161\n6 11 14 \n1 5 7 8 9 10 13 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2125,
        "task_id": 3744,
        "test_case_id": 48,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "16 2 7\n5 4 4 1 5 3 1 1 2 3 3 4 5 5 1 4\n4 5 3 5 4 1 2 2 3 2 2 3 4 5 3 1\n",
        "output": "38\n1 5 \n2 3 4 9 12 13 14 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2126,
        "task_id": 3744,
        "test_case_id": 49,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "16 4 8\n2 6 6 4 1 9 5 8 9 10 2 8 9 8 1 7\n8 9 5 2 4 10 9 2 1 5 6 7 1 1 8 1\n",
        "output": "98\n8 9 10 13 \n1 2 3 6 7 11 12 15 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2127,
        "task_id": 3744,
        "test_case_id": 50,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "16 4 1\n5 20 3 7 19 19 7 17 18 10 16 11 16 9 15 9\n19 2 13 11 8 19 6 7 16 8 8 5 18 18 20 10\n",
        "output": "96\n2 5 6 9 \n15 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2128,
        "task_id": 3744,
        "test_case_id": 51,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "17 1 12\n2 4 5 5 3 3 3 3 1 4 4 1 2 2 3 3 3\n4 1 5 4 2 5 3 4 2 2 5 2 2 5 5 5 3\n",
        "output": "54\n10 \n1 3 4 5 6 7 8 11 14 15 16 17 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2129,
        "task_id": 3744,
        "test_case_id": 52,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "17 8 2\n10 5 9 1 7 5 2 9 3 5 8 4 3 5 4 2 4\n9 10 8 10 10 5 6 2 2 4 6 9 10 3 2 5 1\n",
        "output": "78\n1 3 5 6 8 10 11 14 \n2 4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2130,
        "task_id": 3744,
        "test_case_id": 53,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "17 6 5\n18 9 15 14 15 20 18 8 3 9 17 5 2 17 7 10 13\n17 10 7 3 7 11 4 5 18 15 15 15 5 9 7 5 5\n",
        "output": "179\n3 4 5 6 7 14 \n1 9 10 11 12 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2131,
        "task_id": 3744,
        "test_case_id": 54,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "18 5 2\n5 3 3 4 1 4 5 3 3 3 4 2 4 2 3 1 4 4\n5 4 3 4 5 1 5 5 2 1 3 2 1 1 1 3 5 5\n",
        "output": "32\n1 4 6 7 11 \n5 8 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2132,
        "task_id": 3744,
        "test_case_id": 55,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "18 8 1\n6 10 1 1 10 6 10 2 7 2 3 7 7 7 6 5 8 8\n4 4 4 7 1 5 2 2 7 10 2 7 6 6 2 1 4 3\n",
        "output": "77\n2 5 7 9 12 13 17 18 \n10 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2133,
        "task_id": 3744,
        "test_case_id": 56,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "18 5 3\n18 1 8 13 18 1 16 11 11 12 6 14 16 13 10 7 19 17\n14 3 7 18 9 16 3 5 17 8 1 8 2 8 20 1 16 11\n",
        "output": "143\n1 5 7 17 18 \n4 9 15 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2134,
        "task_id": 3744,
        "test_case_id": 57,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "19 6 1\n4 5 2 3 4 3 2 3 3 3 5 5 1 4 1 2 4 2 5\n1 2 1 4 1 3 3 2 4 1 3 4 3 3 4 4 4 5 5\n",
        "output": "33\n1 2 5 11 12 19 \n18 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2135,
        "task_id": 3744,
        "test_case_id": 58,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "19 14 2\n5 3 4 10 5 7 10 9 2 5 4 3 2 3 10 10 6 4 1\n6 10 5 3 8 9 9 3 1 6 4 4 3 6 8 5 9 3 9\n",
        "output": "111\n1 3 4 5 6 7 8 10 11 12 15 16 17 18 \n2 19 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2136,
        "task_id": 3744,
        "test_case_id": 59,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "19 1 4\n2 10 1 3 13 3 6 2 15 15 7 8 1 18 2 12 9 8 14\n15 3 2 15 9 12 19 20 2 18 15 11 18 6 8 16 17 1 12\n",
        "output": "93\n14 \n7 8 10 13 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2137,
        "task_id": 3744,
        "test_case_id": 60,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "20 3 6\n3 4 4 5 1 2 2 3 5 5 2 2 1 4 1 5 2 2 1 5\n1 4 5 2 2 2 2 5 3 2 4 5 2 1 3 3 1 3 5 3\n",
        "output": "43\n4 9 10 \n2 3 8 11 12 19 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2138,
        "task_id": 3744,
        "test_case_id": 61,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "20 2 5\n9 5 1 8 6 3 5 9 9 9 9 3 4 1 7 2 1 1 3 5\n5 6 4 10 7 9 1 6 9 5 2 1 3 1 5 9 10 8 9 9\n",
        "output": "65\n1 8 \n4 6 9 16 17 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2139,
        "task_id": 3744,
        "test_case_id": 62,
        "question": "There are n students at Berland State University. Every student has two skills, each measured as a number: a_{i} — the programming skill and b_{i} — the sports skill.\n\nIt is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.\n\nThere should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.\n\nThe university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all a_{i} and the strength of the sports team is the sum of all b_{i} over corresponding team members.\n\nHelp Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.\n\n\n-----Input-----\n\nThe first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 3000), where a_{i} is the programming skill of the i-th student.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 3000), where b_{i} is the sports skill of the i-th student.\n\n\n-----Output-----\n\nIn the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.\n\nThe students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.\n\nIf there are multiple solutions, print any of them.\n\n\n-----Examples-----\nInput\n5 2 2\n1 3 4 5 2\n5 3 2 1 4\n\nOutput\n18\n3 4 \n1 5 \n\nInput\n4 2 2\n10 8 8 3\n10 7 9 4\n\nOutput\n31\n1 2 \n3 4 \n\nInput\n5 3 1\n5 2 5 1 7\n6 3 1 6 3\n\nOutput\n23\n1 3 5 \n4",
        "solutions": "[\"#!/usr/bin/env python3\\nfrom itertools import accumulate\\nfrom heapq import heappop, heappush\\n\\n\\ndef top(ppl_indices, vals, start):\\n    Q = []\\n    res = [0 for i in range(len(ppl_indices))]\\n    for k, idx in enumerate(ppl_indices):\\n        heappush(Q, -vals[idx])\\n        if k >= start:\\n            res[k] = res[k-1] - heappop(Q)\\n\\n    return res\\n\\n\\nn, a_size, b_size = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nb = list(map(int, input().split()))\\n\\nconversion_gain = [y - x for x, y in zip(a, b)]\\n\\nordered_by_a = sorted(zip(a, list(range(n))), reverse=True)\\nprefix_sums_a = list(accumulate([x for x, y in ordered_by_a]))\\nconversions = top([idx for val, idx in ordered_by_a], conversion_gain, a_size)\\nrest_of_bs = list(reversed(top([idx for val, idx in reversed(ordered_by_a[a_size:])],\\n                               b, n - a_size - b_size))) + [0]\\n\\nsol, top_k = max([(prefix_a + convert + add_bs, idx)\\n                  for idx, (prefix_a, convert, add_bs)\\n                  in enumerate(zip(prefix_sums_a[a_size-1:a_size+b_size],\\n                                   conversions[a_size-1:a_size+b_size],\\n                                   rest_of_bs))])\\ntop_k += a_size\\n\\nconversion_ordered_by_a = [(conversion_gain[idx], idx) for val, idx in ordered_by_a]\\nconversion_sorted = sorted(conversion_ordered_by_a[:top_k], reverse=True)\\nconverted = [idx for val, idx in conversion_sorted[:top_k-a_size]]\\nteam_a = list(set(idx for val, idx in ordered_by_a[:top_k]) - set(converted))\\n\\nb_ordered_by_a = [(b[idx], idx) for val, idx in ordered_by_a]\\nb_sorted = sorted(b_ordered_by_a[top_k:], reverse=True)\\nteam_b = converted + [idx for val, idx in b_sorted[:(a_size+b_size) - top_k]]\\n\\nprint(sol)\\nprint(\\\" \\\".join(str(idx+1) for idx in team_a))\\nprint(\\\" \\\".join(str(idx+1) for idx in team_b))\\n\"]",
        "difficulty": "competition",
        "input": "20 1 7\n20 8 10 7 14 9 17 19 19 9 20 6 1 14 11 15 12 10 20 15\n10 3 20 1 16 7 8 19 3 17 9 2 20 14 20 2 20 9 2 4\n",
        "output": "152\n1 \n3 5 8 10 13 15 17 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/I"
    },
    {
        "id": 2140,
        "task_id": 3767,
        "test_case_id": 4,
        "question": "Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).\n\nNick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another.\n\nNick asks you to help him to determine k — the minimal number of bottles to store all remaining soda and t — the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved.\n\n\n-----Input-----\n\nThe first line contains positive integer n (1 ≤ n ≤ 100) — the number of bottles.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 100), where a_{i} is the amount of soda remaining in the i-th bottle.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 100), where b_{i} is the volume of the i-th bottle.\n\nIt is guaranteed that a_{i} ≤ b_{i} for any i.\n\n\n-----Output-----\n\nThe only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles.\n\n\n-----Examples-----\nInput\n4\n3 3 4 3\n4 7 6 5\n\nOutput\n2 6\n\nInput\n2\n1 1\n100 100\n\nOutput\n1 1\n\nInput\n5\n10 30 5 6 24\n10 41 7 8 24\n\nOutput\n3 11\n\n\n\n-----Note-----\n\nIn the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.",
        "solutions": "[\"f = lambda: list(map(int, input().split()))\\nn = int(input())\\na, b = f(), f()\\n\\nd = [[None] * 10001 for i in range(n)]\\n\\ndef g(i, s):\\n    if s <= 0: return (0, s)\\n    if i == n: return (1e7, 0)\\n\\n    if not d[i][s]:\\n        x, y = g(i + 1, s - b[i])\\n        d[i][s] = min(g(i + 1, s), (x + 1, y + b[i] - a[i]))\\n    return d[i][s]\\n\\nx, y = g(0, sum(a))\\nprint(x, y)\"]",
        "difficulty": "competition",
        "input": "1\n1\n100\n",
        "output": "1 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/J"
    },
    {
        "id": 2141,
        "task_id": 3767,
        "test_case_id": 5,
        "question": "Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).\n\nNick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another.\n\nNick asks you to help him to determine k — the minimal number of bottles to store all remaining soda and t — the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved.\n\n\n-----Input-----\n\nThe first line contains positive integer n (1 ≤ n ≤ 100) — the number of bottles.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 100), where a_{i} is the amount of soda remaining in the i-th bottle.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 100), where b_{i} is the volume of the i-th bottle.\n\nIt is guaranteed that a_{i} ≤ b_{i} for any i.\n\n\n-----Output-----\n\nThe only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles.\n\n\n-----Examples-----\nInput\n4\n3 3 4 3\n4 7 6 5\n\nOutput\n2 6\n\nInput\n2\n1 1\n100 100\n\nOutput\n1 1\n\nInput\n5\n10 30 5 6 24\n10 41 7 8 24\n\nOutput\n3 11\n\n\n\n-----Note-----\n\nIn the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.",
        "solutions": "[\"f = lambda: list(map(int, input().split()))\\nn = int(input())\\na, b = f(), f()\\n\\nd = [[None] * 10001 for i in range(n)]\\n\\ndef g(i, s):\\n    if s <= 0: return (0, s)\\n    if i == n: return (1e7, 0)\\n\\n    if not d[i][s]:\\n        x, y = g(i + 1, s - b[i])\\n        d[i][s] = min(g(i + 1, s), (x + 1, y + b[i] - a[i]))\\n    return d[i][s]\\n\\nx, y = g(0, sum(a))\\nprint(x, y)\"]",
        "difficulty": "competition",
        "input": "1\n100\n100\n",
        "output": "1 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/J"
    },
    {
        "id": 2142,
        "task_id": 3767,
        "test_case_id": 6,
        "question": "Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).\n\nNick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another.\n\nNick asks you to help him to determine k — the minimal number of bottles to store all remaining soda and t — the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved.\n\n\n-----Input-----\n\nThe first line contains positive integer n (1 ≤ n ≤ 100) — the number of bottles.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 100), where a_{i} is the amount of soda remaining in the i-th bottle.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 100), where b_{i} is the volume of the i-th bottle.\n\nIt is guaranteed that a_{i} ≤ b_{i} for any i.\n\n\n-----Output-----\n\nThe only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles.\n\n\n-----Examples-----\nInput\n4\n3 3 4 3\n4 7 6 5\n\nOutput\n2 6\n\nInput\n2\n1 1\n100 100\n\nOutput\n1 1\n\nInput\n5\n10 30 5 6 24\n10 41 7 8 24\n\nOutput\n3 11\n\n\n\n-----Note-----\n\nIn the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.",
        "solutions": "[\"f = lambda: list(map(int, input().split()))\\nn = int(input())\\na, b = f(), f()\\n\\nd = [[None] * 10001 for i in range(n)]\\n\\ndef g(i, s):\\n    if s <= 0: return (0, s)\\n    if i == n: return (1e7, 0)\\n\\n    if not d[i][s]:\\n        x, y = g(i + 1, s - b[i])\\n        d[i][s] = min(g(i + 1, s), (x + 1, y + b[i] - a[i]))\\n    return d[i][s]\\n\\nx, y = g(0, sum(a))\\nprint(x, y)\"]",
        "difficulty": "competition",
        "input": "1\n50\n100\n",
        "output": "1 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/J"
    },
    {
        "id": 2143,
        "task_id": 3767,
        "test_case_id": 44,
        "question": "Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).\n\nNick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another.\n\nNick asks you to help him to determine k — the minimal number of bottles to store all remaining soda and t — the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved.\n\n\n-----Input-----\n\nThe first line contains positive integer n (1 ≤ n ≤ 100) — the number of bottles.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 100), where a_{i} is the amount of soda remaining in the i-th bottle.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 100), where b_{i} is the volume of the i-th bottle.\n\nIt is guaranteed that a_{i} ≤ b_{i} for any i.\n\n\n-----Output-----\n\nThe only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles.\n\n\n-----Examples-----\nInput\n4\n3 3 4 3\n4 7 6 5\n\nOutput\n2 6\n\nInput\n2\n1 1\n100 100\n\nOutput\n1 1\n\nInput\n5\n10 30 5 6 24\n10 41 7 8 24\n\nOutput\n3 11\n\n\n\n-----Note-----\n\nIn the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.",
        "solutions": "[\"f = lambda: list(map(int, input().split()))\\nn = int(input())\\na, b = f(), f()\\n\\nd = [[None] * 10001 for i in range(n)]\\n\\ndef g(i, s):\\n    if s <= 0: return (0, s)\\n    if i == n: return (1e7, 0)\\n\\n    if not d[i][s]:\\n        x, y = g(i + 1, s - b[i])\\n        d[i][s] = min(g(i + 1, s), (x + 1, y + b[i] - a[i]))\\n    return d[i][s]\\n\\nx, y = g(0, sum(a))\\nprint(x, y)\"]",
        "difficulty": "competition",
        "input": "1\n1\n1\n",
        "output": "1 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/J"
    },
    {
        "id": 2144,
        "task_id": 3767,
        "test_case_id": 45,
        "question": "Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).\n\nNick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another.\n\nNick asks you to help him to determine k — the minimal number of bottles to store all remaining soda and t — the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved.\n\n\n-----Input-----\n\nThe first line contains positive integer n (1 ≤ n ≤ 100) — the number of bottles.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 100), where a_{i} is the amount of soda remaining in the i-th bottle.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 100), where b_{i} is the volume of the i-th bottle.\n\nIt is guaranteed that a_{i} ≤ b_{i} for any i.\n\n\n-----Output-----\n\nThe only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles.\n\n\n-----Examples-----\nInput\n4\n3 3 4 3\n4 7 6 5\n\nOutput\n2 6\n\nInput\n2\n1 1\n100 100\n\nOutput\n1 1\n\nInput\n5\n10 30 5 6 24\n10 41 7 8 24\n\nOutput\n3 11\n\n\n\n-----Note-----\n\nIn the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.",
        "solutions": "[\"f = lambda: list(map(int, input().split()))\\nn = int(input())\\na, b = f(), f()\\n\\nd = [[None] * 10001 for i in range(n)]\\n\\ndef g(i, s):\\n    if s <= 0: return (0, s)\\n    if i == n: return (1e7, 0)\\n\\n    if not d[i][s]:\\n        x, y = g(i + 1, s - b[i])\\n        d[i][s] = min(g(i + 1, s), (x + 1, y + b[i] - a[i]))\\n    return d[i][s]\\n\\nx, y = g(0, sum(a))\\nprint(x, y)\"]",
        "difficulty": "competition",
        "input": "1\n1\n2\n",
        "output": "1 0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/J"
    },
    {
        "id": 2145,
        "task_id": 3767,
        "test_case_id": 47,
        "question": "Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).\n\nNick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another.\n\nNick asks you to help him to determine k — the minimal number of bottles to store all remaining soda and t — the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved.\n\n\n-----Input-----\n\nThe first line contains positive integer n (1 ≤ n ≤ 100) — the number of bottles.\n\nThe second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 100), where a_{i} is the amount of soda remaining in the i-th bottle.\n\nThe third line contains n positive integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 100), where b_{i} is the volume of the i-th bottle.\n\nIt is guaranteed that a_{i} ≤ b_{i} for any i.\n\n\n-----Output-----\n\nThe only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles.\n\n\n-----Examples-----\nInput\n4\n3 3 4 3\n4 7 6 5\n\nOutput\n2 6\n\nInput\n2\n1 1\n100 100\n\nOutput\n1 1\n\nInput\n5\n10 30 5 6 24\n10 41 7 8 24\n\nOutput\n3 11\n\n\n\n-----Note-----\n\nIn the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.",
        "solutions": "[\"f = lambda: list(map(int, input().split()))\\nn = int(input())\\na, b = f(), f()\\n\\nd = [[None] * 10001 for i in range(n)]\\n\\ndef g(i, s):\\n    if s <= 0: return (0, s)\\n    if i == n: return (1e7, 0)\\n\\n    if not d[i][s]:\\n        x, y = g(i + 1, s - b[i])\\n        d[i][s] = min(g(i + 1, s), (x + 1, y + b[i] - a[i]))\\n    return d[i][s]\\n\\nx, y = g(0, sum(a))\\nprint(x, y)\"]",
        "difficulty": "competition",
        "input": "2\n1 1\n100 1\n",
        "output": "1 1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/730/J"
    },
    {
        "id": 2146,
        "task_id": 3799,
        "test_case_id": 2,
        "question": "There is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n - Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.\nThe player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.\n\n-----Constraints-----\n - 3 ≤ |s| ≤ 10^5\n - s consists of lowercase English letters.\n - No two neighboring characters in s are equal.\n\n-----Input-----\nThe input is given from Standard Input in the following format:\ns\n\n-----Output-----\nIf Takahashi will win, print First. If Aoki will win, print Second.\n\n-----Sample Input-----\naba\n\n-----Sample Output-----\nSecond\n\nTakahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.",
        "solutions": "[\"s=input();print(['Second','First'][len(s.rstrip(s[0]))%2])\", \"S = input()\\nflag = (S[0] != S[-1]) ^ (len(S) % 2 == 0)\\nprint((\\\"First\\\" if flag else \\\"Second\\\"))\\n\", \"s=list(input())\\n\\nn=len(s)\\n\\nif (s[0]==s[n-1] and n%2 ==0) or (s[0] != s[n-1] and n%2 != 0):\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"s=input()\\nprint('Second' if (len(s)%2==0)^(s[0]==s[-1]) else 'First')\", \"s = input()\\nif s[0]==s[-1]:\\n    a = 1\\nelse:\\n    a = 0\\nif (len(s)-a)%2==0:\\n    print('Second')\\nelse:\\n    print('First')\", \"s=input();print('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"S = input()\\nN = len(S)\\n\\nif S[0] == S[-1]:\\n    if N%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if N%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s = input()\\nif (len(s)%2 + int(s[0]==s[-1]))%2:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"S = input()\\nans = \\\"First\\\"\\nif (S[0] == S[-1]) ^ (len(S) % 2 == 0):\\n    ans = \\\"Second\\\"\\nprint(ans)\\n\", \"s=input()\\n\\nif s[0]==s[len(s)-1]:\\n    if len(s)%2==1:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if len(s)%2==1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"import sys\\n# input = sys.stdin.readline\\ns = str(input())\\nn = len(s)\\nif s[0] == s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move == 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nread = sys.stdin.read\\nreadline = sys.stdin.readline\\n\\n#xs,ys,xt,yt = map(int,readline().split())\\n\\ns = input()\\n\\nif ((s[0]==s[-1]) + len(s))&1:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\\n\\n\", \"S = input()\\nprint((\\\"First\\\" if (len(S) % 2) ^ (S[0] == S[-1]) else \\\"Second\\\"))\\n\", \"#!/usr/bin/env python\\n# -*- coding:utf-8 -*-\\n\\ns = input()\\nif (len(s) % 2 == 0) and (s[0] == s[-1]):\\n    print(\\\"First\\\")\\nelif (len(s) % 2 == 0) or (s[0] == s[-1]):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\n\\nif (len(s) % 2 != 0)^(s[0] == s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"s = input()\\nprint(['Second', 'First'][(s[0]==s[-1])^(len(s)%2)])\", \"# -*- coding: utf-8 -*-\\ns = input()\\nn = len(s)\\n\\nif n%2==0 and s[0]!=s[n-1]:\\n    print(\\\"Second\\\")\\nelif n%2==1 and s[0]==s[n-1]:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"def main():\\n    s = input()\\n\\n    if s[0] == s[-1]:\\n        ss = 1\\n    else:\\n        ss = 0\\n\\n    if len(s) % 2 == ss:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import collections\\n\\n\\ndef solve():\\n    s = input()\\n    if s[0] == s[-1]:\\n        if len(s)%2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if len(s)%2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = list(input())\\nl = len(s)\\n\\nif s[0] == s[-1]:\\n    if l % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if l % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"S = input()\\nstart_end = (S[0] == S[-1])\\nodd = (len(S) % 2)\\nprint('First' if (start_end and not odd) or (not start_end and odd) else 'Second')\", \"s = input()\\nprint(\\\"Second\\\" if ((len(s)%2 == 0) ^ (s[0] == s[-1])) else \\\"First\\\")\", \"s=input()\\nrem=3 if s[0]==s[-1] else 2\\nif (len(s)-rem)%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\nplayers = ['First', 'Second']\\n\\nlast = 1 if s[0] == s[-1] else 0\\ncnt = (len(s) - 2 + 1 + last) % 2\\nans = players[cnt]\\n\\nprint(ans)\", \"import sys\\n\\ns = str(sys.stdin.readline().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\nprint('First' if (len(S)%2==0) == (S[0]==S[-1]) else 'Second')\", \"s = input()\\nn = len(s)\\nif s[0] == s[-1]:\\n  n += 1\\n  \\nprint(\\\"First\\\" if n % 2 else \\\"Second\\\")\", \"s=input()\\nprint('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"n=input()\\nif len(n)%2==0:\\n    if n[0]!=n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if n[0]==n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"S = list(input())\\nN = len(S)\\nA = N%2\\nB = (S[0]==S[-1])*1\\nif A==1 and B==1:\\n    print(\\\"Second\\\")\\nelif A==1 and B==0:\\n    print(\\\"First\\\")\\nelif A==0 and B==1:\\n    print(\\\"First\\\")\\nelif A==0 and B==0:\\n    print(\\\"Second\\\")\\n\", \"s = input().strip()\\nl = len(s)\\n \\nif (l + (s[0] == s[-1])) % 2:\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"import sys\\nS=input()\\nN=len(S)\\nif N%2!=0:\\n    if S[0]==S[N-1]:\\n        print('Second')\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if S[0]==S[N-1]:\\n        print('First')\\n    else:\\n        print('Second')\", \"s = input()\\n\\nif (len(s)%2==1 and s[-1]!=s[0]) or (len(s)%2==0 and s[-1]==s[0]):\\n    print('First')\\nelse:\\n    print('Second')\", \"def remove(s):\\n    i=1\\n    count=0\\n    while i<len(s)-1:\\n        if s[i-1]!=s[i+1]:\\n            s.pop(i)\\n            count+=1\\n        i+=1\\n    return count\\n\\ns=list(input())\\ncount=0\\nwhile True:\\n    tmp=remove(s)\\n    if tmp==0:\\n        break\\n    count+=tmp\\n\\nif count%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"S = input().strip()\\n\\nif S[0] == S[-1]:\\n  print(\\\"First\\\" if len(S) % 2 == 0 else \\\"Second\\\")\\nelse:\\n  print(\\\"Second\\\" if len(S) % 2 == 0 else \\\"First\\\")\", \"s = input()\\nl = len(s)\\n\\nif (s[0] == s[-1] and l % 2 == 0) or (s[0] != s[-1] and l % 2 != 0):\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"s=input();print(['Second','First'][(len(s)+(s[0]==s[-1]))%2])\", \"s = input()\\nn = len(s)\\n\\nmove = 0\\nif s[0] == s[-1]:\\n    move = 1\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\na = s[0]\\nb = s[len(s)-1]\\nn = len(s) % 2\\nif n == 1 and a == b:\\n    print('Second')\\nelif n == 1 and a != b:\\n    print('First')\\nelif n == 0 and a == b:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def __starting_point():\\n    S = input()\\n    N = len(S)\\n    if S[0] == S[-1]:\\n        if N % 2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if N % 2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\n__starting_point()\", \"S=input()\\nN=len(S)\\nif N%2==0:\\n    if S[0]==S[-1]:\\n        print('First')\\n    else:\\n        print('Second')\\nelse:\\n    if S[0]==S[-1]:\\n        print('Second')\\n    else:\\n        print('First')\", \"S = input()\\nif (S[0] == S[-1]) ^ (len(S) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def ARC064D():\\n    s = list(input())\\n    if s[0] == s[-1]:\\n        key = 1\\n    else:\\n        key = -1\\n\\n    if len(s) % 2 != 0:\\n        key *= -1\\n\\n    if key == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\\nARC064D()\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"s = input()\\nprint([\\\"Second\\\",\\\"First\\\"][(len(s) + (s[0] == s[-1])) % 2])\", \"S=input()\\nstart=len(S)%2\\nif S[0]==S[-1]:\\n    goal=1\\nelse:\\n    goal=0\\ncan=(start+goal)%2\\nif can==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"ss = input()\\n\\nif (ss[0] == ss[-1] and len(ss) % 2 == 0) or (ss[0] != ss[-1] and len(ss) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s=input()\\nif(s[0]==s[len(s)-1]):\\n    a=len(s)-3\\nelse:\\n    a=len(s)-2\\nif(a%2==0):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"s=(input())\\nl=len(s)\\ne=(s[0]==s[-1])\\nprint((\\\"First\\\" if (e+l)%2 else \\\"Second\\\"))\\n\", \"s=input();x=(len(s)+(s[0]==s[-1]))%2;print('First'*x+'Second'*(1-x))\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nS = list(s)\\nf = False\\nk = 1\\nflag = False\\nwhile len(S) > 2:\\n    if k == len(S) - 1:\\n        if flag:\\n            k = 1\\n            flag = False\\n            continue\\n        break\\n    if S[k - 1] != S[k + 1]:\\n        S.pop(k)\\n        f = not f\\n        flag = True\\n    else:\\n        k += 1\\nif f:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s)%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s)%2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"S=input()\\nif len(S)%2 == 0:\\n  print(('First' if S[0]==S[-1] else 'Second'))\\nelse:\\n  print(('First' if S[0]!=S[-1] else 'Second'))\\n\", \"# -*- coding: utf-8 -*-\\ns = input()\\nlr_same = (s[0] == s[-1])\\nodd = len(s)%2\\n\\nif lr_same ^ odd:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ns = str(input().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\n\\ns = sys.stdin.readline().strip()\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif (len(s)%2==0)^(s[0]==s[-1]):\\n  print('Second')\\nelse:\\n  print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"\\nimport sys\\ndef input():\\n\\treturn sys.stdin.readline().strip()\\n\\ns = input()\\n\\nif s[0] == s[-1]:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"First\\\")\\n\\telse:\\n\\t\\tprint(\\\"Second\\\")\\nelse:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"Second\\\")\\n\\telse:\\n\\t\\tprint(\\\"First\\\")\", \"import sys\\nstdin = sys.stdin\\n\\nsys.setrecursionlimit(10**5) \\n \\ndef li(): return list(map(int, stdin.readline().split()))\\ndef li_(): return [int(x)-1 for x in stdin.readline().split()]\\ndef lf(): return list(map(float, stdin.readline().split()))\\ndef ls(): return stdin.readline().split()\\ndef ns(): return stdin.readline().rstrip()\\ndef lc(): return list(ns())\\ndef ni(): return int(stdin.readline())\\ndef nf(): return float(stdin.readline())\\n\\ns = lc()\\n\\nleft = s[0]\\nright = s[-1]\\n\\n# aba\\u578b\\u306e\\u3068\\u304d\\nif s[0] == s[-1]:\\n    if len(s)%2:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n# ab\\u578b\\u306e\\u3068\\u304d    \\nelse:\\n    if len(s)%2:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"ar = list(input())\\nb = 0\\nwhile True:\\n    count = 0\\n    for i in range(1,len(ar)-1):\\n        if ar[i-1] != ar[i+1]:\\n            count +=1\\n            del ar[i]\\n            b += 1\\n            break\\n    if count == 0:\\n        if b % 2 == 1:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n        break\", \"s=input()\\nx,y=s[0],s[-1]\\nl=len(s)\\nif l%2==0:\\n  if x==y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n  \\nif l%2==1:\\n  if x!=y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\", \"S = input()\\nif S[0] == S[-1]:\\n  if len(S)%2 == 0:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\nelse:\\n  if len(S)%2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"S=input().rstrip()\\nprint((\\\"First\\\" if (len(S)+(S[0]==S[-1]))%2 else \\\"Second\\\"))\\n\", \"s = input()\\nif (len(s)+(s[0]==s[-1]))%2==1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\n\\nif S[0] == S[-1]:\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"S=input();A=len(S)%2;B=0 if S[0]==S[-1] else 1;print(\\\"Second\\\" if A^B else \\\"First\\\")\", \"S = input()\\nl = len(S)\\nprint(('First' if (l & 1) ^ (S[0] == S[-1]) else 'Second'))\\n\", \"s=input()\\nif s[0] == s[-1]:\\n    print(('First','Second')[len(s)%2])\\nelse:\\n    print(('Second','First')[len(s)%2])\", \"s=input()\\nif (len(s)%2==0 and s[0]==s[-1]) or (len(s)%2!=0 and s[0]!=s[-1]):\\n\\tprint(\\\"First\\\")\\nelse:\\n\\tprint(\\\"Second\\\")\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input().strip()\\nc1, c2 = s[0], s[-1]\\nif c1 == c2:\\n    if len(s) % 2:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(s) % 2:\\n        print('First')\\n    else:\\n        print('Second')\\n\", \"s=input();l = len;p = print\\nif (s[0]==s[-1] and l(s)%2==0) or (s[0]!=s[-1] and l(s)%2==1):\\n    p(\\\"First\\\")\\nelse:\\n    p(\\\"Second\\\")\\n\", \"import sys\\n\\nsys.setrecursionlimit(10 ** 8)\\nini = lambda: int(sys.stdin.readline())\\ninm = lambda: list(map(int, sys.stdin.readline().split()))\\ninl = lambda: list(inm())\\nins = lambda: sys.stdin.readline().rstrip()\\n# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)\\n\\ns = ins()\\n\\n\\ndef solve():\\n    lreq = s[0] == s[-1]\\n    odd = len(s) % 2 == 1\\n    return odd ^ lreq\\n\\n\\nprint((\\\"First\\\" if solve() else \\\"Second\\\"))\\n\", \"s=input()\\nif len(s)%2==0 and s[0]==s[-1]:\\n  print('First')\\nelif len(s)%2==1 and s[0]!=s[-1]:\\n  print('First')\\nelse:\\n  print('Second')\", \"from operator import xor\\nS = input()\\na = (len(S)+1) % 2\\nb = int(S[0] == S[-1])\\nans = \\\"Second\\\" if xor(a,b) else \\\"First\\\"\\nprint(ans)\", \"s = input()\\nif ((len(s)%2)+(s[0]==s[-1]))%2:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1]:\\n  if len(s) % 2 == 1:\\n    print(\\\"Second\\\")\\n  else:\\n    print(\\\"First\\\")\\nelse:\\n  if len(s) % 2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"s=list(input())\\nn=len(s)\\nflag=1\\nif n%2==0:\\n  flag=0\\nelse:\\n  for i in range(n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\n  for i in range(1,n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\nif s[0]==s[n-1]:\\n  flag^=1\\nprint('First' if flag==1 else 'Second')\", \"s = input()\\ncount = 0\\nplayer = ['First', 'Second']\\n\\nans = 0\\nwhile ans == 0:\\n    if len(s) == 2:\\n        ans = player[(count+1)%2]\\n    else:\\n        for i in range(1, len(s)-1):\\n            if s[i-1]!=s[i+1]:\\n                s = s[:i]+s[i+1:]\\n                break\\n        else:\\n            ans = player[(count+1)%2]\\n    count += 1\\nprint(ans)#winner\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2:\\n        ans = 'Second'\\n    else:\\n        ans = 'First'\\nelse:\\n    if len(s) % 2:\\n        ans = 'First'\\n    else:\\n        ans = 'Second'\\nprint(ans)\", \"S = input()\\nif len(S)%2 == 0 and S[0] == S[len(S)-1]:\\n  print(\\\"First\\\")\\nelif len(S)%2 == 0 and S[0] != S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelif len(S)%2 != 0 and S[0] == S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelse:\\n  print(\\\"First\\\")\", \"s = input()\\nt = (\\\"First\\\",\\\"Second\\\")\\nprint(t[(len(s)%2==0)^(s[0]==s[-1])])\", \"S = input()\\n\\nif S[0] == S[-1]:  # \\u5947\\u6570\\u624b\\u306e\\u8ca0\\u3051\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\\n\", \"s=input()\\nif (len(s)%2==0)^(s[0]!=s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n - 1]:\\n    if n % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if n % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s=input()\\n\\ndef solve(s):\\n\\tif s[0]==s[-1]:\\n\\t\\tA=1 \\n\\telse:\\n\\t\\tA=0\\n\\tif len(s)%2==0:\\n\\t\\tB=1\\n\\telse:\\n\\t\\tB=0\\n\\tif A+B==1:\\n\\t\\treturn(\\\"Second\\\")\\n\\telse:\\n\\t\\treturn(\\\"First\\\")\\n\\nprint(solve(s))\", \"s = input()\\nans = len(s) & 1\\nif (s[0] == s[-1]) ^ ans:\\n    print('First')\\nelse:\\n    print('Second')\\n\\n\", \"#D\\u554f\\u984c\\nS = list(str(input()))\\nSlen = len(S)\\n\\nfro = S[0]\\nbac = S[-1]\\n\\nif fro == bac:\\n    if Slen%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if Slen%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"s=input();print(\\\"SFeicrosntd\\\"[len(s)%2^(s[0]==s[-1])::2])\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1] and len(s) % 2 == 0:\\n    print('First')\\nelif s[0] != s[-1] and len(s) %2 == 1:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[len(s) - 1]:\\n    # a bab a\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    # a baba b\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"s = input()\\nprint(\\\"First\\\" if (s[0] == s[-1]) == (len(s) % 2 == 0) else \\\"Second\\\")\"]",
        "difficulty": "competition",
        "input": "abc\n",
        "output": "First\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://atcoder.jp/contests/arc064/tasks/arc064_b"
    },
    {
        "id": 2147,
        "task_id": 3799,
        "test_case_id": 3,
        "question": "There is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n - Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.\nThe player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.\n\n-----Constraints-----\n - 3 ≤ |s| ≤ 10^5\n - s consists of lowercase English letters.\n - No two neighboring characters in s are equal.\n\n-----Input-----\nThe input is given from Standard Input in the following format:\ns\n\n-----Output-----\nIf Takahashi will win, print First. If Aoki will win, print Second.\n\n-----Sample Input-----\naba\n\n-----Sample Output-----\nSecond\n\nTakahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.",
        "solutions": "[\"s=input();print(['Second','First'][len(s.rstrip(s[0]))%2])\", \"S = input()\\nflag = (S[0] != S[-1]) ^ (len(S) % 2 == 0)\\nprint((\\\"First\\\" if flag else \\\"Second\\\"))\\n\", \"s=list(input())\\n\\nn=len(s)\\n\\nif (s[0]==s[n-1] and n%2 ==0) or (s[0] != s[n-1] and n%2 != 0):\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"s=input()\\nprint('Second' if (len(s)%2==0)^(s[0]==s[-1]) else 'First')\", \"s = input()\\nif s[0]==s[-1]:\\n    a = 1\\nelse:\\n    a = 0\\nif (len(s)-a)%2==0:\\n    print('Second')\\nelse:\\n    print('First')\", \"s=input();print('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"S = input()\\nN = len(S)\\n\\nif S[0] == S[-1]:\\n    if N%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if N%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s = input()\\nif (len(s)%2 + int(s[0]==s[-1]))%2:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"S = input()\\nans = \\\"First\\\"\\nif (S[0] == S[-1]) ^ (len(S) % 2 == 0):\\n    ans = \\\"Second\\\"\\nprint(ans)\\n\", \"s=input()\\n\\nif s[0]==s[len(s)-1]:\\n    if len(s)%2==1:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if len(s)%2==1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"import sys\\n# input = sys.stdin.readline\\ns = str(input())\\nn = len(s)\\nif s[0] == s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move == 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nread = sys.stdin.read\\nreadline = sys.stdin.readline\\n\\n#xs,ys,xt,yt = map(int,readline().split())\\n\\ns = input()\\n\\nif ((s[0]==s[-1]) + len(s))&1:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\\n\\n\", \"S = input()\\nprint((\\\"First\\\" if (len(S) % 2) ^ (S[0] == S[-1]) else \\\"Second\\\"))\\n\", \"#!/usr/bin/env python\\n# -*- coding:utf-8 -*-\\n\\ns = input()\\nif (len(s) % 2 == 0) and (s[0] == s[-1]):\\n    print(\\\"First\\\")\\nelif (len(s) % 2 == 0) or (s[0] == s[-1]):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\n\\nif (len(s) % 2 != 0)^(s[0] == s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"s = input()\\nprint(['Second', 'First'][(s[0]==s[-1])^(len(s)%2)])\", \"# -*- coding: utf-8 -*-\\ns = input()\\nn = len(s)\\n\\nif n%2==0 and s[0]!=s[n-1]:\\n    print(\\\"Second\\\")\\nelif n%2==1 and s[0]==s[n-1]:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"def main():\\n    s = input()\\n\\n    if s[0] == s[-1]:\\n        ss = 1\\n    else:\\n        ss = 0\\n\\n    if len(s) % 2 == ss:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import collections\\n\\n\\ndef solve():\\n    s = input()\\n    if s[0] == s[-1]:\\n        if len(s)%2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if len(s)%2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = list(input())\\nl = len(s)\\n\\nif s[0] == s[-1]:\\n    if l % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if l % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"S = input()\\nstart_end = (S[0] == S[-1])\\nodd = (len(S) % 2)\\nprint('First' if (start_end and not odd) or (not start_end and odd) else 'Second')\", \"s = input()\\nprint(\\\"Second\\\" if ((len(s)%2 == 0) ^ (s[0] == s[-1])) else \\\"First\\\")\", \"s=input()\\nrem=3 if s[0]==s[-1] else 2\\nif (len(s)-rem)%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\nplayers = ['First', 'Second']\\n\\nlast = 1 if s[0] == s[-1] else 0\\ncnt = (len(s) - 2 + 1 + last) % 2\\nans = players[cnt]\\n\\nprint(ans)\", \"import sys\\n\\ns = str(sys.stdin.readline().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\nprint('First' if (len(S)%2==0) == (S[0]==S[-1]) else 'Second')\", \"s = input()\\nn = len(s)\\nif s[0] == s[-1]:\\n  n += 1\\n  \\nprint(\\\"First\\\" if n % 2 else \\\"Second\\\")\", \"s=input()\\nprint('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"n=input()\\nif len(n)%2==0:\\n    if n[0]!=n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if n[0]==n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"S = list(input())\\nN = len(S)\\nA = N%2\\nB = (S[0]==S[-1])*1\\nif A==1 and B==1:\\n    print(\\\"Second\\\")\\nelif A==1 and B==0:\\n    print(\\\"First\\\")\\nelif A==0 and B==1:\\n    print(\\\"First\\\")\\nelif A==0 and B==0:\\n    print(\\\"Second\\\")\\n\", \"s = input().strip()\\nl = len(s)\\n \\nif (l + (s[0] == s[-1])) % 2:\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"import sys\\nS=input()\\nN=len(S)\\nif N%2!=0:\\n    if S[0]==S[N-1]:\\n        print('Second')\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if S[0]==S[N-1]:\\n        print('First')\\n    else:\\n        print('Second')\", \"s = input()\\n\\nif (len(s)%2==1 and s[-1]!=s[0]) or (len(s)%2==0 and s[-1]==s[0]):\\n    print('First')\\nelse:\\n    print('Second')\", \"def remove(s):\\n    i=1\\n    count=0\\n    while i<len(s)-1:\\n        if s[i-1]!=s[i+1]:\\n            s.pop(i)\\n            count+=1\\n        i+=1\\n    return count\\n\\ns=list(input())\\ncount=0\\nwhile True:\\n    tmp=remove(s)\\n    if tmp==0:\\n        break\\n    count+=tmp\\n\\nif count%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"S = input().strip()\\n\\nif S[0] == S[-1]:\\n  print(\\\"First\\\" if len(S) % 2 == 0 else \\\"Second\\\")\\nelse:\\n  print(\\\"Second\\\" if len(S) % 2 == 0 else \\\"First\\\")\", \"s = input()\\nl = len(s)\\n\\nif (s[0] == s[-1] and l % 2 == 0) or (s[0] != s[-1] and l % 2 != 0):\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"s=input();print(['Second','First'][(len(s)+(s[0]==s[-1]))%2])\", \"s = input()\\nn = len(s)\\n\\nmove = 0\\nif s[0] == s[-1]:\\n    move = 1\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\na = s[0]\\nb = s[len(s)-1]\\nn = len(s) % 2\\nif n == 1 and a == b:\\n    print('Second')\\nelif n == 1 and a != b:\\n    print('First')\\nelif n == 0 and a == b:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def __starting_point():\\n    S = input()\\n    N = len(S)\\n    if S[0] == S[-1]:\\n        if N % 2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if N % 2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\n__starting_point()\", \"S=input()\\nN=len(S)\\nif N%2==0:\\n    if S[0]==S[-1]:\\n        print('First')\\n    else:\\n        print('Second')\\nelse:\\n    if S[0]==S[-1]:\\n        print('Second')\\n    else:\\n        print('First')\", \"S = input()\\nif (S[0] == S[-1]) ^ (len(S) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def ARC064D():\\n    s = list(input())\\n    if s[0] == s[-1]:\\n        key = 1\\n    else:\\n        key = -1\\n\\n    if len(s) % 2 != 0:\\n        key *= -1\\n\\n    if key == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\\nARC064D()\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"s = input()\\nprint([\\\"Second\\\",\\\"First\\\"][(len(s) + (s[0] == s[-1])) % 2])\", \"S=input()\\nstart=len(S)%2\\nif S[0]==S[-1]:\\n    goal=1\\nelse:\\n    goal=0\\ncan=(start+goal)%2\\nif can==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"ss = input()\\n\\nif (ss[0] == ss[-1] and len(ss) % 2 == 0) or (ss[0] != ss[-1] and len(ss) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s=input()\\nif(s[0]==s[len(s)-1]):\\n    a=len(s)-3\\nelse:\\n    a=len(s)-2\\nif(a%2==0):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"s=(input())\\nl=len(s)\\ne=(s[0]==s[-1])\\nprint((\\\"First\\\" if (e+l)%2 else \\\"Second\\\"))\\n\", \"s=input();x=(len(s)+(s[0]==s[-1]))%2;print('First'*x+'Second'*(1-x))\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nS = list(s)\\nf = False\\nk = 1\\nflag = False\\nwhile len(S) > 2:\\n    if k == len(S) - 1:\\n        if flag:\\n            k = 1\\n            flag = False\\n            continue\\n        break\\n    if S[k - 1] != S[k + 1]:\\n        S.pop(k)\\n        f = not f\\n        flag = True\\n    else:\\n        k += 1\\nif f:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s)%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s)%2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"S=input()\\nif len(S)%2 == 0:\\n  print(('First' if S[0]==S[-1] else 'Second'))\\nelse:\\n  print(('First' if S[0]!=S[-1] else 'Second'))\\n\", \"# -*- coding: utf-8 -*-\\ns = input()\\nlr_same = (s[0] == s[-1])\\nodd = len(s)%2\\n\\nif lr_same ^ odd:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ns = str(input().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\n\\ns = sys.stdin.readline().strip()\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif (len(s)%2==0)^(s[0]==s[-1]):\\n  print('Second')\\nelse:\\n  print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"\\nimport sys\\ndef input():\\n\\treturn sys.stdin.readline().strip()\\n\\ns = input()\\n\\nif s[0] == s[-1]:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"First\\\")\\n\\telse:\\n\\t\\tprint(\\\"Second\\\")\\nelse:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"Second\\\")\\n\\telse:\\n\\t\\tprint(\\\"First\\\")\", \"import sys\\nstdin = sys.stdin\\n\\nsys.setrecursionlimit(10**5) \\n \\ndef li(): return list(map(int, stdin.readline().split()))\\ndef li_(): return [int(x)-1 for x in stdin.readline().split()]\\ndef lf(): return list(map(float, stdin.readline().split()))\\ndef ls(): return stdin.readline().split()\\ndef ns(): return stdin.readline().rstrip()\\ndef lc(): return list(ns())\\ndef ni(): return int(stdin.readline())\\ndef nf(): return float(stdin.readline())\\n\\ns = lc()\\n\\nleft = s[0]\\nright = s[-1]\\n\\n# aba\\u578b\\u306e\\u3068\\u304d\\nif s[0] == s[-1]:\\n    if len(s)%2:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n# ab\\u578b\\u306e\\u3068\\u304d    \\nelse:\\n    if len(s)%2:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"ar = list(input())\\nb = 0\\nwhile True:\\n    count = 0\\n    for i in range(1,len(ar)-1):\\n        if ar[i-1] != ar[i+1]:\\n            count +=1\\n            del ar[i]\\n            b += 1\\n            break\\n    if count == 0:\\n        if b % 2 == 1:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n        break\", \"s=input()\\nx,y=s[0],s[-1]\\nl=len(s)\\nif l%2==0:\\n  if x==y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n  \\nif l%2==1:\\n  if x!=y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\", \"S = input()\\nif S[0] == S[-1]:\\n  if len(S)%2 == 0:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\nelse:\\n  if len(S)%2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"S=input().rstrip()\\nprint((\\\"First\\\" if (len(S)+(S[0]==S[-1]))%2 else \\\"Second\\\"))\\n\", \"s = input()\\nif (len(s)+(s[0]==s[-1]))%2==1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\n\\nif S[0] == S[-1]:\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"S=input();A=len(S)%2;B=0 if S[0]==S[-1] else 1;print(\\\"Second\\\" if A^B else \\\"First\\\")\", \"S = input()\\nl = len(S)\\nprint(('First' if (l & 1) ^ (S[0] == S[-1]) else 'Second'))\\n\", \"s=input()\\nif s[0] == s[-1]:\\n    print(('First','Second')[len(s)%2])\\nelse:\\n    print(('Second','First')[len(s)%2])\", \"s=input()\\nif (len(s)%2==0 and s[0]==s[-1]) or (len(s)%2!=0 and s[0]!=s[-1]):\\n\\tprint(\\\"First\\\")\\nelse:\\n\\tprint(\\\"Second\\\")\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input().strip()\\nc1, c2 = s[0], s[-1]\\nif c1 == c2:\\n    if len(s) % 2:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(s) % 2:\\n        print('First')\\n    else:\\n        print('Second')\\n\", \"s=input();l = len;p = print\\nif (s[0]==s[-1] and l(s)%2==0) or (s[0]!=s[-1] and l(s)%2==1):\\n    p(\\\"First\\\")\\nelse:\\n    p(\\\"Second\\\")\\n\", \"import sys\\n\\nsys.setrecursionlimit(10 ** 8)\\nini = lambda: int(sys.stdin.readline())\\ninm = lambda: list(map(int, sys.stdin.readline().split()))\\ninl = lambda: list(inm())\\nins = lambda: sys.stdin.readline().rstrip()\\n# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)\\n\\ns = ins()\\n\\n\\ndef solve():\\n    lreq = s[0] == s[-1]\\n    odd = len(s) % 2 == 1\\n    return odd ^ lreq\\n\\n\\nprint((\\\"First\\\" if solve() else \\\"Second\\\"))\\n\", \"s=input()\\nif len(s)%2==0 and s[0]==s[-1]:\\n  print('First')\\nelif len(s)%2==1 and s[0]!=s[-1]:\\n  print('First')\\nelse:\\n  print('Second')\", \"from operator import xor\\nS = input()\\na = (len(S)+1) % 2\\nb = int(S[0] == S[-1])\\nans = \\\"Second\\\" if xor(a,b) else \\\"First\\\"\\nprint(ans)\", \"s = input()\\nif ((len(s)%2)+(s[0]==s[-1]))%2:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1]:\\n  if len(s) % 2 == 1:\\n    print(\\\"Second\\\")\\n  else:\\n    print(\\\"First\\\")\\nelse:\\n  if len(s) % 2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"s=list(input())\\nn=len(s)\\nflag=1\\nif n%2==0:\\n  flag=0\\nelse:\\n  for i in range(n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\n  for i in range(1,n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\nif s[0]==s[n-1]:\\n  flag^=1\\nprint('First' if flag==1 else 'Second')\", \"s = input()\\ncount = 0\\nplayer = ['First', 'Second']\\n\\nans = 0\\nwhile ans == 0:\\n    if len(s) == 2:\\n        ans = player[(count+1)%2]\\n    else:\\n        for i in range(1, len(s)-1):\\n            if s[i-1]!=s[i+1]:\\n                s = s[:i]+s[i+1:]\\n                break\\n        else:\\n            ans = player[(count+1)%2]\\n    count += 1\\nprint(ans)#winner\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2:\\n        ans = 'Second'\\n    else:\\n        ans = 'First'\\nelse:\\n    if len(s) % 2:\\n        ans = 'First'\\n    else:\\n        ans = 'Second'\\nprint(ans)\", \"S = input()\\nif len(S)%2 == 0 and S[0] == S[len(S)-1]:\\n  print(\\\"First\\\")\\nelif len(S)%2 == 0 and S[0] != S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelif len(S)%2 != 0 and S[0] == S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelse:\\n  print(\\\"First\\\")\", \"s = input()\\nt = (\\\"First\\\",\\\"Second\\\")\\nprint(t[(len(s)%2==0)^(s[0]==s[-1])])\", \"S = input()\\n\\nif S[0] == S[-1]:  # \\u5947\\u6570\\u624b\\u306e\\u8ca0\\u3051\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\\n\", \"s=input()\\nif (len(s)%2==0)^(s[0]!=s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n - 1]:\\n    if n % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if n % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s=input()\\n\\ndef solve(s):\\n\\tif s[0]==s[-1]:\\n\\t\\tA=1 \\n\\telse:\\n\\t\\tA=0\\n\\tif len(s)%2==0:\\n\\t\\tB=1\\n\\telse:\\n\\t\\tB=0\\n\\tif A+B==1:\\n\\t\\treturn(\\\"Second\\\")\\n\\telse:\\n\\t\\treturn(\\\"First\\\")\\n\\nprint(solve(s))\", \"s = input()\\nans = len(s) & 1\\nif (s[0] == s[-1]) ^ ans:\\n    print('First')\\nelse:\\n    print('Second')\\n\\n\", \"#D\\u554f\\u984c\\nS = list(str(input()))\\nSlen = len(S)\\n\\nfro = S[0]\\nbac = S[-1]\\n\\nif fro == bac:\\n    if Slen%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if Slen%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"s=input();print(\\\"SFeicrosntd\\\"[len(s)%2^(s[0]==s[-1])::2])\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1] and len(s) % 2 == 0:\\n    print('First')\\nelif s[0] != s[-1] and len(s) %2 == 1:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[len(s) - 1]:\\n    # a bab a\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    # a baba b\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"s = input()\\nprint(\\\"First\\\" if (s[0] == s[-1]) == (len(s) % 2 == 0) else \\\"Second\\\")\"]",
        "difficulty": "competition",
        "input": "abcab\n",
        "output": "First\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://atcoder.jp/contests/arc064/tasks/arc064_b"
    },
    {
        "id": 2148,
        "task_id": 3799,
        "test_case_id": 4,
        "question": "There is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n - Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.\nThe player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.\n\n-----Constraints-----\n - 3 ≤ |s| ≤ 10^5\n - s consists of lowercase English letters.\n - No two neighboring characters in s are equal.\n\n-----Input-----\nThe input is given from Standard Input in the following format:\ns\n\n-----Output-----\nIf Takahashi will win, print First. If Aoki will win, print Second.\n\n-----Sample Input-----\naba\n\n-----Sample Output-----\nSecond\n\nTakahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.",
        "solutions": "[\"s=input();print(['Second','First'][len(s.rstrip(s[0]))%2])\", \"S = input()\\nflag = (S[0] != S[-1]) ^ (len(S) % 2 == 0)\\nprint((\\\"First\\\" if flag else \\\"Second\\\"))\\n\", \"s=list(input())\\n\\nn=len(s)\\n\\nif (s[0]==s[n-1] and n%2 ==0) or (s[0] != s[n-1] and n%2 != 0):\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"s=input()\\nprint('Second' if (len(s)%2==0)^(s[0]==s[-1]) else 'First')\", \"s = input()\\nif s[0]==s[-1]:\\n    a = 1\\nelse:\\n    a = 0\\nif (len(s)-a)%2==0:\\n    print('Second')\\nelse:\\n    print('First')\", \"s=input();print('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"S = input()\\nN = len(S)\\n\\nif S[0] == S[-1]:\\n    if N%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if N%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s = input()\\nif (len(s)%2 + int(s[0]==s[-1]))%2:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"S = input()\\nans = \\\"First\\\"\\nif (S[0] == S[-1]) ^ (len(S) % 2 == 0):\\n    ans = \\\"Second\\\"\\nprint(ans)\\n\", \"s=input()\\n\\nif s[0]==s[len(s)-1]:\\n    if len(s)%2==1:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if len(s)%2==1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"import sys\\n# input = sys.stdin.readline\\ns = str(input())\\nn = len(s)\\nif s[0] == s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move == 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nread = sys.stdin.read\\nreadline = sys.stdin.readline\\n\\n#xs,ys,xt,yt = map(int,readline().split())\\n\\ns = input()\\n\\nif ((s[0]==s[-1]) + len(s))&1:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\\n\\n\", \"S = input()\\nprint((\\\"First\\\" if (len(S) % 2) ^ (S[0] == S[-1]) else \\\"Second\\\"))\\n\", \"#!/usr/bin/env python\\n# -*- coding:utf-8 -*-\\n\\ns = input()\\nif (len(s) % 2 == 0) and (s[0] == s[-1]):\\n    print(\\\"First\\\")\\nelif (len(s) % 2 == 0) or (s[0] == s[-1]):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\n\\nif (len(s) % 2 != 0)^(s[0] == s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"s = input()\\nprint(['Second', 'First'][(s[0]==s[-1])^(len(s)%2)])\", \"# -*- coding: utf-8 -*-\\ns = input()\\nn = len(s)\\n\\nif n%2==0 and s[0]!=s[n-1]:\\n    print(\\\"Second\\\")\\nelif n%2==1 and s[0]==s[n-1]:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"def main():\\n    s = input()\\n\\n    if s[0] == s[-1]:\\n        ss = 1\\n    else:\\n        ss = 0\\n\\n    if len(s) % 2 == ss:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import collections\\n\\n\\ndef solve():\\n    s = input()\\n    if s[0] == s[-1]:\\n        if len(s)%2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if len(s)%2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = list(input())\\nl = len(s)\\n\\nif s[0] == s[-1]:\\n    if l % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if l % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"S = input()\\nstart_end = (S[0] == S[-1])\\nodd = (len(S) % 2)\\nprint('First' if (start_end and not odd) or (not start_end and odd) else 'Second')\", \"s = input()\\nprint(\\\"Second\\\" if ((len(s)%2 == 0) ^ (s[0] == s[-1])) else \\\"First\\\")\", \"s=input()\\nrem=3 if s[0]==s[-1] else 2\\nif (len(s)-rem)%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\nplayers = ['First', 'Second']\\n\\nlast = 1 if s[0] == s[-1] else 0\\ncnt = (len(s) - 2 + 1 + last) % 2\\nans = players[cnt]\\n\\nprint(ans)\", \"import sys\\n\\ns = str(sys.stdin.readline().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\nprint('First' if (len(S)%2==0) == (S[0]==S[-1]) else 'Second')\", \"s = input()\\nn = len(s)\\nif s[0] == s[-1]:\\n  n += 1\\n  \\nprint(\\\"First\\\" if n % 2 else \\\"Second\\\")\", \"s=input()\\nprint('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"n=input()\\nif len(n)%2==0:\\n    if n[0]!=n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if n[0]==n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"S = list(input())\\nN = len(S)\\nA = N%2\\nB = (S[0]==S[-1])*1\\nif A==1 and B==1:\\n    print(\\\"Second\\\")\\nelif A==1 and B==0:\\n    print(\\\"First\\\")\\nelif A==0 and B==1:\\n    print(\\\"First\\\")\\nelif A==0 and B==0:\\n    print(\\\"Second\\\")\\n\", \"s = input().strip()\\nl = len(s)\\n \\nif (l + (s[0] == s[-1])) % 2:\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"import sys\\nS=input()\\nN=len(S)\\nif N%2!=0:\\n    if S[0]==S[N-1]:\\n        print('Second')\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if S[0]==S[N-1]:\\n        print('First')\\n    else:\\n        print('Second')\", \"s = input()\\n\\nif (len(s)%2==1 and s[-1]!=s[0]) or (len(s)%2==0 and s[-1]==s[0]):\\n    print('First')\\nelse:\\n    print('Second')\", \"def remove(s):\\n    i=1\\n    count=0\\n    while i<len(s)-1:\\n        if s[i-1]!=s[i+1]:\\n            s.pop(i)\\n            count+=1\\n        i+=1\\n    return count\\n\\ns=list(input())\\ncount=0\\nwhile True:\\n    tmp=remove(s)\\n    if tmp==0:\\n        break\\n    count+=tmp\\n\\nif count%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"S = input().strip()\\n\\nif S[0] == S[-1]:\\n  print(\\\"First\\\" if len(S) % 2 == 0 else \\\"Second\\\")\\nelse:\\n  print(\\\"Second\\\" if len(S) % 2 == 0 else \\\"First\\\")\", \"s = input()\\nl = len(s)\\n\\nif (s[0] == s[-1] and l % 2 == 0) or (s[0] != s[-1] and l % 2 != 0):\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"s=input();print(['Second','First'][(len(s)+(s[0]==s[-1]))%2])\", \"s = input()\\nn = len(s)\\n\\nmove = 0\\nif s[0] == s[-1]:\\n    move = 1\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\na = s[0]\\nb = s[len(s)-1]\\nn = len(s) % 2\\nif n == 1 and a == b:\\n    print('Second')\\nelif n == 1 and a != b:\\n    print('First')\\nelif n == 0 and a == b:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def __starting_point():\\n    S = input()\\n    N = len(S)\\n    if S[0] == S[-1]:\\n        if N % 2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if N % 2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\n__starting_point()\", \"S=input()\\nN=len(S)\\nif N%2==0:\\n    if S[0]==S[-1]:\\n        print('First')\\n    else:\\n        print('Second')\\nelse:\\n    if S[0]==S[-1]:\\n        print('Second')\\n    else:\\n        print('First')\", \"S = input()\\nif (S[0] == S[-1]) ^ (len(S) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def ARC064D():\\n    s = list(input())\\n    if s[0] == s[-1]:\\n        key = 1\\n    else:\\n        key = -1\\n\\n    if len(s) % 2 != 0:\\n        key *= -1\\n\\n    if key == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\\nARC064D()\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"s = input()\\nprint([\\\"Second\\\",\\\"First\\\"][(len(s) + (s[0] == s[-1])) % 2])\", \"S=input()\\nstart=len(S)%2\\nif S[0]==S[-1]:\\n    goal=1\\nelse:\\n    goal=0\\ncan=(start+goal)%2\\nif can==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"ss = input()\\n\\nif (ss[0] == ss[-1] and len(ss) % 2 == 0) or (ss[0] != ss[-1] and len(ss) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s=input()\\nif(s[0]==s[len(s)-1]):\\n    a=len(s)-3\\nelse:\\n    a=len(s)-2\\nif(a%2==0):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"s=(input())\\nl=len(s)\\ne=(s[0]==s[-1])\\nprint((\\\"First\\\" if (e+l)%2 else \\\"Second\\\"))\\n\", \"s=input();x=(len(s)+(s[0]==s[-1]))%2;print('First'*x+'Second'*(1-x))\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nS = list(s)\\nf = False\\nk = 1\\nflag = False\\nwhile len(S) > 2:\\n    if k == len(S) - 1:\\n        if flag:\\n            k = 1\\n            flag = False\\n            continue\\n        break\\n    if S[k - 1] != S[k + 1]:\\n        S.pop(k)\\n        f = not f\\n        flag = True\\n    else:\\n        k += 1\\nif f:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s)%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s)%2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"S=input()\\nif len(S)%2 == 0:\\n  print(('First' if S[0]==S[-1] else 'Second'))\\nelse:\\n  print(('First' if S[0]!=S[-1] else 'Second'))\\n\", \"# -*- coding: utf-8 -*-\\ns = input()\\nlr_same = (s[0] == s[-1])\\nodd = len(s)%2\\n\\nif lr_same ^ odd:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ns = str(input().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\n\\ns = sys.stdin.readline().strip()\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif (len(s)%2==0)^(s[0]==s[-1]):\\n  print('Second')\\nelse:\\n  print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"\\nimport sys\\ndef input():\\n\\treturn sys.stdin.readline().strip()\\n\\ns = input()\\n\\nif s[0] == s[-1]:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"First\\\")\\n\\telse:\\n\\t\\tprint(\\\"Second\\\")\\nelse:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"Second\\\")\\n\\telse:\\n\\t\\tprint(\\\"First\\\")\", \"import sys\\nstdin = sys.stdin\\n\\nsys.setrecursionlimit(10**5) \\n \\ndef li(): return list(map(int, stdin.readline().split()))\\ndef li_(): return [int(x)-1 for x in stdin.readline().split()]\\ndef lf(): return list(map(float, stdin.readline().split()))\\ndef ls(): return stdin.readline().split()\\ndef ns(): return stdin.readline().rstrip()\\ndef lc(): return list(ns())\\ndef ni(): return int(stdin.readline())\\ndef nf(): return float(stdin.readline())\\n\\ns = lc()\\n\\nleft = s[0]\\nright = s[-1]\\n\\n# aba\\u578b\\u306e\\u3068\\u304d\\nif s[0] == s[-1]:\\n    if len(s)%2:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n# ab\\u578b\\u306e\\u3068\\u304d    \\nelse:\\n    if len(s)%2:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"ar = list(input())\\nb = 0\\nwhile True:\\n    count = 0\\n    for i in range(1,len(ar)-1):\\n        if ar[i-1] != ar[i+1]:\\n            count +=1\\n            del ar[i]\\n            b += 1\\n            break\\n    if count == 0:\\n        if b % 2 == 1:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n        break\", \"s=input()\\nx,y=s[0],s[-1]\\nl=len(s)\\nif l%2==0:\\n  if x==y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n  \\nif l%2==1:\\n  if x!=y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\", \"S = input()\\nif S[0] == S[-1]:\\n  if len(S)%2 == 0:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\nelse:\\n  if len(S)%2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"S=input().rstrip()\\nprint((\\\"First\\\" if (len(S)+(S[0]==S[-1]))%2 else \\\"Second\\\"))\\n\", \"s = input()\\nif (len(s)+(s[0]==s[-1]))%2==1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\n\\nif S[0] == S[-1]:\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"S=input();A=len(S)%2;B=0 if S[0]==S[-1] else 1;print(\\\"Second\\\" if A^B else \\\"First\\\")\", \"S = input()\\nl = len(S)\\nprint(('First' if (l & 1) ^ (S[0] == S[-1]) else 'Second'))\\n\", \"s=input()\\nif s[0] == s[-1]:\\n    print(('First','Second')[len(s)%2])\\nelse:\\n    print(('Second','First')[len(s)%2])\", \"s=input()\\nif (len(s)%2==0 and s[0]==s[-1]) or (len(s)%2!=0 and s[0]!=s[-1]):\\n\\tprint(\\\"First\\\")\\nelse:\\n\\tprint(\\\"Second\\\")\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input().strip()\\nc1, c2 = s[0], s[-1]\\nif c1 == c2:\\n    if len(s) % 2:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(s) % 2:\\n        print('First')\\n    else:\\n        print('Second')\\n\", \"s=input();l = len;p = print\\nif (s[0]==s[-1] and l(s)%2==0) or (s[0]!=s[-1] and l(s)%2==1):\\n    p(\\\"First\\\")\\nelse:\\n    p(\\\"Second\\\")\\n\", \"import sys\\n\\nsys.setrecursionlimit(10 ** 8)\\nini = lambda: int(sys.stdin.readline())\\ninm = lambda: list(map(int, sys.stdin.readline().split()))\\ninl = lambda: list(inm())\\nins = lambda: sys.stdin.readline().rstrip()\\n# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)\\n\\ns = ins()\\n\\n\\ndef solve():\\n    lreq = s[0] == s[-1]\\n    odd = len(s) % 2 == 1\\n    return odd ^ lreq\\n\\n\\nprint((\\\"First\\\" if solve() else \\\"Second\\\"))\\n\", \"s=input()\\nif len(s)%2==0 and s[0]==s[-1]:\\n  print('First')\\nelif len(s)%2==1 and s[0]!=s[-1]:\\n  print('First')\\nelse:\\n  print('Second')\", \"from operator import xor\\nS = input()\\na = (len(S)+1) % 2\\nb = int(S[0] == S[-1])\\nans = \\\"Second\\\" if xor(a,b) else \\\"First\\\"\\nprint(ans)\", \"s = input()\\nif ((len(s)%2)+(s[0]==s[-1]))%2:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1]:\\n  if len(s) % 2 == 1:\\n    print(\\\"Second\\\")\\n  else:\\n    print(\\\"First\\\")\\nelse:\\n  if len(s) % 2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"s=list(input())\\nn=len(s)\\nflag=1\\nif n%2==0:\\n  flag=0\\nelse:\\n  for i in range(n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\n  for i in range(1,n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\nif s[0]==s[n-1]:\\n  flag^=1\\nprint('First' if flag==1 else 'Second')\", \"s = input()\\ncount = 0\\nplayer = ['First', 'Second']\\n\\nans = 0\\nwhile ans == 0:\\n    if len(s) == 2:\\n        ans = player[(count+1)%2]\\n    else:\\n        for i in range(1, len(s)-1):\\n            if s[i-1]!=s[i+1]:\\n                s = s[:i]+s[i+1:]\\n                break\\n        else:\\n            ans = player[(count+1)%2]\\n    count += 1\\nprint(ans)#winner\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2:\\n        ans = 'Second'\\n    else:\\n        ans = 'First'\\nelse:\\n    if len(s) % 2:\\n        ans = 'First'\\n    else:\\n        ans = 'Second'\\nprint(ans)\", \"S = input()\\nif len(S)%2 == 0 and S[0] == S[len(S)-1]:\\n  print(\\\"First\\\")\\nelif len(S)%2 == 0 and S[0] != S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelif len(S)%2 != 0 and S[0] == S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelse:\\n  print(\\\"First\\\")\", \"s = input()\\nt = (\\\"First\\\",\\\"Second\\\")\\nprint(t[(len(s)%2==0)^(s[0]==s[-1])])\", \"S = input()\\n\\nif S[0] == S[-1]:  # \\u5947\\u6570\\u624b\\u306e\\u8ca0\\u3051\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\\n\", \"s=input()\\nif (len(s)%2==0)^(s[0]!=s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n - 1]:\\n    if n % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if n % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s=input()\\n\\ndef solve(s):\\n\\tif s[0]==s[-1]:\\n\\t\\tA=1 \\n\\telse:\\n\\t\\tA=0\\n\\tif len(s)%2==0:\\n\\t\\tB=1\\n\\telse:\\n\\t\\tB=0\\n\\tif A+B==1:\\n\\t\\treturn(\\\"Second\\\")\\n\\telse:\\n\\t\\treturn(\\\"First\\\")\\n\\nprint(solve(s))\", \"s = input()\\nans = len(s) & 1\\nif (s[0] == s[-1]) ^ ans:\\n    print('First')\\nelse:\\n    print('Second')\\n\\n\", \"#D\\u554f\\u984c\\nS = list(str(input()))\\nSlen = len(S)\\n\\nfro = S[0]\\nbac = S[-1]\\n\\nif fro == bac:\\n    if Slen%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if Slen%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"s=input();print(\\\"SFeicrosntd\\\"[len(s)%2^(s[0]==s[-1])::2])\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1] and len(s) % 2 == 0:\\n    print('First')\\nelif s[0] != s[-1] and len(s) %2 == 1:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[len(s) - 1]:\\n    # a bab a\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    # a baba b\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"s = input()\\nprint(\\\"First\\\" if (s[0] == s[-1]) == (len(s) % 2 == 0) else \\\"Second\\\")\"]",
        "difficulty": "competition",
        "input": "abab\n",
        "output": "Second\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://atcoder.jp/contests/arc064/tasks/arc064_b"
    },
    {
        "id": 2149,
        "task_id": 3799,
        "test_case_id": 5,
        "question": "There is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n - Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.\nThe player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.\n\n-----Constraints-----\n - 3 ≤ |s| ≤ 10^5\n - s consists of lowercase English letters.\n - No two neighboring characters in s are equal.\n\n-----Input-----\nThe input is given from Standard Input in the following format:\ns\n\n-----Output-----\nIf Takahashi will win, print First. If Aoki will win, print Second.\n\n-----Sample Input-----\naba\n\n-----Sample Output-----\nSecond\n\nTakahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.",
        "solutions": "[\"s=input();print(['Second','First'][len(s.rstrip(s[0]))%2])\", \"S = input()\\nflag = (S[0] != S[-1]) ^ (len(S) % 2 == 0)\\nprint((\\\"First\\\" if flag else \\\"Second\\\"))\\n\", \"s=list(input())\\n\\nn=len(s)\\n\\nif (s[0]==s[n-1] and n%2 ==0) or (s[0] != s[n-1] and n%2 != 0):\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"s=input()\\nprint('Second' if (len(s)%2==0)^(s[0]==s[-1]) else 'First')\", \"s = input()\\nif s[0]==s[-1]:\\n    a = 1\\nelse:\\n    a = 0\\nif (len(s)-a)%2==0:\\n    print('Second')\\nelse:\\n    print('First')\", \"s=input();print('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"S = input()\\nN = len(S)\\n\\nif S[0] == S[-1]:\\n    if N%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if N%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s = input()\\nif (len(s)%2 + int(s[0]==s[-1]))%2:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"S = input()\\nans = \\\"First\\\"\\nif (S[0] == S[-1]) ^ (len(S) % 2 == 0):\\n    ans = \\\"Second\\\"\\nprint(ans)\\n\", \"s=input()\\n\\nif s[0]==s[len(s)-1]:\\n    if len(s)%2==1:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if len(s)%2==1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"import sys\\n# input = sys.stdin.readline\\ns = str(input())\\nn = len(s)\\nif s[0] == s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move == 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nread = sys.stdin.read\\nreadline = sys.stdin.readline\\n\\n#xs,ys,xt,yt = map(int,readline().split())\\n\\ns = input()\\n\\nif ((s[0]==s[-1]) + len(s))&1:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\\n\\n\", \"S = input()\\nprint((\\\"First\\\" if (len(S) % 2) ^ (S[0] == S[-1]) else \\\"Second\\\"))\\n\", \"#!/usr/bin/env python\\n# -*- coding:utf-8 -*-\\n\\ns = input()\\nif (len(s) % 2 == 0) and (s[0] == s[-1]):\\n    print(\\\"First\\\")\\nelif (len(s) % 2 == 0) or (s[0] == s[-1]):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\n\\nif (len(s) % 2 != 0)^(s[0] == s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"s = input()\\nprint(['Second', 'First'][(s[0]==s[-1])^(len(s)%2)])\", \"# -*- coding: utf-8 -*-\\ns = input()\\nn = len(s)\\n\\nif n%2==0 and s[0]!=s[n-1]:\\n    print(\\\"Second\\\")\\nelif n%2==1 and s[0]==s[n-1]:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"def main():\\n    s = input()\\n\\n    if s[0] == s[-1]:\\n        ss = 1\\n    else:\\n        ss = 0\\n\\n    if len(s) % 2 == ss:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import collections\\n\\n\\ndef solve():\\n    s = input()\\n    if s[0] == s[-1]:\\n        if len(s)%2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if len(s)%2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = list(input())\\nl = len(s)\\n\\nif s[0] == s[-1]:\\n    if l % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if l % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"S = input()\\nstart_end = (S[0] == S[-1])\\nodd = (len(S) % 2)\\nprint('First' if (start_end and not odd) or (not start_end and odd) else 'Second')\", \"s = input()\\nprint(\\\"Second\\\" if ((len(s)%2 == 0) ^ (s[0] == s[-1])) else \\\"First\\\")\", \"s=input()\\nrem=3 if s[0]==s[-1] else 2\\nif (len(s)-rem)%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\nplayers = ['First', 'Second']\\n\\nlast = 1 if s[0] == s[-1] else 0\\ncnt = (len(s) - 2 + 1 + last) % 2\\nans = players[cnt]\\n\\nprint(ans)\", \"import sys\\n\\ns = str(sys.stdin.readline().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\nprint('First' if (len(S)%2==0) == (S[0]==S[-1]) else 'Second')\", \"s = input()\\nn = len(s)\\nif s[0] == s[-1]:\\n  n += 1\\n  \\nprint(\\\"First\\\" if n % 2 else \\\"Second\\\")\", \"s=input()\\nprint('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"n=input()\\nif len(n)%2==0:\\n    if n[0]!=n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if n[0]==n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"S = list(input())\\nN = len(S)\\nA = N%2\\nB = (S[0]==S[-1])*1\\nif A==1 and B==1:\\n    print(\\\"Second\\\")\\nelif A==1 and B==0:\\n    print(\\\"First\\\")\\nelif A==0 and B==1:\\n    print(\\\"First\\\")\\nelif A==0 and B==0:\\n    print(\\\"Second\\\")\\n\", \"s = input().strip()\\nl = len(s)\\n \\nif (l + (s[0] == s[-1])) % 2:\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"import sys\\nS=input()\\nN=len(S)\\nif N%2!=0:\\n    if S[0]==S[N-1]:\\n        print('Second')\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if S[0]==S[N-1]:\\n        print('First')\\n    else:\\n        print('Second')\", \"s = input()\\n\\nif (len(s)%2==1 and s[-1]!=s[0]) or (len(s)%2==0 and s[-1]==s[0]):\\n    print('First')\\nelse:\\n    print('Second')\", \"def remove(s):\\n    i=1\\n    count=0\\n    while i<len(s)-1:\\n        if s[i-1]!=s[i+1]:\\n            s.pop(i)\\n            count+=1\\n        i+=1\\n    return count\\n\\ns=list(input())\\ncount=0\\nwhile True:\\n    tmp=remove(s)\\n    if tmp==0:\\n        break\\n    count+=tmp\\n\\nif count%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"S = input().strip()\\n\\nif S[0] == S[-1]:\\n  print(\\\"First\\\" if len(S) % 2 == 0 else \\\"Second\\\")\\nelse:\\n  print(\\\"Second\\\" if len(S) % 2 == 0 else \\\"First\\\")\", \"s = input()\\nl = len(s)\\n\\nif (s[0] == s[-1] and l % 2 == 0) or (s[0] != s[-1] and l % 2 != 0):\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"s=input();print(['Second','First'][(len(s)+(s[0]==s[-1]))%2])\", \"s = input()\\nn = len(s)\\n\\nmove = 0\\nif s[0] == s[-1]:\\n    move = 1\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\na = s[0]\\nb = s[len(s)-1]\\nn = len(s) % 2\\nif n == 1 and a == b:\\n    print('Second')\\nelif n == 1 and a != b:\\n    print('First')\\nelif n == 0 and a == b:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def __starting_point():\\n    S = input()\\n    N = len(S)\\n    if S[0] == S[-1]:\\n        if N % 2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if N % 2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\n__starting_point()\", \"S=input()\\nN=len(S)\\nif N%2==0:\\n    if S[0]==S[-1]:\\n        print('First')\\n    else:\\n        print('Second')\\nelse:\\n    if S[0]==S[-1]:\\n        print('Second')\\n    else:\\n        print('First')\", \"S = input()\\nif (S[0] == S[-1]) ^ (len(S) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def ARC064D():\\n    s = list(input())\\n    if s[0] == s[-1]:\\n        key = 1\\n    else:\\n        key = -1\\n\\n    if len(s) % 2 != 0:\\n        key *= -1\\n\\n    if key == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\\nARC064D()\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"s = input()\\nprint([\\\"Second\\\",\\\"First\\\"][(len(s) + (s[0] == s[-1])) % 2])\", \"S=input()\\nstart=len(S)%2\\nif S[0]==S[-1]:\\n    goal=1\\nelse:\\n    goal=0\\ncan=(start+goal)%2\\nif can==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"ss = input()\\n\\nif (ss[0] == ss[-1] and len(ss) % 2 == 0) or (ss[0] != ss[-1] and len(ss) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s=input()\\nif(s[0]==s[len(s)-1]):\\n    a=len(s)-3\\nelse:\\n    a=len(s)-2\\nif(a%2==0):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"s=(input())\\nl=len(s)\\ne=(s[0]==s[-1])\\nprint((\\\"First\\\" if (e+l)%2 else \\\"Second\\\"))\\n\", \"s=input();x=(len(s)+(s[0]==s[-1]))%2;print('First'*x+'Second'*(1-x))\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nS = list(s)\\nf = False\\nk = 1\\nflag = False\\nwhile len(S) > 2:\\n    if k == len(S) - 1:\\n        if flag:\\n            k = 1\\n            flag = False\\n            continue\\n        break\\n    if S[k - 1] != S[k + 1]:\\n        S.pop(k)\\n        f = not f\\n        flag = True\\n    else:\\n        k += 1\\nif f:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s)%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s)%2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"S=input()\\nif len(S)%2 == 0:\\n  print(('First' if S[0]==S[-1] else 'Second'))\\nelse:\\n  print(('First' if S[0]!=S[-1] else 'Second'))\\n\", \"# -*- coding: utf-8 -*-\\ns = input()\\nlr_same = (s[0] == s[-1])\\nodd = len(s)%2\\n\\nif lr_same ^ odd:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ns = str(input().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\n\\ns = sys.stdin.readline().strip()\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif (len(s)%2==0)^(s[0]==s[-1]):\\n  print('Second')\\nelse:\\n  print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"\\nimport sys\\ndef input():\\n\\treturn sys.stdin.readline().strip()\\n\\ns = input()\\n\\nif s[0] == s[-1]:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"First\\\")\\n\\telse:\\n\\t\\tprint(\\\"Second\\\")\\nelse:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"Second\\\")\\n\\telse:\\n\\t\\tprint(\\\"First\\\")\", \"import sys\\nstdin = sys.stdin\\n\\nsys.setrecursionlimit(10**5) \\n \\ndef li(): return list(map(int, stdin.readline().split()))\\ndef li_(): return [int(x)-1 for x in stdin.readline().split()]\\ndef lf(): return list(map(float, stdin.readline().split()))\\ndef ls(): return stdin.readline().split()\\ndef ns(): return stdin.readline().rstrip()\\ndef lc(): return list(ns())\\ndef ni(): return int(stdin.readline())\\ndef nf(): return float(stdin.readline())\\n\\ns = lc()\\n\\nleft = s[0]\\nright = s[-1]\\n\\n# aba\\u578b\\u306e\\u3068\\u304d\\nif s[0] == s[-1]:\\n    if len(s)%2:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n# ab\\u578b\\u306e\\u3068\\u304d    \\nelse:\\n    if len(s)%2:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"ar = list(input())\\nb = 0\\nwhile True:\\n    count = 0\\n    for i in range(1,len(ar)-1):\\n        if ar[i-1] != ar[i+1]:\\n            count +=1\\n            del ar[i]\\n            b += 1\\n            break\\n    if count == 0:\\n        if b % 2 == 1:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n        break\", \"s=input()\\nx,y=s[0],s[-1]\\nl=len(s)\\nif l%2==0:\\n  if x==y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n  \\nif l%2==1:\\n  if x!=y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\", \"S = input()\\nif S[0] == S[-1]:\\n  if len(S)%2 == 0:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\nelse:\\n  if len(S)%2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"S=input().rstrip()\\nprint((\\\"First\\\" if (len(S)+(S[0]==S[-1]))%2 else \\\"Second\\\"))\\n\", \"s = input()\\nif (len(s)+(s[0]==s[-1]))%2==1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\n\\nif S[0] == S[-1]:\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"S=input();A=len(S)%2;B=0 if S[0]==S[-1] else 1;print(\\\"Second\\\" if A^B else \\\"First\\\")\", \"S = input()\\nl = len(S)\\nprint(('First' if (l & 1) ^ (S[0] == S[-1]) else 'Second'))\\n\", \"s=input()\\nif s[0] == s[-1]:\\n    print(('First','Second')[len(s)%2])\\nelse:\\n    print(('Second','First')[len(s)%2])\", \"s=input()\\nif (len(s)%2==0 and s[0]==s[-1]) or (len(s)%2!=0 and s[0]!=s[-1]):\\n\\tprint(\\\"First\\\")\\nelse:\\n\\tprint(\\\"Second\\\")\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input().strip()\\nc1, c2 = s[0], s[-1]\\nif c1 == c2:\\n    if len(s) % 2:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(s) % 2:\\n        print('First')\\n    else:\\n        print('Second')\\n\", \"s=input();l = len;p = print\\nif (s[0]==s[-1] and l(s)%2==0) or (s[0]!=s[-1] and l(s)%2==1):\\n    p(\\\"First\\\")\\nelse:\\n    p(\\\"Second\\\")\\n\", \"import sys\\n\\nsys.setrecursionlimit(10 ** 8)\\nini = lambda: int(sys.stdin.readline())\\ninm = lambda: list(map(int, sys.stdin.readline().split()))\\ninl = lambda: list(inm())\\nins = lambda: sys.stdin.readline().rstrip()\\n# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)\\n\\ns = ins()\\n\\n\\ndef solve():\\n    lreq = s[0] == s[-1]\\n    odd = len(s) % 2 == 1\\n    return odd ^ lreq\\n\\n\\nprint((\\\"First\\\" if solve() else \\\"Second\\\"))\\n\", \"s=input()\\nif len(s)%2==0 and s[0]==s[-1]:\\n  print('First')\\nelif len(s)%2==1 and s[0]!=s[-1]:\\n  print('First')\\nelse:\\n  print('Second')\", \"from operator import xor\\nS = input()\\na = (len(S)+1) % 2\\nb = int(S[0] == S[-1])\\nans = \\\"Second\\\" if xor(a,b) else \\\"First\\\"\\nprint(ans)\", \"s = input()\\nif ((len(s)%2)+(s[0]==s[-1]))%2:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1]:\\n  if len(s) % 2 == 1:\\n    print(\\\"Second\\\")\\n  else:\\n    print(\\\"First\\\")\\nelse:\\n  if len(s) % 2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"s=list(input())\\nn=len(s)\\nflag=1\\nif n%2==0:\\n  flag=0\\nelse:\\n  for i in range(n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\n  for i in range(1,n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\nif s[0]==s[n-1]:\\n  flag^=1\\nprint('First' if flag==1 else 'Second')\", \"s = input()\\ncount = 0\\nplayer = ['First', 'Second']\\n\\nans = 0\\nwhile ans == 0:\\n    if len(s) == 2:\\n        ans = player[(count+1)%2]\\n    else:\\n        for i in range(1, len(s)-1):\\n            if s[i-1]!=s[i+1]:\\n                s = s[:i]+s[i+1:]\\n                break\\n        else:\\n            ans = player[(count+1)%2]\\n    count += 1\\nprint(ans)#winner\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2:\\n        ans = 'Second'\\n    else:\\n        ans = 'First'\\nelse:\\n    if len(s) % 2:\\n        ans = 'First'\\n    else:\\n        ans = 'Second'\\nprint(ans)\", \"S = input()\\nif len(S)%2 == 0 and S[0] == S[len(S)-1]:\\n  print(\\\"First\\\")\\nelif len(S)%2 == 0 and S[0] != S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelif len(S)%2 != 0 and S[0] == S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelse:\\n  print(\\\"First\\\")\", \"s = input()\\nt = (\\\"First\\\",\\\"Second\\\")\\nprint(t[(len(s)%2==0)^(s[0]==s[-1])])\", \"S = input()\\n\\nif S[0] == S[-1]:  # \\u5947\\u6570\\u624b\\u306e\\u8ca0\\u3051\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\\n\", \"s=input()\\nif (len(s)%2==0)^(s[0]!=s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n - 1]:\\n    if n % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if n % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s=input()\\n\\ndef solve(s):\\n\\tif s[0]==s[-1]:\\n\\t\\tA=1 \\n\\telse:\\n\\t\\tA=0\\n\\tif len(s)%2==0:\\n\\t\\tB=1\\n\\telse:\\n\\t\\tB=0\\n\\tif A+B==1:\\n\\t\\treturn(\\\"Second\\\")\\n\\telse:\\n\\t\\treturn(\\\"First\\\")\\n\\nprint(solve(s))\", \"s = input()\\nans = len(s) & 1\\nif (s[0] == s[-1]) ^ ans:\\n    print('First')\\nelse:\\n    print('Second')\\n\\n\", \"#D\\u554f\\u984c\\nS = list(str(input()))\\nSlen = len(S)\\n\\nfro = S[0]\\nbac = S[-1]\\n\\nif fro == bac:\\n    if Slen%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if Slen%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"s=input();print(\\\"SFeicrosntd\\\"[len(s)%2^(s[0]==s[-1])::2])\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1] and len(s) % 2 == 0:\\n    print('First')\\nelif s[0] != s[-1] and len(s) %2 == 1:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[len(s) - 1]:\\n    # a bab a\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    # a baba b\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"s = input()\\nprint(\\\"First\\\" if (s[0] == s[-1]) == (len(s) % 2 == 0) else \\\"Second\\\")\"]",
        "difficulty": "competition",
        "input": "abac\n",
        "output": "Second\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://atcoder.jp/contests/arc064/tasks/arc064_b"
    },
    {
        "id": 2150,
        "task_id": 3799,
        "test_case_id": 7,
        "question": "There is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\nTakahashi and Aoki will play a game against each other.\nThe two players alternately performs the following operation, Takahashi going first:\n - Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.\nThe player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.\n\n-----Constraints-----\n - 3 ≤ |s| ≤ 10^5\n - s consists of lowercase English letters.\n - No two neighboring characters in s are equal.\n\n-----Input-----\nThe input is given from Standard Input in the following format:\ns\n\n-----Output-----\nIf Takahashi will win, print First. If Aoki will win, print Second.\n\n-----Sample Input-----\naba\n\n-----Sample Output-----\nSecond\n\nTakahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.",
        "solutions": "[\"s=input();print(['Second','First'][len(s.rstrip(s[0]))%2])\", \"S = input()\\nflag = (S[0] != S[-1]) ^ (len(S) % 2 == 0)\\nprint((\\\"First\\\" if flag else \\\"Second\\\"))\\n\", \"s=list(input())\\n\\nn=len(s)\\n\\nif (s[0]==s[n-1] and n%2 ==0) or (s[0] != s[n-1] and n%2 != 0):\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"s=input()\\nprint('Second' if (len(s)%2==0)^(s[0]==s[-1]) else 'First')\", \"s = input()\\nif s[0]==s[-1]:\\n    a = 1\\nelse:\\n    a = 0\\nif (len(s)-a)%2==0:\\n    print('Second')\\nelse:\\n    print('First')\", \"s=input();print('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"S = input()\\nN = len(S)\\n\\nif S[0] == S[-1]:\\n    if N%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if N%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s = input()\\nif (len(s)%2 + int(s[0]==s[-1]))%2:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"S = input()\\nans = \\\"First\\\"\\nif (S[0] == S[-1]) ^ (len(S) % 2 == 0):\\n    ans = \\\"Second\\\"\\nprint(ans)\\n\", \"s=input()\\n\\nif s[0]==s[len(s)-1]:\\n    if len(s)%2==1:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if len(s)%2==1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"import sys\\n# input = sys.stdin.readline\\ns = str(input())\\nn = len(s)\\nif s[0] == s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move == 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"# coding: utf-8\\n# Your code here!\\nimport sys\\nread = sys.stdin.read\\nreadline = sys.stdin.readline\\n\\n#xs,ys,xt,yt = map(int,readline().split())\\n\\ns = input()\\n\\nif ((s[0]==s[-1]) + len(s))&1:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\\n\\n\", \"S = input()\\nprint((\\\"First\\\" if (len(S) % 2) ^ (S[0] == S[-1]) else \\\"Second\\\"))\\n\", \"#!/usr/bin/env python\\n# -*- coding:utf-8 -*-\\n\\ns = input()\\nif (len(s) % 2 == 0) and (s[0] == s[-1]):\\n    print(\\\"First\\\")\\nelif (len(s) % 2 == 0) or (s[0] == s[-1]):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\n\\nif (len(s) % 2 != 0)^(s[0] == s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"s = input()\\nprint(['Second', 'First'][(s[0]==s[-1])^(len(s)%2)])\", \"# -*- coding: utf-8 -*-\\ns = input()\\nn = len(s)\\n\\nif n%2==0 and s[0]!=s[n-1]:\\n    print(\\\"Second\\\")\\nelif n%2==1 and s[0]==s[n-1]:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"def main():\\n    s = input()\\n\\n    if s[0] == s[-1]:\\n        ss = 1\\n    else:\\n        ss = 0\\n\\n    if len(s) % 2 == ss:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"import collections\\n\\n\\ndef solve():\\n    s = input()\\n    if s[0] == s[-1]:\\n        if len(s)%2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if len(s)%2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\ndef __starting_point():\\n    solve()\\n\\n__starting_point()\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = list(input())\\nl = len(s)\\n\\nif s[0] == s[-1]:\\n    if l % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if l % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"S = input()\\nstart_end = (S[0] == S[-1])\\nodd = (len(S) % 2)\\nprint('First' if (start_end and not odd) or (not start_end and odd) else 'Second')\", \"s = input()\\nprint(\\\"Second\\\" if ((len(s)%2 == 0) ^ (s[0] == s[-1])) else \\\"First\\\")\", \"s=input()\\nrem=3 if s[0]==s[-1] else 2\\nif (len(s)-rem)%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"s = input()\\nplayers = ['First', 'Second']\\n\\nlast = 1 if s[0] == s[-1] else 0\\ncnt = (len(s) - 2 + 1 + last) % 2\\nans = players[cnt]\\n\\nprint(ans)\", \"import sys\\n\\ns = str(sys.stdin.readline().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\nprint('First' if (len(S)%2==0) == (S[0]==S[-1]) else 'Second')\", \"s = input()\\nn = len(s)\\nif s[0] == s[-1]:\\n  n += 1\\n  \\nprint(\\\"First\\\" if n % 2 else \\\"Second\\\")\", \"s=input()\\nprint('SFeicrosntd'[len(s)+(s[0]==s[-1])&1::2])\", \"n=input()\\nif len(n)%2==0:\\n    if n[0]!=n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if n[0]==n[-1]:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"S = list(input())\\nN = len(S)\\nA = N%2\\nB = (S[0]==S[-1])*1\\nif A==1 and B==1:\\n    print(\\\"Second\\\")\\nelif A==1 and B==0:\\n    print(\\\"First\\\")\\nelif A==0 and B==1:\\n    print(\\\"First\\\")\\nelif A==0 and B==0:\\n    print(\\\"Second\\\")\\n\", \"s = input().strip()\\nl = len(s)\\n \\nif (l + (s[0] == s[-1])) % 2:\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"import sys\\nS=input()\\nN=len(S)\\nif N%2!=0:\\n    if S[0]==S[N-1]:\\n        print('Second')\\n    else:\\n        print(\\\"First\\\")\\nelse:\\n    if S[0]==S[N-1]:\\n        print('First')\\n    else:\\n        print('Second')\", \"s = input()\\n\\nif (len(s)%2==1 and s[-1]!=s[0]) or (len(s)%2==0 and s[-1]==s[0]):\\n    print('First')\\nelse:\\n    print('Second')\", \"def remove(s):\\n    i=1\\n    count=0\\n    while i<len(s)-1:\\n        if s[i-1]!=s[i+1]:\\n            s.pop(i)\\n            count+=1\\n        i+=1\\n    return count\\n\\ns=list(input())\\ncount=0\\nwhile True:\\n    tmp=remove(s)\\n    if tmp==0:\\n        break\\n    count+=tmp\\n\\nif count%2==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\\n\", \"S = input().strip()\\n\\nif S[0] == S[-1]:\\n  print(\\\"First\\\" if len(S) % 2 == 0 else \\\"Second\\\")\\nelse:\\n  print(\\\"Second\\\" if len(S) % 2 == 0 else \\\"First\\\")\", \"s = input()\\nl = len(s)\\n\\nif (s[0] == s[-1] and l % 2 == 0) or (s[0] != s[-1] and l % 2 != 0):\\n  print(\\\"First\\\")\\nelse:\\n  print(\\\"Second\\\")\", \"s=input();print(['Second','First'][(len(s)+(s[0]==s[-1]))%2])\", \"s = input()\\nn = len(s)\\n\\nmove = 0\\nif s[0] == s[-1]:\\n    move = 1\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\na = s[0]\\nb = s[len(s)-1]\\nn = len(s) % 2\\nif n == 1 and a == b:\\n    print('Second')\\nelif n == 1 and a != b:\\n    print('First')\\nelif n == 0 and a == b:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def __starting_point():\\n    S = input()\\n    N = len(S)\\n    if S[0] == S[-1]:\\n        if N % 2 == 0:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n    else:\\n        if N % 2 == 0:\\n            print(\\\"Second\\\")\\n        else:\\n            print(\\\"First\\\")\\n\\n__starting_point()\", \"S=input()\\nN=len(S)\\nif N%2==0:\\n    if S[0]==S[-1]:\\n        print('First')\\n    else:\\n        print('Second')\\nelse:\\n    if S[0]==S[-1]:\\n        print('Second')\\n    else:\\n        print('First')\", \"S = input()\\nif (S[0] == S[-1]) ^ (len(S) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"def ARC064D():\\n    s = list(input())\\n    if s[0] == s[-1]:\\n        key = 1\\n    else:\\n        key = -1\\n\\n    if len(s) % 2 != 0:\\n        key *= -1\\n\\n    if key == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\\nARC064D()\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"s = input()\\nprint([\\\"Second\\\",\\\"First\\\"][(len(s) + (s[0] == s[-1])) % 2])\", \"S=input()\\nstart=len(S)%2\\nif S[0]==S[-1]:\\n    goal=1\\nelse:\\n    goal=0\\ncan=(start+goal)%2\\nif can==0:\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"import sys\\ninput = sys.stdin.readline\\ns = str(input().strip())\\nn = len(s)\\nif s[0] is s[n - 1]:\\n\\tmove = 1\\nelse:\\n\\tmove = 0\\nmove = (n - move) % 2\\nif move is 1:\\n\\tprint('First')\\nelse:\\n\\tprint('Second')\", \"ss = input()\\n\\nif (ss[0] == ss[-1] and len(ss) % 2 == 0) or (ss[0] != ss[-1] and len(ss) % 2):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s=input()\\nif(s[0]==s[len(s)-1]):\\n    a=len(s)-3\\nelse:\\n    a=len(s)-2\\nif(a%2==0):\\n    print(\\\"Second\\\")\\nelse:\\n    print(\\\"First\\\")\", \"s=(input())\\nl=len(s)\\ne=(s[0]==s[-1])\\nprint((\\\"First\\\" if (e+l)%2 else \\\"Second\\\"))\\n\", \"s=input();x=(len(s)+(s[0]==s[-1]))%2;print('First'*x+'Second'*(1-x))\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nS = list(s)\\nf = False\\nk = 1\\nflag = False\\nwhile len(S) > 2:\\n    if k == len(S) - 1:\\n        if flag:\\n            k = 1\\n            flag = False\\n            continue\\n        break\\n    if S[k - 1] != S[k + 1]:\\n        S.pop(k)\\n        f = not f\\n        flag = True\\n    else:\\n        k += 1\\nif f:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s)%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if len(s)%2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"S=input()\\nif len(S)%2 == 0:\\n  print(('First' if S[0]==S[-1] else 'Second'))\\nelse:\\n  print(('First' if S[0]!=S[-1] else 'Second'))\\n\", \"# -*- coding: utf-8 -*-\\ns = input()\\nlr_same = (s[0] == s[-1])\\nodd = len(s)%2\\n\\nif lr_same ^ odd:\\n    print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ns = str(input().strip())\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"import sys\\n\\ns = sys.stdin.readline().strip()\\n\\nn = len(s)\\n\\nif s[0] == s[n-1]:\\n    move = 1\\nelse:\\n    move = 0\\n\\nmove = (n - move) % 2\\n\\nif move == 1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nif (len(s)%2==0)^(s[0]==s[-1]):\\n  print('Second')\\nelse:\\n  print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"\\nimport sys\\ndef input():\\n\\treturn sys.stdin.readline().strip()\\n\\ns = input()\\n\\nif s[0] == s[-1]:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"First\\\")\\n\\telse:\\n\\t\\tprint(\\\"Second\\\")\\nelse:\\n\\tif len(s) % 2 == 0:\\n\\t\\tprint(\\\"Second\\\")\\n\\telse:\\n\\t\\tprint(\\\"First\\\")\", \"import sys\\nstdin = sys.stdin\\n\\nsys.setrecursionlimit(10**5) \\n \\ndef li(): return list(map(int, stdin.readline().split()))\\ndef li_(): return [int(x)-1 for x in stdin.readline().split()]\\ndef lf(): return list(map(float, stdin.readline().split()))\\ndef ls(): return stdin.readline().split()\\ndef ns(): return stdin.readline().rstrip()\\ndef lc(): return list(ns())\\ndef ni(): return int(stdin.readline())\\ndef nf(): return float(stdin.readline())\\n\\ns = lc()\\n\\nleft = s[0]\\nright = s[-1]\\n\\n# aba\\u578b\\u306e\\u3068\\u304d\\nif s[0] == s[-1]:\\n    if len(s)%2:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\\n# ab\\u578b\\u306e\\u3068\\u304d    \\nelse:\\n    if len(s)%2:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\n\", \"ar = list(input())\\nb = 0\\nwhile True:\\n    count = 0\\n    for i in range(1,len(ar)-1):\\n        if ar[i-1] != ar[i+1]:\\n            count +=1\\n            del ar[i]\\n            b += 1\\n            break\\n    if count == 0:\\n        if b % 2 == 1:\\n            print(\\\"First\\\")\\n        else:\\n            print(\\\"Second\\\")\\n        break\", \"s=input()\\nx,y=s[0],s[-1]\\nl=len(s)\\nif l%2==0:\\n  if x==y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n  \\nif l%2==1:\\n  if x!=y:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\", \"S = input()\\nif S[0] == S[-1]:\\n  if len(S)%2 == 0:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\nelse:\\n  if len(S)%2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"S=input().rstrip()\\nprint((\\\"First\\\" if (len(S)+(S[0]==S[-1]))%2 else \\\"Second\\\"))\\n\", \"s = input()\\nif (len(s)+(s[0]==s[-1]))%2==1:\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"S = input()\\n\\nif S[0] == S[-1]:\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\", \"s = input()\\ntable = [0] * 30\\no = lambda x: ord(x) - ord('a')\\nkind = 0\\nfor c in s:\\n    if table[o(c)] == 0:\\n        kind += 1\\n    table[o(c)] += 1\\n\\nif kind > 2 and s[0] != s[-1]:\\n    print(\\\"First\\\") if len(s) % 2 == 1 else print(\\\"Second\\\")\\nelif kind > 2 and s[0] == s[-1]:\\n    print(\\\"Second\\\") if len(s) % 2 == 1 else print(\\\"First\\\")\\nelse:\\n    print(\\\"Second\\\")\\n\", \"S=input();A=len(S)%2;B=0 if S[0]==S[-1] else 1;print(\\\"Second\\\" if A^B else \\\"First\\\")\", \"S = input()\\nl = len(S)\\nprint(('First' if (l & 1) ^ (S[0] == S[-1]) else 'Second'))\\n\", \"s=input()\\nif s[0] == s[-1]:\\n    print(('First','Second')[len(s)%2])\\nelse:\\n    print(('Second','First')[len(s)%2])\", \"s=input()\\nif (len(s)%2==0 and s[0]==s[-1]) or (len(s)%2!=0 and s[0]!=s[-1]):\\n\\tprint(\\\"First\\\")\\nelse:\\n\\tprint(\\\"Second\\\")\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input().strip()\\nc1, c2 = s[0], s[-1]\\nif c1 == c2:\\n    if len(s) % 2:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(s) % 2:\\n        print('First')\\n    else:\\n        print('Second')\\n\", \"s=input();l = len;p = print\\nif (s[0]==s[-1] and l(s)%2==0) or (s[0]!=s[-1] and l(s)%2==1):\\n    p(\\\"First\\\")\\nelse:\\n    p(\\\"Second\\\")\\n\", \"import sys\\n\\nsys.setrecursionlimit(10 ** 8)\\nini = lambda: int(sys.stdin.readline())\\ninm = lambda: list(map(int, sys.stdin.readline().split()))\\ninl = lambda: list(inm())\\nins = lambda: sys.stdin.readline().rstrip()\\n# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)\\n\\ns = ins()\\n\\n\\ndef solve():\\n    lreq = s[0] == s[-1]\\n    odd = len(s) % 2 == 1\\n    return odd ^ lreq\\n\\n\\nprint((\\\"First\\\" if solve() else \\\"Second\\\"))\\n\", \"s=input()\\nif len(s)%2==0 and s[0]==s[-1]:\\n  print('First')\\nelif len(s)%2==1 and s[0]!=s[-1]:\\n  print('First')\\nelse:\\n  print('Second')\", \"from operator import xor\\nS = input()\\na = (len(S)+1) % 2\\nb = int(S[0] == S[-1])\\nans = \\\"Second\\\" if xor(a,b) else \\\"First\\\"\\nprint(ans)\", \"s = input()\\nif ((len(s)%2)+(s[0]==s[-1]))%2:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1]:\\n  if len(s) % 2 == 1:\\n    print(\\\"Second\\\")\\n  else:\\n    print(\\\"First\\\")\\nelse:\\n  if len(s) % 2 == 1:\\n    print(\\\"First\\\")\\n  else:\\n    print(\\\"Second\\\")\\n\", \"s=list(input())\\nn=len(s)\\nflag=1\\nif n%2==0:\\n  flag=0\\nelse:\\n  for i in range(n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\n  for i in range(1,n-2):\\n    if s[i]!=s[i+2]:\\n      flag=1\\nif s[0]==s[n-1]:\\n  flag^=1\\nprint('First' if flag==1 else 'Second')\", \"s = input()\\ncount = 0\\nplayer = ['First', 'Second']\\n\\nans = 0\\nwhile ans == 0:\\n    if len(s) == 2:\\n        ans = player[(count+1)%2]\\n    else:\\n        for i in range(1, len(s)-1):\\n            if s[i-1]!=s[i+1]:\\n                s = s[:i]+s[i+1:]\\n                break\\n        else:\\n            ans = player[(count+1)%2]\\n    count += 1\\nprint(ans)#winner\", \"s = input()\\nif s[0] == s[-1]:\\n    if len(s) % 2:\\n        ans = 'Second'\\n    else:\\n        ans = 'First'\\nelse:\\n    if len(s) % 2:\\n        ans = 'First'\\n    else:\\n        ans = 'Second'\\nprint(ans)\", \"S = input()\\nif len(S)%2 == 0 and S[0] == S[len(S)-1]:\\n  print(\\\"First\\\")\\nelif len(S)%2 == 0 and S[0] != S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelif len(S)%2 != 0 and S[0] == S[len(S)-1]:\\n  print(\\\"Second\\\")\\nelse:\\n  print(\\\"First\\\")\", \"s = input()\\nt = (\\\"First\\\",\\\"Second\\\")\\nprint(t[(len(s)%2==0)^(s[0]==s[-1])])\", \"S = input()\\n\\nif S[0] == S[-1]:  # \\u5947\\u6570\\u624b\\u306e\\u8ca0\\u3051\\n    if len(S) % 2 == 1:\\n        print('Second')\\n    else:\\n        print('First')\\nelse:\\n    if len(S) % 2 == 0:\\n        print('Second')\\n    else:\\n        print('First')\\n\", \"s=input()\\nif (len(s)%2==0)^(s[0]!=s[-1]):\\n    print('First')\\nelse:\\n    print('Second')\\n\", \"s = input()\\nn = len(s)\\n\\nif s[0] == s[n - 1]:\\n    if n % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if n % 2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\", \"s=input()\\n\\ndef solve(s):\\n\\tif s[0]==s[-1]:\\n\\t\\tA=1 \\n\\telse:\\n\\t\\tA=0\\n\\tif len(s)%2==0:\\n\\t\\tB=1\\n\\telse:\\n\\t\\tB=0\\n\\tif A+B==1:\\n\\t\\treturn(\\\"Second\\\")\\n\\telse:\\n\\t\\treturn(\\\"First\\\")\\n\\nprint(solve(s))\", \"s = input()\\nans = len(s) & 1\\nif (s[0] == s[-1]) ^ ans:\\n    print('First')\\nelse:\\n    print('Second')\\n\\n\", \"#D\\u554f\\u984c\\nS = list(str(input()))\\nSlen = len(S)\\n\\nfro = S[0]\\nbac = S[-1]\\n\\nif fro == bac:\\n    if Slen%2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    if Slen%2 == 0:\\n        print(\\\"Second\\\")\\n    else:\\n        print(\\\"First\\\")\\n\", \"s=input();print(\\\"SFeicrosntd\\\"[len(s)%2^(s[0]==s[-1])::2])\", \"a,*s,g=input()\\nc=s.count\\nif a==g:\\n  if(len(s)-c(a)*2)%2:\\n    print('Second')\\n  else:\\n    print('First')\\nelse:\\n  if(len(s)-max(c(a),c(g))*2)%2:\\n    print('First')\\n  else:\\n    print('Second')\", \"s = input()\\nif s[0] == s[-1] and len(s) % 2 == 0:\\n    print('First')\\nelif s[0] != s[-1] and len(s) %2 == 1:\\n    print('First')\\nelse:\\n    print('Second')\", \"s = input()\\nif s[0] == s[len(s) - 1]:\\n    # a bab a\\n    if len(s) % 2 == 0:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\\nelse:\\n    # a baba b\\n    if len(s) % 2 == 1:\\n        print(\\\"First\\\")\\n    else:\\n        print(\\\"Second\\\")\", \"s = input()\\nprint(\\\"First\\\" if (s[0] == s[-1]) == (len(s) % 2 == 0) else \\\"Second\\\")\"]",
        "difficulty": "competition",
        "input": "abcb\n",
        "output": "Second\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://atcoder.jp/contests/arc064/tasks/arc064_b"
    },
    {
        "id": 2151,
        "task_id": 3802,
        "test_case_id": 1,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "AJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n",
        "output": "ORZ\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2152,
        "task_id": 3802,
        "test_case_id": 2,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "AA\nA\nA\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2153,
        "task_id": 3802,
        "test_case_id": 3,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "PWBJTZPQHA\nZJMKLWSROQ\nUQ\n",
        "output": "WQ\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2154,
        "task_id": 3802,
        "test_case_id": 4,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "QNHRPFYMAAPJDUHBAEXNEEZSTMYHVGQPYKNMVKMBVSVLIYGUVMJHEFLJEPIWFHSLISTGOKRXNMSCXYKMAXBPKCOCNTIRPCUEPHXM\nRRFCZUGFDRKKMQTOETNELXMEWGOCDHFKIXOPVHHEWTCDNXVFKFKTKNWKEIKTCMHMHDNCLLVQSGKHBCDDYVVVQIRPZEOPUGQUGRHH\nR\n",
        "output": "QNHFPHEXNETMHMHLLSGKCYPOPUH\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2155,
        "task_id": 3802,
        "test_case_id": 5,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "CGPWTAPEVBTGANLCLVSHQIIKHDPVUHRSQPXHSNYAHPGBECICFQYDFRTRELLLEDZYWJSLOBSKDGRRDHNRRGIXAMEBGFJJTEIGUGRU\nHAWYVKRRBEIWNOGYMIYQXDCFXMMCSAYSOXQFHHIFRRCJRAWHLDDHHHAKHXVKCVPBFGGEXUKWTFWMOUUGMXTSBUTHXCJCWHCQQTYQ\nANKFDWLYSX\n",
        "output": "WVBGCSSQHHIFRRWLDDHXBGFUGU\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2156,
        "task_id": 3802,
        "test_case_id": 6,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "AUNBEKNURNUPHXQYKUTAHCOLMPRQZZTVDUYCTNIRACQQTQAIDTAWJXBUTIZUASDIJZWLHAQVGCAHKTZMXSDVVWAIGQEALRFKFYTT\nQBVRFKPKLYZLYNRFTRJZZQEYAEKPFXVICUVFVQSDENBJYYNCFTOZHULSWJQTNELYLKCZTGHOARDCFXBXQGGSQIVUCJVNGFZEEZQE\nN\n",
        "output": "BKPYTRZZVICQDJTZUSJZHAQGSVVGQE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2157,
        "task_id": 3802,
        "test_case_id": 7,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "BGIIURZTEUJJULBWKHDQBRFGEUOMQSREOTILICRSBUHBGTSRDHKVDDEBVHGMHXUVFJURSMFDJOOOWCYPJDVRVKLDHICPNKTBFXDJ\nXOADNTKNILGNHHBNFYNDWUNXBGDFUKUVHLPDOGOYRMOTAQELLRMHFAQEOXFWGAQUROVUSWOAWFRVIRJQVXPCXLSCQLCUWKBZUFQP\nYVF\n",
        "output": "ILBWKHDGOMQELRHEGUVUSOWVRVLCKBF\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2158,
        "task_id": 3802,
        "test_case_id": 8,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "AXBPBDEYIYKKCZBTLKBUNEQLCXXLKIUTOOATYDXYYQCLFAXAEIGTFMNTTQKCQRMEEFRYVYXAOLMUQNPJBMFBUGVXFZAJSBXWALSI\nVWFONLLKSHGHHQSFBBFWTXAITPUKNDANOCLMNFTAAMJVDLXYPILPCJCFWTNBQWEOMMXHRYHEGBJIVSXBBGQKXRIYNZFIWSZPPUUM\nPPKKLHXWWT\n",
        "output": "BBITKNCLTADXYCFTNQMRYVXBBGXFWS\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2159,
        "task_id": 3802,
        "test_case_id": 9,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "XKTAOCPCVMIOGCQKPENDKIZRZBZVRTBTGCDRQUIMVHABDIHSCGWPUTQKLPBOXAYICPWJBFLFSEPERGJZHRINEHQMYTOTKLCQCSMZ\nAITFIOUTUVZLSSIYWXSYTQMFLICCXOFSACHTKGPXRHRCGXFZXPYWKWPUOIDNEEZOKMOUYGVUJRQTIRQFCSBCWXVFCIAOLZDGENNI\nDBHOIORVCPNXCDOJKSYYIENQRJGZFHOWBYQIITMTVWXRMAMYILTHBBAJRJELWMIZOZBGPDGSTIRTQIILJRYICMUQTUAFKDYGECPY\n",
        "output": "TOVMIOCKPRRCGWPUOIEEGJRQTQCSZ\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2160,
        "task_id": 3802,
        "test_case_id": 10,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "UNGXODEEINVYVPHYVGSWPIPFMFLZJYRJIPCUSWVUDLLSLRPJJFWCUOYDUGXBRKWPARGLXFJCNNFUIGEZUCTPFYUIMQMJLQHTIVPO\nBWDEGORKXYCXIDWZKGFCUYIDYLTWLCDBUVHPAPFLIZPEUINQSTNRAOVYKZCKFWIJQVLSVCGLTCOEMAYRCDVVQWQENTWZALWUKKKA\nXDGPZXADAFCHKILONSXFGRHIQVMIYWUTJUPCCEKYQVYAENRHVWERJSNPVEMRYSZGYBNTQLIFKFISKZJQIQQGSKVGCNMPNIJDRTXI\n",
        "output": "GODIYVHPPFLZPUSWVLSLCOYDWALU\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2161,
        "task_id": 3802,
        "test_case_id": 11,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "KOROXDDWEUVYWJIXSFPEJFYZJDDUXISOFJTIFJSBTWIJQHMTQWLAGGMXTFALRXYCMGZNKYQRCDVTPRQDBAALTWAXTNLDPYWNSFKE\nNHZGRZFMFQGSAYOJTFKMMUPOOQXWCPPAIVRJHINJPHXTTBWRIYNOHMJKBBGXVXYZDBVBBTQRXTOFLBBCXGNICBKAAGOKAYCCJYCW\nXCXLBESCRBNKWYGFDZFKWYNLFAKEWWGRUIAQGNCFDQXCHDBEQDSWSNGVKUFOGGSPFFZWTXGZQMMFJXDWOPUEZCMZEFDHXTRJTNLW\n",
        "output": "KOOXWVJIPXTBWIHMTQXTFLCGNCBAAAYW\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2162,
        "task_id": 3802,
        "test_case_id": 12,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ESQZPIRAWBTUZSOWLYKIYCHZJPYERRXPJANKPZVPEDCXCJIDTLCARMAOTZMHJVDJXRDNQRIIOFIUTALVSCKDUSAKANKKOFKWINLQ\nGKSTYEAXFJQQUTKPZDAKHZKXCJDONKBZOTYGLYQJOGKOYMYNNNQRRVAGARKBQYJRVYYPFXTIBJJYQUWJUGAUQZUVMUHXLIQWGRMP\nUFPHNRDXLNYRIIYVOFRKRUQCWAICQUUBPHHEGBCILXHHGLOBKADQVPSQCMXJRLIZQPSRLZJNZVQPIURDQUKNHVVYNVBYGXXXXJDI\n",
        "output": "STYEXJKPZDXCJDTLOMVRQRFIUAVUIQ\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2163,
        "task_id": 3802,
        "test_case_id": 13,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "UAYQUMTSNGMYBORUYXJJQZVAGBRVDWUTGUYYYOTWAHVKGGOHADXULFUFQULSAGDWFJCSDKPWBROYZIFRGGRVZQMEHKHCKNHTQSMK\nSVKVTPUZOBRKGLEAAXMIUSRISOTDIFFUCODYGNYIPSWEEBHGNWRZETXSVVMQTRBVFZMYHOHUCMLBUXBMPMSNCSHFZTAFUVTMQFGL\nTNICVANBEBOQASUEJJAOJXWNMDGAAVYNHRPSMKGMXZDJHCZHFHRRMIDWUOQCZSBKDPLSGHNHFKFYDRGVKXOLPOOWBPOWSDFLEJVX\n",
        "output": "SVVTUOKGAXUFFUCDPWBRZRVZMHHCNHTQ\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2164,
        "task_id": 3802,
        "test_case_id": 14,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "KEJHTOKHMKWTYSJEAJAXGADRHUKBCRHACSRDNSZIHTPQNLOSRKYBGYIIJDINTXRPMWSVMMBODAYPVVDDTIXGDIOMWUAKZVFKDAUM\nWTEVPIFAAJYIDTZSZKPPQKIOMHDZTKDMFVKSJRUFMNHZJPVSQYELWYAFACGGNRORSLGYVXAEYVLZBLDEHYDGOFDSWUYCXLXDKFSU\nTUZEQBWVBVTKETQ\n",
        "output": "EJTOKMKSJRUHZPQLYGNRSVAYVDDGDWUKFU\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2165,
        "task_id": 3802,
        "test_case_id": 15,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "EGQYYSKTFTURZNRDVIWBYXMRDGFWMYKFXGIFOGYJSXKDCJUAGZPVTYCHIXVFTVTCXMKHZFTXSMMQVFXZGKHCIYODDRZEYECDLKNG\nPEXXCTRFJAAKPOTBAEFRLDRZKORNMXHHXTLKMKCGPVPUOBELPLFQFXOBZWIVIQCHEJQPXKGSCQAWIMETCJVTAGXJIINTADDXJTKQ\nQURSEKPMSSEVQZI\n",
        "output": "EKTFRZNXMGFFXIJXKCATCVTXTDDK\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2166,
        "task_id": 3802,
        "test_case_id": 16,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ZFFBNYVXOZCJPSRAEACVPAUKVTCVZYQPHVENTKOCMHNIYYMIKKLNKHLWHHWAQMWFTSYEOQQFEYAAYGMPNZCRYBVNAQTDSLXZGBCG\nPIQHLNEWAMFAKGHBGZAWRWAXCSKUDZBDOCTXAHSVFZACXGFMDSYBYYDDNQNBEZCYCULSMMPBTQOJQNRPZTRCSDLIYPLVUGJPKDTG\nZBFJPLNAKWQBTUVJKMHVBATAM\n",
        "output": "FBZRACUZOCHAMSYYYNZCYBNTDLGG\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2167,
        "task_id": 3802,
        "test_case_id": 17,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "BTWZLIKDACZVLCKMVTIQHLFBNRCBDSWPFFKGPCQFPTOIJLPFCDMFGQKFHTDFFCCULUAYPXXIIIWBZIDMOPNHPZBEXLVARJFTBFOE\nMDXYKKWZVASJPPWRCYNMRAOBBLUNBSMQAPCPSFAGLXWJRBQTBRWXYNQGWECYNFIAJXDMUHIIMDFMSHLPIMYQXNRRUSSNXALGNWIK\nKNFVBVAOWXMZVUHAVUDKDBUVAKNHACZBGBHMUOPHWGQSDFXLHB\n",
        "output": "WZACLMQLBRWGCFIJDMHDFLPIMNXL\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2168,
        "task_id": 3802,
        "test_case_id": 18,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "GOZVMIRQIGYGVAGOREQTXFXPEZYOJOXPNDGAESICXHMKQDXQPRLMRVWHXFEJVCWZDLYMQLDURUXZPTLEHPTSKXGSNEQDKLVFFLDX\nIMEVFCZXACKRRJVXDRKFWTLTRTLQQDHEBZLCOCNVPABQMIWJHRLKFUKWOVVWGGNWCJNRYOYOAJFQWCLHQIQRBZTVWKBFOXKEHHQP\nSZ\n",
        "output": "MVARXFEZOPAIHRLVWFCLQRZTKXEQ\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2169,
        "task_id": 3802,
        "test_case_id": 19,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "BBYUVCIYLNUJPSEYCAAPQSDNSDDTNEHQZDPBEKQAWNAKEYFBNEEBGPDPRLCSVOWYDEDRPPEDOROCHRCNQUSPNVXGRXHNLKDETWQC\nBQCQXCAHADGJHBYIKEUWNXFUOOTVCCKJPJJCMWLAWWKSDGHFNZTCPSQNRTPCBLXDTSJLRHSCCZXQXCVLVGTROOUCUQASIQHZGNEI\nRYE\n",
        "output": "BBYUVCJPCASDNTPQNBDRLVROOCQSGNE\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2170,
        "task_id": 3802,
        "test_case_id": 20,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "WZRKLETJRBBRZKGHEFBVEFVLIERBPSEGJVSNUZUICONWWBOOTHCOJLLZFNOCNOFJQZTZWBLKHGIWWWPBUYWBAHYJGEBJZJDTNBGN\nZINFGDCNKHYFZYYWHTIHZTKWXXXMSWOVOPQDTRWSQKBWWCPEMYFVGARELELBLGEVJCMOCFTTUVCYUQUSFONAMWKVDWMGXVNZJBWH\nAFPA\n",
        "output": "WZKTRBEFVELEBEJCOTCFONWKWGZJB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2171,
        "task_id": 3802,
        "test_case_id": 21,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABABABB\nABABABB\nABABB\n",
        "output": "ABABAB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2172,
        "task_id": 3802,
        "test_case_id": 22,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABBB\nABBB\nABB\n",
        "output": "BBB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2173,
        "task_id": 3802,
        "test_case_id": 23,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "A\nBABAABAAABABABABABABAABABABABBABABABABAABBABBABAABABAABAABBAAAAAABBABABABABAABABAABABABABAABAABABABA\nB\n",
        "output": "A\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2174,
        "task_id": 3802,
        "test_case_id": 24,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABBAABAAABABAABAABABABABAABBBABABABAAABBABAAABABABABBABBABABAABABABABABABBABAABABAABABABAAABBABABABA\nA\nB\n",
        "output": "A\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2175,
        "task_id": 3802,
        "test_case_id": 25,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABBBABABABABABBABAABAAABABAABABABABBABAAAABABABBABAABABAAABAABBAAABAABABBABBABABBABAABABABAAAAABABAB\nB\nBABBABAABABABABABABABABABBAABABBABABBAAABAAABABBAABAABBABABBABABAABBABAABABBAABAABAABABABABABBABABAB\n",
        "output": "B\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2176,
        "task_id": 3802,
        "test_case_id": 26,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "AABABAABAAABABAAABAAAABBAAABABAAABABAABAABAAAABAABAAAABAAAABAAAABBAABAAAAABAAAAABABAAAAAABABAABAAAAA\nABAABABABAAABABAABABBAABAABAABABAABABAAABBAABAAAABABABAAAAABAAAAABABABABAABAABAABAABABAABABAABAABAAB\nBABAAABABBAABABAABAA\n",
        "output": "ABAABABABAAABAAAABBAABAAAABABAABABAAABAABAAAABAAAAAAABAAAAAAABAAAAABAAAAAAABABAABAAAA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2177,
        "task_id": 3802,
        "test_case_id": 27,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "AABABABABAAAABBAAAABABABABAAAAABABAAAA\nAABABAAABABABAAABAAAAABAAABAAABABABBBABBAAABAABAAAAABABBABAAABAABAABABAAAABABAAABAAABAABABBBABBABABA\nAAAAA\n",
        "output": "AABABABABAAAABBAAAABABABABAAAABABAAAA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2178,
        "task_id": 3802,
        "test_case_id": 28,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ZZXXAAZZAXAAZZAZZXXAAZZAXAXZZXXAAZZZZXXAZZXXAAAZZXXAAAZZXXZZXXXAAAZZXZZXXAZZXXZXXAAXAAZZZXXAXAXAZZXZ\nAZZXXAAZZXXAAXZXXAZZXAZZXZZXXAAZZXXAAZAAZZAAZZXXAA\nAAZZXAAXXAAAZZXXAZZXXAAZZXXAAAZZXXZ\n",
        "output": "ZZXXAAZZXXAAXZXXAZZXAZZXZZXXAAZZXXAAZAZZAAZZXXAA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2179,
        "task_id": 3802,
        "test_case_id": 29,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "SDASSDADASDASDASDSDADASASDAAASDASDDASDDASDADASDASDSSDASDD\nSDASDASDDASDASDASDSDSDASDASDASDASDASDASDASDADASDASDASDSDASDASDDDASSD\nSDASDSDDAA\n",
        "output": "SDASSDADASDASDSDSDADASASDAAASDASDDASDDASDDASDASDDASD\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2180,
        "task_id": 3802,
        "test_case_id": 30,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "DASSDASDASDDAASDASDADASDASASDAS\nSDADASDASSDAASDASDASDADASSDDA\nSD\n",
        "output": "DADADADAADADADADASSA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2181,
        "task_id": 3802,
        "test_case_id": 31,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ASDASSDASDS\nDASDASDDDASDADASDASDASDASSDADASDDAASDA\nDSD\n",
        "output": "ASDASSDASDS\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2182,
        "task_id": 3802,
        "test_case_id": 32,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ASDASASDASDASDAASDASDASDASASDDAASDASSASDSDAD\nDASDASSSDASDASDASASDASSDAASDASSDDSASDASDAASDDAASDASDAASDASDDASDASDASDASDASS\nDASD\n",
        "output": "ASDASASDASASDAASDASASDASASDDAASDASSASDSDAD\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2183,
        "task_id": 3802,
        "test_case_id": 33,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "DASDSDASDADASDDDSDASSDDAASDA\nDASDDASDSDADSDASDADSDSDADDASDASDDASDASDASDSDASD\nDAASD\n",
        "output": "DASDSDASDADASDDDSDASSDDASDA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2184,
        "task_id": 3802,
        "test_case_id": 34,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABAAAABABADABAABAABCCABADABACABACABCABADABADABACABBACAADABACABABACABADABACABABA\nBACAACABABABACABCABADABAACABADABACABAA\nABBAB\n",
        "output": "BAAACABABABACABCABADABAACABADABACABAA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2185,
        "task_id": 3802,
        "test_case_id": 35,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABAABACABADAACADABACAAB\nBAACABADABACABAAAADADAABACABACABADABABADABACABAADABBADABACAAACAABACABADABBBAA\nDABACA\n",
        "output": "ABAABACABADAACADABAAAB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2186,
        "task_id": 3802,
        "test_case_id": 36,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "BACABACABAACABADABABACAABACABBACAACAACABCABADAACABAABAABBADABACABADABCABAD\nBACAABADABABADABACABABACABADABACABCBADABACADABCABABADAABA\nBADABAA\n",
        "output": "BACAABAAABADABACAABACABAAACABCBADAACADABCABADAABA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2187,
        "task_id": 3802,
        "test_case_id": 37,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ACABADABACABCABAAB\nBADAB\nACAACABA\n",
        "output": "BADAB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2188,
        "task_id": 3802,
        "test_case_id": 38,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABABAC\nABABAC\nABAC\n",
        "output": "ABABA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2189,
        "task_id": 3802,
        "test_case_id": 39,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "BCBCBC\nBCBCBC\nBC\n",
        "output": "CCB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2190,
        "task_id": 3802,
        "test_case_id": 40,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "AAACAAACAAADAAAAAAA\nAADAAAAAAAACDAAAAAAAAAAACAAAAABCACAAACAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADA\nAAACAADAAAAADD\n",
        "output": "AAACAAACAAAAAAAAAA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2191,
        "task_id": 3802,
        "test_case_id": 41,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABABBB\nABABBB\nABB\n",
        "output": "ABAB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2192,
        "task_id": 3802,
        "test_case_id": 42,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABABABAC\nABABABAC\nABABAC\n",
        "output": "ABABABA\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2193,
        "task_id": 3802,
        "test_case_id": 43,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "BBAABAAAAABBBBBBBABABAABAABAABBABABABBBABBABBABBBABAABBBBBBAABAAAAAAAAABABAAABBABBAAAAAABAABABBAAABB\nBBAABAAAAABBBBBBBABABAABAABAABBABABABBBABBABBABBBABAABBBBBBAABAAAAAAAAABABAAABBABBAAAAAABAABABBAAABB\nBBBAA\n",
        "output": "BBAABAAAAABBBBBBBABABAABAABAABBABABABBBABBABBABBBABAABBBBBBABAAAAAAAAABABAAABBABBAAAAAABAABABBAAABB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2194,
        "task_id": 3802,
        "test_case_id": 44,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABABC\nABABC\nABC\n",
        "output": "ABAB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2195,
        "task_id": 3802,
        "test_case_id": 45,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "BABBB\nBABBB\nABB\n",
        "output": "BBBB\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2196,
        "task_id": 3802,
        "test_case_id": 46,
        "question": "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.\n\nYou are given two strings s_1, s_2 and another string called virus. Your task is to find the longest common subsequence of s_1 and s_2, such that it doesn't contain virus as a substring.\n\n\n-----Input-----\n\nThe input contains three strings in three separate lines: s_1, s_2 and virus (1 ≤ |s_1|, |s_2|, |virus| ≤ 100). Each string consists only of uppercase English letters.\n\n\n-----Output-----\n\nOutput the longest common subsequence of s_1 and s_2 without virus as a substring. If there are multiple answers, any of them will be accepted. \n\nIf there is no valid common subsequence, output 0.\n\n\n-----Examples-----\nInput\nAJKEQSLOBSROFGZ\nOVGURWZLWVLUXTH\nOZ\n\nOutput\nORZ\n\nInput\nAA\nA\nA\n\nOutput\n0",
        "solutions": "[\"# coding=utf-8\\nfrom functools import reduce\\n\\na = input()\\nb = input()\\nc = input()\\n\\nalen = len(a)\\nblen = len(b)\\nclen = len(c)\\n\\nkmpnext = [0]*(clen+1)\\ni = 1\\nj = 0\\nwhile i < clen:\\n\\twhile j > 0 and c[i]!=c[j]:\\n\\t\\tj = kmpnext[j]\\n\\tif c[i] == c[j]:\\n\\t\\tj+=1\\n\\tkmpnext[i+1] = j\\n\\ti+=1\\n#print(kmpnext)\\n\\nf = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\ng = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\nh = [[[0 for i in range(clen+2)] for i in range(blen+2)] for i in range(alen+2)]\\n\\nf[0][0][0] = 0\\ng[0][0][0] = (-1,-1,-1)\\nh[0][0][0] = 1\\nm = (0,0,0)\\n\\nfor i in range(alen):\\n\\tfor j in range(blen):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif h[i][j][k] == 0:\\n\\t\\t\\t\\t#print(i,j,k)\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\tif f[i+1][j][k] < f[i][j][k] or h[i+1][j][0] == 0:\\n\\t\\t\\t\\tf[i+1][j][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i+1][j][k] = g[i][j][k]\\n\\t\\t\\t\\th[i+1][j][k] = 1\\n\\t\\t\\tif f[i][j+1][k] < f[i][j][k] or h[i][j+1][0] == 0:\\n\\t\\t\\t\\tf[i][j+1][k] = f[i][j][k]\\n\\t\\t\\t\\tg[i][j+1][k] = g[i][j][k]\\n\\t\\t\\t\\th[i][j+1][k] = 1\\n\\n\\t\\t\\tif a[i] == b[j]:\\n\\t\\t\\t\\t#print(i,j,a[i],b[j])\\n\\t\\t\\t\\tkt = k\\n\\t\\t\\t\\twhile kt != 0 and a[i] != c[kt]:\\n\\t\\t\\t\\t\\tkt = kmpnext[kt]\\n\\t\\t\\t\\tif a[i] == c[kt]:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][kt+1] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][kt+1] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][kt+1] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][kt+1] = 1\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tif f[i+1][j+1][0] < f[i][j][k] + 1:\\n\\t\\t\\t\\t\\t\\tf[i+1][j+1][0] = f[i][j][k] + 1\\n\\t\\t\\t\\t\\t\\tg[i+1][j+1][0] = (i,j,k)\\n\\t\\t\\t\\t\\t\\th[i+1][j+1][0] = 1\\n\\n\\t\\t\\t#print(i,j,k,f[i][j][k],g[i][j][k])\\n\\nfor i in range(alen+1):\\n\\tfor j in range(blen+1):\\n\\t\\tfor k in range(clen):\\n\\t\\t\\tif f[i][j][k] > f[m[0]][m[1]][m[2]]:\\n\\t\\t\\t\\tm = (i,j,k)\\nif f[m[0]][m[1]][m[2]] == 0:\\n\\tprint(0)\\nelse:\\n\\tans = \\\"\\\"\\n\\tt = m\\n\\tt = g[t[0]][t[1]][t[2]]\\n\\twhile t != (-1,-1,-1):\\n\\t\\tans = a[t[0]] + ans\\n\\t\\tt = g[t[0]][t[1]][t[2]]\\n\\tprint(ans)\\n\"]",
        "difficulty": "competition",
        "input": "ABCCCCCCCC\nABCCCCCCCC\nABC\n",
        "output": "BCCCCCCCC\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/346/B"
    },
    {
        "id": 2197,
        "task_id": 3836,
        "test_case_id": 1,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n",
        "output": "22\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2198,
        "task_id": 3836,
        "test_case_id": 2,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "5\n11 1\n01 1\n00 100\n10 1\n01 1\n",
        "output": "103\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2199,
        "task_id": 3836,
        "test_case_id": 3,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n",
        "output": "105\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2200,
        "task_id": 3836,
        "test_case_id": 4,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "3\n00 5000\n00 5000\n00 5000\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2201,
        "task_id": 3836,
        "test_case_id": 5,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "1\n00 1\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2202,
        "task_id": 3836,
        "test_case_id": 6,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "1\n00 4\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2203,
        "task_id": 3836,
        "test_case_id": 7,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "1\n11 15\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2204,
        "task_id": 3836,
        "test_case_id": 8,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "2\n00 1\n10 1\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2205,
        "task_id": 3836,
        "test_case_id": 9,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "2\n00 2\n11 1\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2206,
        "task_id": 3836,
        "test_case_id": 10,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "2\n01 13\n11 3\n",
        "output": "16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2207,
        "task_id": 3836,
        "test_case_id": 11,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "3\n11 1\n00 1\n00 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2208,
        "task_id": 3836,
        "test_case_id": 12,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "3\n10 4\n00 1\n01 3\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2209,
        "task_id": 3836,
        "test_case_id": 13,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "3\n01 11\n10 15\n11 10\n",
        "output": "36\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2210,
        "task_id": 3836,
        "test_case_id": 14,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "4\n11 1\n00 1\n11 1\n00 1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2211,
        "task_id": 3836,
        "test_case_id": 15,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "4\n10 3\n10 4\n01 3\n11 3\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2212,
        "task_id": 3836,
        "test_case_id": 16,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "4\n00 10\n00 3\n00 16\n00 13\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2213,
        "task_id": 3836,
        "test_case_id": 17,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "5\n01 1\n01 1\n10 1\n10 1\n01 1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2214,
        "task_id": 3836,
        "test_case_id": 18,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "5\n11 1\n01 1\n10 2\n01 2\n00 1\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2215,
        "task_id": 3836,
        "test_case_id": 19,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "5\n11 12\n10 16\n11 16\n00 15\n11 15\n",
        "output": "74\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2216,
        "task_id": 3836,
        "test_case_id": 20,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "6\n11 1\n00 1\n00 1\n00 1\n00 1\n00 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2217,
        "task_id": 3836,
        "test_case_id": 21,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "6\n10 1\n01 1\n00 2\n10 1\n01 2\n01 2\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2218,
        "task_id": 3836,
        "test_case_id": 22,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "6\n00 3\n11 7\n00 6\n00 1\n01 4\n11 4\n",
        "output": "21\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2219,
        "task_id": 3836,
        "test_case_id": 23,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "7\n10 1\n01 1\n10 1\n01 1\n01 1\n00 1\n01 1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2220,
        "task_id": 3836,
        "test_case_id": 24,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "7\n11 3\n10 4\n11 3\n10 3\n00 2\n10 3\n00 2\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2221,
        "task_id": 3836,
        "test_case_id": 25,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "7\n10 2\n11 6\n11 8\n00 2\n11 2\n01 2\n00 2\n",
        "output": "24\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2222,
        "task_id": 3836,
        "test_case_id": 26,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "8\n10 1\n11 1\n00 1\n10 1\n11 1\n11 1\n11 1\n01 1\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2223,
        "task_id": 3836,
        "test_case_id": 27,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "8\n01 4\n11 4\n11 4\n01 3\n01 3\n11 3\n01 4\n01 4\n",
        "output": "23\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2224,
        "task_id": 3836,
        "test_case_id": 28,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "8\n00 4\n00 8\n01 4\n01 7\n11 1\n10 5\n11 8\n10 3\n",
        "output": "40\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2225,
        "task_id": 3836,
        "test_case_id": 29,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "9\n10 1\n10 1\n10 1\n11 1\n00 1\n11 1\n10 1\n11 1\n00 1\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2226,
        "task_id": 3836,
        "test_case_id": 30,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "9\n00 3\n01 4\n10 2\n10 4\n01 4\n01 2\n01 2\n10 4\n01 2\n",
        "output": "20\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2227,
        "task_id": 3836,
        "test_case_id": 31,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "9\n10 10\n00 16\n00 16\n01 5\n00 14\n10 13\n00 13\n00 15\n10 6\n",
        "output": "18\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2228,
        "task_id": 3836,
        "test_case_id": 32,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "10\n11 1\n11 1\n11 1\n11 1\n11 1\n11 1\n11 1\n11 1\n11 1\n11 1\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2229,
        "task_id": 3836,
        "test_case_id": 33,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "10\n11 4\n11 3\n11 4\n11 2\n01 4\n01 3\n00 4\n00 4\n10 3\n11 2\n",
        "output": "33\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2230,
        "task_id": 3836,
        "test_case_id": 34,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "10\n00 2\n00 2\n11 1\n00 2\n01 12\n10 16\n10 7\n10 3\n10 12\n00 12\n",
        "output": "41\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2231,
        "task_id": 3836,
        "test_case_id": 35,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "7\n10 60\n11 41\n11 32\n00 7\n00 45\n10 40\n00 59\n",
        "output": "192\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2232,
        "task_id": 3836,
        "test_case_id": 37,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "1\n00 5000\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2233,
        "task_id": 3836,
        "test_case_id": 38,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "1\n01 1\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2234,
        "task_id": 3836,
        "test_case_id": 39,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "1\n10 5000\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2235,
        "task_id": 3836,
        "test_case_id": 40,
        "question": "Elections in Berland are coming. There are only two candidates — Alice and Bob.\n\nThe main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:  supporting none of candidates (this kind is denoted as \"00\"),  supporting Alice but not Bob (this kind is denoted as \"10\"),  supporting Bob but not Alice (this kind is denoted as \"01\"),  supporting both candidates (this kind is denoted as \"11\"). \n\nThe direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:  at least half of spectators support Alice (i.e. $2 \\cdot a \\ge m$, where $a$ is number of spectators supporting Alice and $m$ is the total number of spectators),  at least half of spectators support Bob (i.e. $2 \\cdot b \\ge m$, where $b$ is number of spectators supporting Bob and $m$ is the total number of spectators),  the total influence of spectators is maximal possible. \n\nHelp the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.\n\n\n-----Input-----\n\nThe first line contains integer $n$ ($1 \\le n \\le 4\\cdot10^5$) — the number of people who want to take part in the debate as a spectator.\n\nThese people are described on the next $n$ lines. Each line describes a single person and contains the string $s_i$ and integer $a_i$ separated by space ($1 \\le a_i \\le 5000$), where $s_i$ denotes person's political views (possible values — \"00\", \"10\", \"01\", \"11\") and $a_i$ — the influence of the $i$-th person.\n\n\n-----Output-----\n\nPrint a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.\n\n\n-----Examples-----\nInput\n6\n11 6\n10 4\n01 3\n00 3\n00 7\n00 9\n\nOutput\n22\n\nInput\n5\n11 1\n01 1\n00 100\n10 1\n01 1\n\nOutput\n103\n\nInput\n6\n11 19\n10 22\n00 18\n00 29\n11 29\n10 28\n\nOutput\n105\n\nInput\n3\n00 5000\n00 5000\n00 5000\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example $4$ spectators can be invited to maximize total influence: $1$, $2$, $3$ and $6$. Their political views are: \"11\", \"10\", \"01\" and \"00\". So in total $2$ out of $4$ spectators support Alice and $2$ out of $4$ spectators support Bob. The total influence is $6+4+3+9=22$.\n\nIn the second example the direction can select all the people except the $5$-th person.\n\nIn the third example the direction can select people with indices: $1$, $4$, $5$ and $6$.\n\nIn the fourth example it is impossible to select any non-empty set of spectators.",
        "solutions": "[\"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import math as ma\\nimport sys\\nfrom decimal import Decimal as dec\\nfrom itertools import permutations\\n\\ndef li():\\n\\treturn list(map(int , input().split()))\\n\\ndef num():\\n\\treturn list(map(int , input().split()))\\n\\ndef nu():\\n\\treturn int(input())\\n\\ndef find_gcd(x , y):\\n\\twhile (y):\\n\\t\\tx , y = y , x % y\\n\\treturn x\\n\\nn=nu()\\nal=[]\\nbo=[]\\nto=[]\\nze=[]\\nfor i in range(n):\\n\\tx,y=input().split()\\n\\tif(x==\\\"00\\\"):\\n\\t\\tze.append(int(y))\\n\\tif(x==\\\"11\\\"):\\n\\t\\tto.append(int(y))\\n\\tif (x == \\\"10\\\"):\\n\\t\\tal.append(int(y))\\n\\tif (x == \\\"01\\\"):\\n\\t\\tbo.append(int(y))\\nal.sort(reverse=True)\\nbo.sort(reverse=True)\\nto.sort(reverse=True)\\nze.sort(reverse=True)\\nzz=0\\nif(len(al)<=len(bo)):\\n\\tzz=sum(al)+sum(bo[0:len(al)])\\n\\tgh=bo[len(al):]+ze\\n\\tzz=zz+sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc=0\\n\\tfor i in range(len(gh)):\\n\\t\\tif(cc==len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz+=gh[i]\\n\\t\\tcc+=1\\n\\tprint(zz)\\nelse:\\n\\tzz = sum(bo) + sum(al[0:len(bo)])\\n\\tgh = al[len(bo):] + ze\\n\\tzz = zz + sum(to)\\n\\tgh.sort(reverse=True)\\n\\tcc = 0\\n\\tfor i in range(len(gh)):\\n\\t\\tif (cc == len(to)):\\n\\t\\t\\tbreak\\n\\t\\tzz += gh[i]\\n\\t\\tcc += 1\\n\\tprint(zz)\\n\", \"def fun(c):\\n\\treturn c[0];\\n\\ndef f(a,b,alice,bob,un,n,check):\\n\\tinf = 0;\\n\\tif n-a <= a:\\n\\t\\tinf = 0;\\n\\t\\tfor i in range(n):\\n\\t\\t\\tinf += int(inp[i][1]);\\n\\telse:\\n\\t\\t#print(\\\"alice\\\")\\n\\t\\t#print(*alice)\\n\\t\\t#print(\\\"bob\\\")\\n\\t\\t#print(*bob);\\n\\t\\t#print(\\\"un\\\")\\n\\t\\t#print(*un)\\n\\n\\t\\t#print(\\\"H\\\")\\n\\t\\ttempb = 0;\\n\\t\\tj=0;\\n\\t\\tfor i in range(a):\\n\\t\\t\\tinf += alice[i][0];\\n\\t\\t\\td[alice[i][1]] = 1;\\n\\t\\t\\tif who[alice[i][1]][check]==\\\"1\\\":\\n\\t\\t\\t\\ttempb+=1;\\n\\t\\t\\tj+=1;\\n\\t\\ti=0;\\n\\t\\t#print(\\\"inf\\\",inf,\\\"j\\\",j,\\\"tempb\\\",tempb)\\n\\t\\t#print(\\\"d\\\",d)\\n\\t\\twhile(i<b and tempb < a):\\n\\t\\t\\tif d[bob[i][1]]==0:\\n\\t\\t\\t\\t#(bob[i])\\n\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\ttempb+=1\\n\\t\\t\\t\\tj+=1;\\n\\t\\t\\ti+=1;\\n\\t\\t#print(inf,j)\\n\\t\\tif j < 2*a:\\n\\t\\t\\tk = 0;\\n\\t\\t\\tunn = len(un);\\n\\t\\t\\t#print(i)\\n\\t\\t\\twhile( j < 2*a and i < b and k < unn):\\n\\t\\t\\t\\tif ( i < b and k <unn):\\n\\t\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t#print(bob[i][0],un[k][0])\\n\\t\\t\\t\\t\\t\\tif (bob[i][0] > un[k][0]):\\n\\t\\t\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\t\\n\\t\\t\\twhile(j<2*a and i<b):\\n\\t\\t\\t\\tif (d[bob[i][1]]==1):\\n\\t\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\telse:\\n\\t\\t\\t\\t\\tinf+=bob[i][0];\\n\\t\\t\\t\\t\\ti+=1;\\n\\t\\t\\t\\t\\tj+=1;\\n\\t\\t\\twhile(j<2*a and k<unn):\\n\\t\\t\\t\\tinf+=un[k][0];\\n\\t\\t\\t\\tk+=1;\\n\\t\\t\\t\\tj+=1;\\n\\tprint(inf);\\n\\nn = int(input())\\nd= {};\\nwho = {};\\ninp = [];\\na = 0;\\nb = 0;\\nalice = [];\\nbob = [];\\nun = [];\\nfor i in range(n):\\n\\tt = input().split();\\n\\tif t[0][0] ==\\\"1\\\":\\n\\t\\ta += 1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\td[i] = 0;\\n\\t\\talice.append(temp)\\n\\tif t[0][1] ==\\\"1\\\":\\n\\t\\tb+=1;\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tbob.append(temp)\\n\\t\\td[i]=0;\\n\\tif t[0][1] == t[0][0] and t[0][0]==\\\"0\\\":\\n\\t\\ttemp = [int(t[1]),i];\\n\\t\\tun.append(temp);\\n\\twho[i] = t[0];\\n\\tinp.append(t)\\n\\nalice.sort(key=fun,reverse=True);\\nbob.sort(key=fun,reverse=True);\\nun.sort(key=fun,reverse=True);\\n#print(*alice);\\n#print(*bob);\\n#print(*un)\\ninf = 0;\\n\\nif a < b:\\n\\tf(a,b,alice,bob,un,n,1);\\nelse:\\n\\t#print(\\\"YO\\\")\\n\\tf(b,a,bob,alice,un,n,0);\\n\\n\\n\\n\\n\\n\\n\\n\", \"n=int(input())\\nsu0=[]\\nsu1=[]\\nsu00=[]\\nsu11=[]\\nans=0\\nfor i in range(n):\\n\\tsup,val=map(int,input().split())\\n\\tif(sup==00):\\n\\t\\tsu00.append(val)\\n\\telif(sup==11):\\n\\t\\tsu11.append(val)\\n\\telif(sup==1):\\n\\t\\tsu0.append(val)\\n\\telse:\\n\\t\\tsu1.append(val)\\nsu0.sort()\\nsu1.sort()\\nsu11.sort()\\nsu00.sort()\\nwhile(len(su1)!=0 and len(su0)!=0):\\n\\tans+=su1[len(su1)-1]+su0[len(su0)-1]\\n\\tsu1.pop()\\n\\tsu0.pop()\\nwhile(len(su11)!=0 and len(su00)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tif(su00[len(su00)-1]>su0[len(su0)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tif(su00[len(su00)-1]>su1[len(su1)-1]):\\n\\t\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu00.pop()\\n\\t\\telse:\\n\\t\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\t\\tsu11.pop()\\n\\t\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]+su00[len(su00)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu00.pop()\\nwhile(len(su11)!=0):\\n\\tif(len(su1)!=0):\\n\\t\\tk=1\\n\\telif(len(su0)!=0):\\n\\t\\tk=0\\n\\telse:\\n\\t\\tk=2\\n\\tif(k==0):\\n\\t\\tans+=su11[len(su11)-1]+su0[len(su0)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu0.pop()\\n\\telif(k==1):\\n\\t\\tans+=su11[len(su11)-1]+su1[len(su1)-1]\\n\\t\\tsu11.pop()\\n\\t\\tsu1.pop()\\n\\telse:\\n\\t\\tans+=su11[len(su11)-1]\\n\\t\\tsu11.pop()\\nprint(ans)\", \"from math import *\\nn=int(input())\\narr=[]\\ncount1=0\\ncount2=0\\nans=0\\nfor i in range(n):\\n    a,b=map(str,input().split())\\n    b=int(b)\\n    arr.append((b,a))\\n    if(arr[i][1]=='10'):\\n        count1+=1\\n    elif(arr[i][1]=='01'):\\n        count2+=1\\n    elif(arr[i][1]=='11'):\\n        count1+=1\\n        count2+=1\\n    ans+=arr[i][0]\\narr.sort(reverse=True)\\ni=n-1\\nflag=0\\nsize=n\\nminval=min(count1,count2)\\nwhile(i>=0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    if(arr[i][1]=='00'):\\n        ans-=arr[i][0]\\n        size-=1\\n    elif(arr[i][1]=='10'):\\n        if(count1>minval):\\n            ans-=arr[i][0]\\n            count1-=1\\n            size-=1\\n    elif(arr[i][1]=='01'):\\n        if(count2>minval):\\n            ans-=arr[i][0]\\n            count2-=1\\n            size-=1\\n    #print(size,count1,count2,ans)\\n    i-=1\\nif(i==0 and (count1<ceil(size/2) or count2<ceil(size/2))):\\n    print(0)\\nelse:\\n    print(ans)\", \"\\nn = int(input())\\n#00 = 0, 01 = 1, 10 = 2, 11 = 3\\ntonumber = {'00':0, '01':1, '10':2, '11':3}\\npeople = [[], [], [], []]\\nfor i in range(n):\\n    s, a = input().split()\\n    s, a = tonumber[s], int(a)\\n    people[s].append(a)\\npeople[0].sort(reverse = True)\\npeople[1].sort(reverse = True)\\npeople[2].sort(reverse = True)\\n#print(people)\\ntotalInfluence = sum(people[3])\\ntotalPeople = len(people[3])\\nsupport = [len(people[3]), len(people[3])]\\nminLen = min(len(people[1]), len(people[2]))\\nfor i in range(minLen):\\n    totalInfluence += people[1][i] + people[2][i]\\n    totalPeople += 2\\n    support[0] += 1\\n    support[1] += 1\\nlonger = 0\\nlongerIndex = 2\\nif minLen == len(people[1]):\\n    longer = 0\\n    longerIndex = 2\\nelse:\\n    longer = 1\\n    longerIndex = 1\\nindices = [0, minLen]\\nallEmpty = [len(people[0]), len(people[longerIndex])]\\n#print(longer, longerIndex, minLen, indices, allEmpty)\\nwhile indices != allEmpty:\\n    top = [-1, -1]\\n    if indices[0] != allEmpty[0]:\\n       top[0] = people[0][indices[0]]\\n    if indices[1] != allEmpty[1]:\\n       top[1] = people[longerIndex][indices[1]]\\n    if top[0] > top[1]:\\n        if support[longer] >= (totalPeople + 1) / 2 and support[not longer] >= (totalPeople + 1) / 2:\\n            #print(str(support[longer]) + ' ' +  str((totalPeople + 1) / 2) + ';' + str(support[not longer]) + ' ' +  str((totalPeople + 1) / 2))\\n            totalInfluence += top[0]\\n            totalPeople += 1\\n            indices[0] += 1\\n        else:\\n            indices[0] += 1\\n    else:\\n        if support[not longer] >= (totalPeople + 1) / 2:\\n            totalInfluence += top[1]\\n            totalPeople += 1\\n            support[longer] += 1\\n            indices[1] += 1\\n        else:\\n            indices[1] += 1\\n    #print(top, support, totalInfluence, totalPeople)\\n\\nif totalPeople != 0:\\n    print(totalInfluence)\\nelse:\\n    print(0)\\n\", \"from math import ceil\\nn, A = int(input()), []\\na = b = ab = ab_ = ans = 0\\nfor _ in range(n):\\n    t, tt = input().split()\\n    tt = int(tt)\\n    if t != '11':\\n        A.append([t, tt])\\n        if t == '10':\\n            a += 1\\n        elif t == '01':\\n            b += 1\\n        else:\\n            ab_ += 1\\n    else:\\n        ans += tt\\n        ab += 1\\nA.sort(reverse=True, key=lambda x: x[1])\\nx = y = t = ttt = ab\\nk, j = a, b\\nfor i in A:\\n    if i[0] == '10' and (j or ttt):\\n        ans += i[1]\\n        t += 1\\n        x += 1\\n        if j == 0 and ttt:\\n            ttt -= 1\\n            j = 1\\n        j -= 1\\n    elif i[0] == '01' and (k or ttt):\\n        ans += i[1]\\n        t += 1\\n        y += 1\\n        if k == 0 and ttt:\\n            ttt -= 1\\n            k = 1\\n        k -= 1\\n    elif i[0] == '00' and ttt:\\n        ans += i[1]\\n        ttt -= 1\\n        t += 1\\nprint(ans)\\n\", \"n=int(input())\\na=[[] for i in range(4)]\\n\\nfor i in range(n):\\n    s,influence=[i for i in input().split() ]\\n    a[int(s,2)].append(int(influence))\\n\\nfor i in range(4):\\n    a[i].sort(reverse=True)\\ndef check():\\n    x=len(a[1])\\n    y=len(a[2])\\n    xy=len(a[3])\\n    z=len(a[0])\\n\\n    if(xy+y==0 or xy+x==0 ):\\n        print(0)\\n        return\\n\\n    w=min(x,y)\\n    sum0=0\\n    sum0+=sum(a[1][:w])+sum(a[2][:w])+sum(a[3])\\n    choose = 2\\n    if x >= y:\\n        choose = 1\\n    num=0\\n    i=w\\n    j=0\\n    while(i<max(x,y) and j<z and num<xy):\\n        if(a[choose][i]>=a[0][j]):\\n            sum0+=a[choose][i]\\n            i+=1\\n        else:\\n            sum0 += a[0][j]\\n            j += 1\\n        num+=1\\n\\n    while(i<max(x,y) and num<xy):\\n        sum0 += a[choose][i]\\n        i += 1\\n        num+=1\\n\\n    while (j < z and num < xy):\\n        sum0 += a[0][j]\\n        j += 1\\n        num += 1\\n    print(sum0)\\n\\ncheck()\\n\\n\\n\\n\\n\", \"from collections import defaultdict\\nc = defaultdict(int)\\nm = defaultdict(list)\\nn = int(input())\\nfor i in range(n):\\n    s,a = input().split()\\n    m[s].append(int(a))\\n    c[s]+=1\\nali = c['10']\\nbob = c['01']\\nco = c['11']\\nno = c['00']\\n\\nif(ali==0 or bob==0) and (co==0):\\n    print(0)\\nelse:\\n    if(ali>bob):\\n        ali-=(ali-bob)\\n    else:\\n        bob-=(bob-ali)\\n    x = m['10']\\n    y = m['01']\\n    x.sort(reverse=True)\\n    y.sort(reverse=True)\\n    ans = sum(x[:ali])+sum(y[:ali])\\n    rem = x[ali:]+y[ali:]+m['00']\\n    tot = ali+bob\\n    if(co>0):\\n        ans+=sum(m['11'])\\n        tot+=co\\n        ali+=co\\n        bob+=co\\n    #print(ali,bob,tot)\\n    rem.sort(reverse=True)\\n    #print(rem)\\n    mn = min(ali,bob)\\n    re = max(2*mn-tot,0)\\n    #print(re)\\n    ans+=sum(rem[:re])\\n    print(ans)\\n    \\n\", \"#!/usr/bin/env python3\\n\\nimport collections\\nimport sys\\nimport traceback\\n\\nclass Input(object):\\n    def __init__(self):\\n        self.fh = sys.stdin\\n\\n    def next_line(self):\\n        while True:\\n            line = sys.stdin.readline()\\n            if line == '\\\\n':\\n                continue\\n            return line\\n\\n\\n    def next_line_ints(self):\\n        line = self.next_line()\\n        return [int(x) for x in line.split()]\\n\\n    def next_line_strs(self):\\n        line = self.next_line()\\n        return line.split()\\n\\n\\ndef get_max_influence(influence):\\n    for i in range(4):\\n        influence[i].sort(reverse=True)\\n        #print('influence[{}] = {}'.format(i, influence[i]))\\n    t = [0] * 4\\n    result = 0\\n    while t[1] < len(influence[1]) and t[2] < len(influence[2]):\\n        result += influence[1][t[1]] + influence[2][t[2]]\\n        t[1] += 1\\n        t[2] += 1\\n    while t[3] < len(influence[3]):\\n        best = 0\\n        best_id = -1\\n        for i in range(3):\\n            if t[i] < len(influence[i]) and influence[i][t[i]] > best:\\n                best = influence[i][t[i]]\\n                best_id = i\\n        result += influence[3][t[3]]\\n        t[3] += 1\\n        if best_id != -1:\\n            result += influence[best_id][t[best_id]]\\n            t[best_id] += 1\\n    return result\\n\\ndef main():\\n    input = Input()\\n    while True:\\n        try:\\n            nums = input.next_line_ints()\\n            if not nums:\\n                break\\n            n, = nums\\n            if n == -1:\\n                break\\n            influence = [[] for _ in range(4)]\\n            for _ in range(n):\\n                support, value = input.next_line_strs()\\n                influence[int(support, 2)].append(int(value))\\n                #print('influence = {}'.format(influence))\\n        except:\\n            print('read input failed')\\n        try:\\n            #print('influence = {}'.format(influence))\\n            max_value = get_max_influence(influence)\\n            print(\\\"{}\\\".format(max_value))\\n        except:\\n            traceback.print_exc(file=sys.stdout)\\n            print('get_min_dist failed')\\n\\nmain()\", \"n = int(input())\\na, b, c = [], [], []\\nans = 0\\nnum11 = 0\\nfor i in range(n):\\n    t, val = map(int, input().split())\\n    if t == 11:\\n        ans += val\\n        num11 += 1\\n        continue\\n    if t & 1: a.append(val)\\n    if t & 2: b.append(val)\\n    if not t: c.append(val)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\n\\nmin_num = min(len(a), len(b))\\nans += sum(a[:min_num]) + sum(b[:min_num])\\nt = a[min_num:] + b[min_num:] + c\\nt.sort(reverse=True)\\nans += sum(t[:2 * (min(len(a), len(b))+num11) - 2 * min_num - num11])\\nprint(ans)\", \"def __starting_point():\\n    n = int(input())\\n    supporters = {}\\n    supporters[0]=[]\\n    supporters[1]=[]\\n    supporters[10]=[]\\n    supporters[11]=[]\\n    for i in range(n):\\n        [x,y] = [int(x) for x in input().split()]\\n        supporters[x].append(y)\\n        #print(x,y)\\n\\n    for x in supporters:\\n        supporters[x].sort(reverse=True)\\n        #print(supporters[x])\\n\\n    t = 0\\n    res = 0\\n    x = len(supporters[11])\\n    y = len(supporters[10])\\n    z = len(supporters[1])\\n\\n    if y>z:\\n        t = min(x+y,z)\\n    else:\\n        t = min(x+z,y)\\n    k = 0\\n    for val in supporters[11]:\\n        res += val \\n        k+=1\\n\\n    for i in range(y):\\n        if i>=t:\\n            supporters[0].append(supporters[10][i])\\n            \\n        else:    \\n            res += supporters[10][i]\\n            k+=1\\n    for i in range(z):\\n        if i>=t:\\n            supporters[0].append(supporters[1][i])\\n            \\n        else:    \\n            res += supporters[1][i]\\n            k+=1\\n\\n    supporters[0].sort(reverse=True)\\n    t = min(x+y,x+z)\\n    i = 0\\n    #print(res)\\n    while 2*t > k and i<len(supporters[0]):\\n        k+=1\\n        #print(supporters[0][i])\\n        res += supporters[0][i]\\n        i+=1\\n\\n    print(res)     \\n\\n__starting_point()\", \"#!usr/bin/python\\n\\nn = int(input());\\ns = [[], [], [], []];\\n\\nfor i in range(n):\\n\\tx = input().strip().split();\\n\\tif x[0] == \\\"11\\\":\\n\\t\\ts[3].append(int(x[1]));\\n\\telif x[0] == \\\"10\\\":\\n\\t\\ts[2].append(int(x[1]));\\n\\telif x[0] == \\\"01\\\":\\n\\t\\ts[1].append(int(x[1]));\\n\\telse:\\n\\t\\ts[0].append(int(x[1]));\\n\\nans = 0;\\nfor i in range(len(s[3])):\\n\\tans = ans + s[3][i];\\ns[2] = sorted(s[2], reverse = True);\\ns[1] = sorted(s[1], reverse = True);\\ntlen = min(len(s[1]),len(s[2]));\\n\\nfor i in range(1, 3):\\n\\tfor j in range(tlen):\\n\\t\\tans = ans + s[i][j];\\n\\tfor j in range(tlen,len(s[i])):\\n\\t\\ts[0].append(s[i][j]);\\n\\ns[0] = sorted(s[0], reverse = True);\\ntlen = min(len(s[3]),len(s[0]));\\nfor i in range(tlen):\\n\\tans = ans + s[0][i];\\n\\nprint(ans);\\n\\n\\n\\n\\n\\n\\n\\n\", \"# -*- coding:utf-8 -*-\\n\\n\\\"\\\"\\\"\\n\\ncreated by shuangquan.huang at 11/3/18\\n\\n\\\"\\\"\\\"\\n\\n\\n\\nN = int(input())\\n\\nA = [[] for _ in range(4)]\\na, b, c, d = A\\nfor ni in range(N):\\n    v, f = input().split()\\n    A[int(v, 2)].append(int(f))\\n\\n\\nfor i in range(len(A)):\\n    A[i].sort(reverse= True)\\n    \\n    \\n# all people '11' supports both will be selected\\nans = sum(A[3] or [0])\\n\\n# select equal number of '01' or '10'\\n\\nsingle = min(len(A[1]), len(A[2]))\\n\\nans += sum(A[1][:single]or [0])\\nans += sum(A[2][:single] or [0])\\n\\nx = len(A[3]) + single\\n# select left '01' '10' or '00' make total people <= 2*x, current have 2*single + len(A[3])\\n# so at most select len(A[3]) more people\\n\\na = A[1][single:] + A[2][single:] + A[0]\\na.sort(reverse=True)\\nans += sum(a[: len(A[3])] or [0])\\n\\nprint(ans)\\n\\n    \\n\", \"def read():\\n    return []\\n\\n\\ndef main():\\n    n = int(input())\\n    d = [[], [], [], []]\\n\\n    for _ in range(n):\\n        key, influence = input().split()\\n        key = int(key, 2)\\n        d[key].append(int(influence))\\n\\n    for key in range(4):\\n        d[key].sort(reverse=True)\\n\\n    ans = sum(d[3])\\n    additional = len(d[3])\\n\\n    container = []\\n    if len(d[1]) < len(d[2]):\\n        container = d[2]\\n    elif len(d[1]) > len(d[2]):\\n        container = d[1]\\n    container_start = min(len(d[1]), len(d[2]))\\n    zeros_start = 0\\n\\n    for a1, a2 in zip(d[1], d[2]):\\n        ans += a1 + a2\\n\\n    while (container_start < len(container) or zeros_start < len(d[0])) and additional:\\n        t1, t2 = 0, 0\\n        if container_start < len(container):\\n            t1 = container[container_start]\\n        if zeros_start < len(d[0]):\\n            t2 = d[0][zeros_start]\\n        if t1 < t2:\\n            ans += t2\\n            zeros_start += 1\\n        elif t1 >= t2 and t1 != 0:\\n            ans += t1\\n            container_start += 1\\n        additional -= 1\\n\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nt_11=[]\\nt_10=[]\\nt_01=[]\\nt_00=[]\\nfor x in range(n):\\n    tmp=list(input().split())\\n    supp = str(tmp[0])\\n    m = int(tmp[1])\\n    t_tmp = [supp, m]\\n    if supp == '11':\\n        t_11.append(t_tmp)\\n    elif supp == '01':\\n        t_01.append(t_tmp)\\n    elif supp == '10':\\n        t_10.append(t_tmp)\\n    else:\\n        t_00.append(t_tmp)\\nt_00=sorted(t_00, key=lambda x: x[1])\\nt_10=sorted(t_10, key=lambda x: x[1])\\nt_01=sorted(t_01, key=lambda x: x[1])\\nt_11=sorted(t_11, key=lambda x: x[1])\\npop_a = 0\\npop_b = 0\\ntot_inf = 0\\npop_tot=0\\nl_t_11 = len(t_11)-1\\nfor x in range(l_t_11,-1,-1):\\n    pop_a+=1\\n    pop_b+=1\\n    pop_tot+=1\\n    tot_inf+=t_11[-1][1]\\n    del t_11[-1]\\nfor x in range(min(len(t_10),len(t_01))-1,-1,-1):\\n    pop_b+=1\\n    pop_a+=1\\n    pop_tot+=2\\n    tot_inf+=t_01[-1][1]+t_10[-1][1]\\n    del t_01[-1]\\n    del t_10[-1]\\ntmp_inf_1 = 0\\ntmp_inf_2 = 0\\ntmp_inf_3 = 0\\ntmp_t1 = []\\ntmp_t2 = []\\nif len(t_10)!=0:\\n    for x in t_10:\\n        tmp_t1.append(x)\\n    for x in t_00:\\n        tmp_t1.append(x)\\n    tmp_t1 = sorted(tmp_t1, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t1)==0 or pop_a*2==pop_tot or pop_b*2==pop_a or pop_b*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t1[-1][1]\\n        if tmp_t1[-1][0] == '10':\\n            pop_a+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t1[-1]\\n    print(tot_inf)\\nelif len(t_01)!=0:\\n    for x in t_01:\\n        tmp_t2.append(x)\\n    for x in t_00:\\n        tmp_t2.append(x)\\n    tmp_t2 = sorted(tmp_t2, key=lambda x: x[1])\\n    while True:\\n        if len(tmp_t2)==0 or pop_b*2==pop_tot or pop_a*2==pop_b or pop_a*2==pop_tot:\\n            break\\n        tot_inf+=tmp_t2[-1][1]\\n        if tmp_t2[-1][0] == '01':\\n            pop_b+=1\\n            pop_tot+=1\\n        else:\\n            pop_tot+=1\\n        del tmp_t2[-1]\\n    print(tot_inf)\\nelse:\\n    if len(t_00)==0:\\n        print(tot_inf)\\n        return\\n    else:\\n        while True:\\n            if len(t_00)==0 or pop_a*2==pop_tot or pop_b*2==pop_tot:\\n                break\\n            tot_inf+=t_00[-1][1]\\n            pop_tot+=1\\n            del t_00[-1]\\n        print(tot_inf)\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=0\\nans+=sum(d)\\nb.sort(reverse=True)\\nc.sort(reverse=True)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"import sys\\n\\na = []\\nb = []\\nc = []\\nd = []\\n\\ndef main():\\n\\t#sys.stdin = open('D:\\\\\\\\Sublime\\\\\\\\in.txt', 'r')\\n\\t#sys.stdout = open('D:\\\\\\\\Sublime\\\\\\\\out.txt', 'w')\\n\\n\\tn = int(sys.stdin.readline().strip('\\\\n'))\\n\\n\\tfor i in range(n):\\n\\t\\topt,num=[int(line) for line in sys.stdin.readline().strip('\\\\n').split()[:2]]\\n\\t\\tif opt==0:\\n\\t\\t\\ta.append(num)\\n\\t\\tif opt==10:\\n\\t\\t\\tb.append(num)\\n\\t\\tif opt==1:\\n\\t\\t\\tc.append(num)\\n\\t\\tif opt==11:\\n\\t\\t\\td.append(num)\\n\\n\\tres = sum(d)\\n\\n\\tb.sort(reverse = True)\\n\\tc.sort(reverse = True)\\n\\n\\tif len(b) > len(c):\\n\\t\\tres += sum(c) + sum(b[:len(c)])\\n\\t\\ta.extend(b[len(c):])\\n\\telse:\\n\\t\\tres += sum(b) + sum(c[:len(b)])\\n\\t\\ta.extend(c[len(b):])\\n\\n\\ta.sort(reverse = True)\\n\\tres += sum(a[:len(d)])\\n\\tprint(res)\\n\\ndef __starting_point():\\n\\tmain()\\n__starting_point()\", \"n=int(input())\\na=[];b=[];c=[];d=[]\\nfor i in range(n):\\n    opt,num=[int(x) for x in input().split()]\\n    if opt==0:\\n        a.append(num)\\n    if opt==10:\\n        b.append(num)\\n    if opt==1:\\n        c.append(num)\\n    if opt==11:\\n        d.append(num)\\nans=sum(d)\\nb.sort(reverse=True) # from the largest then choose: greedy\\nc.sort(reverse=True) # make sortings is O(nlogn)\\nif len(b)<len(c):\\n    ans+=sum(b)+sum(c[0:len(b)])\\n    a.extend(c[len(b):])\\nelse:\\n    ans+=sum(c)+sum(b[0:len(c)])\\n    a.extend(b[len(c):])\\na.sort(reverse=True)\\nans+=sum(a[0:len(d)])\\nprint(ans)\", \"n=int(input())\\nboth=[]\\na=[]\\nb=[]\\nneither=[]\\nfor i in range(n):\\n    c,d=map(int,input().split())\\n    if c==11:\\n        both.append(d)\\n    elif c==10:\\n        a.append(d)\\n    elif c==1:\\n        b.append(d)\\n    else:\\n        neither.append(d)\\ninf=sum(both)\\nlee=len(both)\\na.sort(reverse=True)\\nb.sort(reverse=True)\\nx=min(len(a),len(b))\\ninf+=sum(a[:x])+sum(b[:x])\\nneither+=a[x:]+b[x:]\\nneither.sort(reverse=True)\\nif len(neither)<lee:\\n    inf+=sum(neither)\\nelse:\\n    inf+=sum(neither[:lee])\\nprint(inf)\", \"from collections import defaultdict\\nN = int(input())\\nnum = 0\\ncnt = 0\\nrec = defaultdict(list)\\ncnt10 = 0\\ncnt01 = 0\\nfor i in range(N):\\n    a, b = input().split()\\n    if a == \\\"11\\\":\\n        num += int(b)\\n        cnt += 1\\n    elif a == \\\"01\\\":\\n        cnt01 += 1\\n        rec[a].append(int(b))\\n    elif a == \\\"10\\\":\\n        cnt10 += 1\\n        rec[a].append(int(b))\\n    else:\\n        rec[a].append(int(b))\\n\\nrec[\\\"10\\\"] = sorted(rec[\\\"10\\\"])\\nrec[\\\"01\\\"] = sorted(rec[\\\"01\\\"])\\n\\nfor i in range(min(cnt10, cnt01)):\\n    num += rec[\\\"10\\\"].pop()\\n    num += rec[\\\"01\\\"].pop()\\n\\nq = rec[\\\"10\\\"] + rec[\\\"01\\\"] + rec[\\\"00\\\"]\\nq = sorted(q, reverse=True)\\n\\nnum += sum(q[:cnt])\\n\\nprint(num)\", \"m=int(input())\\ndou=0\\nfir=[]\\nsec=[]\\nnon=[]\\nd,f,s,n=0,0,0,0\\nfor i in [0]*m:\\n    a,b=list(map(int,input().split()))\\n    if a==11:\\n        dou+=b\\n        d+=1\\n    elif a==1:\\n        sec.append(b)\\n        s+=1\\n    elif a==10:\\n        fir.append(b)\\n        f+=1\\n    else:\\n        non.append(b)\\n        n+=1\\nfir.sort(reverse=True)\\nsec.sort(reverse=True)\\nif not (d+f*s):\\n    print(0)\\n    quit()\\nelse:\\n    m=min(f,s)\\n    ans=dou+sum(fir[:m])+sum(sec[:m])\\n    non=non+fir[m:]+sec[m:]\\n    non.sort(reverse=True)\\n    print(ans+sum(non[:d]))\\n\\n\", \"n = int(input())\\nlis10=[]\\nlis01=[]\\nlis00=[]\\ninf=c11=c10=c01=c=c00=0\\nfor i in range(n):\\n    a , b = list(map(str,input().split()))\\n    if a=='11':\\n        inf+=int(b)\\n        c11+=1\\n    elif a=='10':\\n        c10+=1\\n        lis10.append(int(b))\\n    elif a=='01':\\n        c01+=1\\n        lis01.append(int(b))\\n    else:\\n        c00+=1\\n        lis00.append(int(b)) \\nlis10.sort(reverse=True)\\nlis01.sort(reverse=True)\\nc=min(c01,c10)\\nfor i in range(c):\\n    inf+=(lis10[i]+lis01[i])\\nlis00+=lis10[c:c10]+lis01[c:c01]    \\nlis00.sort(reverse=True)\\n#if len(lis00)<c11:\\n#    print(inf)\\n#else:    \\nfor i in range(min(c11,len(lis00))):\\n    inf+=lis00[i]\\nprint(inf)    \\n\", \"# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\\nfrom sys import stdin, stdout\\nfrom math import sqrt\\nimport math\\nimport heapq\\nfrom itertools import accumulate\\n\\nN = int(input())\\n\\nf = {}\\nf['00'] = []\\nf['10'] = []\\nf['01'] = []\\nf['11'] = []\\n\\nfor i in range(N):\\n    s = [x for x in stdin.readline().split()]\\n    f[s[0]].append(int(s[1]))\\n    \\nfor key in f:\\n    f[key].sort(reverse=True)\\n    \\n#print(f)\\n\\ns_X = sum(f['11'])\\n# X >= W\\nX = len(f['11'])\\nY = len(f['10'])\\nZ = len(f['01'])\\n\\nm = min(Y,Z)\\n\\n# calculate prefix of '10' and '01'\\ns_Y = [0]*len(f['10'])\\ns = 0\\nfor i in range(len(f['10'])):\\n    s += f['10'][i]\\n    s_Y[i] = s\\ns_Z = [0]*len(f['01'])\\ns = 0\\nfor i in range(len(f['01'])):\\n    s += f['01'][i]\\n    s_Z[i] = s\\n\\n# W = 0 to X\\nres = 0\\ns = 0\\nfor W in range(X+1):\\n    # abs(Y-Z) <= X-W\\n    if W>len(f['00']):\\n        break\\n    if W>=1:\\n        s += f['00'][W-1]\\n    \\n    bound = X-W\\n    if Y>Z:\\n        tmp_Y = min(Y,Z+bound)\\n        tmp_Z = Z\\n    elif Y==Z:\\n        tmp_Y = Y\\n        tmp_Z = Z\\n    elif Y<Z:\\n        tmp_Y = Y\\n        tmp_Z = min(Z,Y+bound)\\n    \\n    # X+W+Y+Z\\n    calculate = s_X + s\\n    if tmp_Y>0:\\n        calculate += s_Y[tmp_Y-1]\\n    if tmp_Z>0:\\n        calculate += s_Z[tmp_Z-1]\\n        \\n    res = max(res,calculate)\\n    #print(X,tmp_Y,tmp_Z,W,calculate)\\n    \\nprint(res)\\n            \\n\\n\\n    \\n\", \"n = int(input())\\n\\ninfluences = [[],[],[],[]]\\n\\nfor i in range(0,n):\\n    [support, influence] = [x for x in input().split()]\\n    support = int(support, 2)\\n    influences[support].append(int(influence))\\n\\nfor i in range(0,4):\\n    influences[i] = sorted(influences[i])\\n    influences[i].reverse()\\n\\ntotal_influence = 0\\ntotal_influence += sum(influences[3])\\n\\nmin_size = min(len(influences[2]),len(influences[1]))\\n\\ntotal_influence += sum(influences[1][:min_size]) + sum(influences[2][:min_size])\\n\\nsize = len(influences[3])\\n\\ninfluences[0] += influences[1][min_size:] + influences[2][min_size:]\\ninfluences[0] = sorted(influences[0])\\ninfluences[0].reverse()\\n\\ntotal_influence += sum(influences[0][:size])\\n\\nprint(total_influence)\"]",
        "difficulty": "competition",
        "input": "1\n11 5000\n",
        "output": "5000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1070/F"
    },
    {
        "id": 2236,
        "task_id": 3902,
        "test_case_id": 3,
        "question": "First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. \n\nFor example, you should know linguistics very well. You learn a structure of Reberland language as foreign language. In this language words are constructed according to the following rules. First you need to choose the \"root\" of the word — some string which has more than 4 letters. Then several strings with the length 2 or 3 symbols are appended to this word. The only restriction —  it is not allowed to append the same string twice in a row. All these strings are considered to be suffixes of the word (this time we use word \"suffix\" to describe a morpheme but not the few last characters of the string as you may used to). \n\nHere is one exercise that you have found in your task list. You are given the word s. Find all distinct strings with the length 2 or 3, which can be suffixes of this word according to the word constructing rules in Reberland language. \n\nTwo strings are considered distinct if they have different length or there is a position in which corresponding characters do not match. \n\nLet's look at the example: the word abacabaca is given. This word can be obtained in the following ways: [Image], where the root of the word is overlined, and suffixes are marked by \"corners\". Thus, the set of possible suffixes for this word is {aca, ba, ca}. \n\n\n-----Input-----\n\nThe only line contains a string s (5 ≤ |s| ≤ 10^4) consisting of lowercase English letters.\n\n\n-----Output-----\n\nOn the first line print integer k — a number of distinct possible suffixes. On the next k lines print suffixes. \n\nPrint suffixes in lexicographical (alphabetical) order. \n\n\n-----Examples-----\nInput\nabacabaca\n\nOutput\n3\naca\nba\nca\n\nInput\nabaca\n\nOutput\n0\n\n\n\n-----Note-----\n\nThe first test was analysed in the problem statement. \n\nIn the second example the length of the string equals 5. The length of the root equals 5, so no string can be used as a suffix.",
        "solutions": "[\"s = input()\\ns = s[5:]\\n\\nif len(s) < 2:\\n    print(0)\\nelif len(s) == 2:\\n    print(1)\\n    print(s)\\nelif len(s) == 3:\\n    print(2)\\n    for suff in sorted([s, s[-2:]]):\\n        print(suff)\\nelse:\\n    D = [[False for _ in range(2)] for _ in range(len(s))]\\n\\n    suffixes = { s[-2:], s[-3:] }\\n\\n    D[-2][0] = True\\n    D[-3][1] = True\\n\\n    for i in range(len(s) - 4, -1, -1):\\n        if (s[i:i+2] != s[i+2:i+4] and D[i+2][0]) or D[i+2][1]:\\n            D[i][0] = True\\n            suffixes |= { s[i:i+2] }\\n        if (i <= len(s) - 6 and s[i:i+3] != s[i+3:i+6] and D[i+3][1]) or D[i+3][0]:\\n            D[i][1] = True\\n            suffixes |= { s[i:i+3] }\\n\\n    print(len(suffixes))\\n    for suffix in sorted(suffixes):\\n        print(suffix)\\n\", \"__author__ = 'Utena'\\ns=input()\\nn=len(s)\\nans=set()\\nif n<=6:\\n    print(0)\\n    return\\ndp=[[False,False]for i in range(n+1)]\\nif n>7:\\n    dp[3][1]=True\\n    ans.add(s[-3:])\\ndp[2][0]=True\\nans.add(s[-2:])\\n\\nfor i in range(4,n-4):\\n    if s[(-i):(-i+2)]!=s[(-i+2):(-i+3)]+s[-i+3]and dp[i-2][0] or dp[i-2][1]:\\n        dp[i][0]=True\\n        ans|={s[(-i):(-i+2)]}\\n    if i>=6 and s[(-i):(-i+3)]!=s[(-i+3):(-i+5)]+s[-i+5]and dp[i-3][1] or dp[i-3][0]:\\n        dp[i][1]=True\\n        ans.add(s[(-i):(-i+3)])\\nans=sorted(list(ans))\\nprint(len(ans))\\nprint('\\\\n'.join(ans))\", \"from sys import *\\nsetrecursionlimit(20000)\\ndp = []\\nans = []\\ndef fun(s, pos, r, ln):\\n\\tif pos <= 4+ln:\\n\\t\\treturn 0\\n\\tif dp[pos][ln-2] != 0:\\n\\t\\treturn dp[pos][ln-2]\\n\\tif s[pos-ln:pos] != r:\\n\\t\\tdp[pos][ln-2] = 1 + fun(s, pos - ln, s[pos-ln:pos],2) + fun(s, pos - ln, s[pos-ln:pos],3)\\n\\t\\tans.append(s[pos-ln:pos])\\n\\t'''\\tif pos > 4+ln and s[pos-3:pos] != r:\\n\\t\\tdp[pos][1] = 1 + fun(s, pos - 3, s[pos-3:pos])\\n\\t\\tans.append(s[pos-3:pos])'''\\n\\treturn dp[pos][ln-2]\\n\\n\\ns = input()\\ndp = [[0, 0] for i in range(len(s) + 1)]\\nfun(s, len(s), '', 2)\\nfun(s, len(s), '', 3)\\nans = list(set(ans))\\nans.sort()\\nprint(len(ans))\\nfor i in ans:\\n\\tprint (i)\\n\", \"from sys import *\\nsetrecursionlimit(200000)\\nd = {}\\nt = set()\\ns = input() + ' '\\ndef gen(l, ll):\\n    if (l, ll) in t: return\\n    t.add((l, ll))\\n    if l > 6:\\n        d[s[l - 2 : l]] = 1\\n        if s[l - 2 : l] != s[l : ll]: gen(l - 2, l)\\n    if l > 7:\\n        d[s[l - 3 : l]] = 1\\n        if s[l - 3 : l] != s[l : ll]: gen(l - 3, l)\\ngen(len(s) - 1,len(s))\\nprint(len(d))\\nfor k in sorted(d): print(k)\\n\", \"def main():\\n    s = input()[5:]\\n    n = len(s)\\n    if n < 2:\\n        print(0)\\n        return\\n    res2, res3 = set(), set()\\n    dp2 = [False] * (n + 1)\\n    dp3 = [False] * (n + 1)\\n    dp2[-1] = dp3[-1] = True\\n    for i in range(n, 1, -1):\\n        if dp3[i] or dp2[i] and s[i - 2:i] != s[i:i + 2]:\\n            res2.add(s[i - 2:i])\\n            dp2[i - 2] = True\\n        if dp2[i] or dp3[i] and s[i - 3:i] != s[i:i + 3]:\\n            res3.add(s[i - 3:i])\\n            dp3[i - 3] = True\\n    res3.discard(s[i - 3:i])\\n    res3.update(res2)\\n    print(len(res3))\\n    for s in sorted(res3):\\n        print(s)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"s = input()\\nn = len(s)\\ndp2,dp3=[0 for i in range(n)],[0 for i in range(n)]\\nif(n<7): print(0)\\nelse:\\n    if n-2>4: dp2[n-2]=1\\n    if n-3>4: dp3[n-3]=1;\\n    #for(i=n-4;i>5;i--)\\n    i=n-4\\n    while i>=5:\\n        #print(\\\"i=%d\\\"% i)\\n        dp2[i]=(dp3[i+2] | (dp2[i+2] & (s[i:i+2]!=s[i+2:i+4]) ) )\\n        #if s[i:i+2]!=s[i+2:i+4] : t=1\\n        #else: t=0\\n        #print(\\\"%s  %s\\\" %(s[i:i+2],s[i+2:i+4]))\\n        dp3[i]=dp2[i+3] | (dp3[i+3] & (s[i:i+3]!=s[i+3:i+6]) )\\n        #print(s[i:i+3]+s[i+3:i+6])\\n        i=i-1\\n    a=set()\\n    for i in range(n):\\n        if dp2[i]:a.add(s[i:i+2])\\n        if dp3[i]:a.add(s[i:i+3])\\n    a=sorted(list(a))\\n    print(len(a))\\n    for i in a:\\n        print(i)\\n\", \"s = input()\\nn = len(s)\\ndp2,dp3=[0 for i in range(n)],[0 for i in range(n)]\\nif(n<7): print(0)\\nelse:\\n    if n-2>4: dp2[n-2]=1\\n    if n-3>4: dp3[n-3]=1;\\n    i=n-4\\n    while i>=5:\\n        dp2[i]=(dp3[i+2] | (dp2[i+2] & (s[i:i+2]!=s[i+2:i+4]) ) )\\n        dp3[i]=dp2[i+3] | (dp3[i+3] & (s[i:i+3]!=s[i+3:i+6]) )\\n        i=i-1\\n    a=set()\\n    for i in range(n):\\n        if dp2[i]:a.add(s[i:i+2])\\n        if dp3[i]:a.add(s[i:i+3])\\n    a=sorted(list(a))\\n    print(len(a))\\n    for i in a:\\n        print(i)\\n\", \"s = (input())\\nn = len(s)\\nx = set()\\n\\na = [[0 for i in range(2)] for j in range(n + 5)]\\nb = [0 for i in range(n + 5)]\\n\\nb[n] = 1\\na[n][0] = 1\\na[n][1] = 1\\n\\nfor i in range(n - 1, 4, -1):\\n    if b[i + 2]:\\n        if a[i + 2][0] and (s[i:i + 2] != s[i + 2:i + 4]):\\n            b[i] = 1\\n            a[i][0] = 1\\n        if a[i + 2][1]:\\n            b[i] = 1\\n            a[i][0] = 1\\n        if b[i]:\\n            x.add(s[i:i + 2])\\n    if b[i + 3]:\\n        if a[i + 3][1] and (s[i:i + 3] != s[i + 3:i + 6]):\\n            b[i] = 1\\n            a[i][1] = 1\\n        if a[i + 3][0]:\\n            b[i] = 1\\n            a[i][1] = 1\\n        if b[i]:\\n            x.add(s[i:i + 3])\\n\\nx = sorted(list(x))\\nprint(len(x))\\nfor i in x:\\n    print(i)\\n\", \"s = (input())\\nn = len(s)\\nx = set()\\n\\na = [[0 for i in range(2)] for j in range(n+3)]\\nb = [0 for i in range(n+3)]\\n\\nb[n] = 1\\na[n][0] = 1\\na[n][1] = 1\\n\\nfor i in range(n - 1, 4, -1):\\n    if b[i + 2]:\\n        if a[i + 2][0] and (s[i:i + 2] != s[i + 2:i + 4]):\\n            b[i] = 1\\n            a[i][0] = 1\\n        if a[i + 2][1]:\\n            b[i] = 1\\n            a[i][0] = 1\\n        if b[i]:\\n            x.add(s[i:i + 2])\\n    if b[i + 3]:\\n        if a[i + 3][1] and (s[i:i + 3] != s[i + 3:i + 6]):\\n            b[i] = 1\\n            a[i][1] = 1\\n        if a[i + 3][0]:\\n            b[i] = 1\\n            a[i][1] = 1\\n        if b[i]:\\n            x.add(s[i:i + 3])\\n\\nx = sorted(list(x))\\nprint(len(x))\\nfor i in x:\\n    print(i)\\n\", \"t = input()\\ns, d = set(), set()\\np = {(len(t), 2)}\\n\\nwhile p:\\n    m, x = p.pop()\\n    r = m + x\\n\\n    for y in [x, 5 - x]:\\n        l = m - y\\n        q = (l, y)\\n\\n        if q in d or l < 5 or t[l:m] == t[m:r]: continue\\n        s.add(t[l:m])\\n\\n        d.add(q)\\n        p.add(q)\\n\\nprint(len(s))\\nprint('\\\\n'.join(sorted(s)))\", \"t = input()\\ns, d = set(), set()\\np = {(len(t), 2)}\\n\\nwhile p:\\n    m, x = p.pop()\\n    r = m + x\\n\\n    for y in [x, 5 - x]:\\n        l = m - y\\n        q = (l, y)\\n\\n        if q in d or l < 5 or t[l:m] == t[m:r]: continue\\n        s.add(t[l:m])\\n\\n        d.add(q)\\n        p.add(q)\\n\\nprint(len(s))\\nprint('\\\\n'.join(sorted(s)))\\n\", \"t = input()\\n\\ns, d = set(), set()\\n\\np = {(len(t), 2)}\\n\\n\\n\\nwhile p:\\n\\n    m, x = p.pop()\\n\\n    r = m + x\\n\\n\\n\\n    for y in [x, 5 - x]:\\n\\n        l = m - y\\n\\n        q = (l, y)\\n\\n\\n\\n        if q in d or l < 5 or t[l:m] == t[m:r]: continue\\n\\n        s.add(t[l:m])\\n\\n\\n\\n        d.add(q)\\n\\n        p.add(q)\\n\\n\\n\\nprint(len(s))\\n\\nprint('\\\\n'.join(sorted(s)))\\n\\n\\n\\n\\n# Made By Mostafa_Khaled\\n\", \"import sys\\nsys.setrecursionlimit(15000)\\n\\ns = input()\\ns = s[5:] + \\\" \\\"\\nres = set()\\naux = set()\\n\\ndef getWords(x,y):\\n    if (x,y) in aux:\\n        return\\n    aux.add((x,y))\\n    if x > 1 and s[x:y] != s[x-2:x]:\\n        res.add(s[x-2:x])\\n        getWords(x-2,x)\\n    if x > 2 and s[x:y] != s[x-3:x]:\\n        res.add(s[x-3:x])\\n        getWords(x-3,x)\\n\\ngetWords(len(s)-1,len(s))\\n\\nprint(len(res))\\nfor word in sorted(list(res)):\\n    print(word)\", \"# Reberland Linguistics\\n\\nimport sys\\n\\nword = input()\\nsuffixes = set()\\npossible = {(len(word), 2)}\\nmy_set = set()\\n\\nwhile possible:\\n    d, x = possible.pop()\\n    a = d + x\\n\\n    for i in [x, 5 - x]:\\n        l = d - i\\n        q = (l, i)\\n\\n#        if q in my_set or (l < 5) or (word[l:d] == word[d:a]):\\n#            break\\n        if q in my_set or (l < 5) or (word[l:d] == word[d:a]):\\n            continue\\n\\n        suffixes.add(word[l:d])\\n        possible.add(q)\\n        my_set.add(q)\\n\\nsuffixes_alph = sorted(suffixes)\\n\\nprint(len(suffixes))\\nprint(*suffixes_alph, sep='\\\\n')\\n\", \"import sys\\n\\nword = input()\\n\\nsuffixes = set()\\npossible = set()\\nmy_set = set()\\nnot_poss = set()\\n\\npossible.add((len(word), 2))\\n\\nwhile possible:\\n    tam, x = possible.pop()\\n    a = tam + x\\n\\n    for i in [x, 5 - x]:\\n        root = tam - i\\n        new_pos = (root, i)\\n\\n        if root < 5 or new_pos in my_set or (word[root:tam] == word[tam:a]):\\n                not_poss.add(word[root:tam])\\n        else:\\n            suffixes.add(word[root:tam])\\n            possible.add(new_pos)\\n            my_set.add(new_pos)\\n\\nsuffixes_alph = sorted(suffixes)\\n\\nprint(len(suffixes))\\nprint(*suffixes_alph, sep='\\\\n')\\n\", \"\\ndef __starting_point():\\n\\n\\n    word = input()\\n\\n    suffixes = set()\\n    possible = set()\\n    my_set = set()\\n    not_poss = set()\\n\\n    possible.add((len(word), 2))\\n\\n    while possible:\\n        tam, x = possible.pop()\\n        a = tam + x\\n        for i in [x, 5 - x]:\\n            root = tam - i\\n            new_pos = (root, i)\\n\\n            if root < 5 or new_pos in my_set or (word[root:tam] == word[tam:a]):\\n                    not_poss.add(word[root:tam])\\n            else:\\n                suffixes.add(word[root:tam])\\n                possible.add(new_pos)\\n                my_set.add(new_pos)\\n\\n    suffixes_alph = sorted(suffixes)\\n\\n    print(len(suffixes))\\n    for i in suffixes_alph:\\n        print(i)\\n\\n__starting_point()\", \"def getPossibleSuffixes(s):\\n    if len(s) == 5:\\n        print(0)\\n        return\\n    possible_suffixes = s[5:len(s)]\\n    suffixes = []\\n    helper_hash = {}\\n    suffix_starts = [0 for x in range(len(possible_suffixes))]\\n    prev_2 = [\\\"\\\" for x in range(len(possible_suffixes))]\\n    suffix_starts[-1] = 1\\n    for i in range(len(possible_suffixes)-2, -1, -1):\\n        if suffix_starts[i+1] and prev_2[i+1] != possible_suffixes[i:i+2]:\\n            if not helper_hash.get(possible_suffixes[i:i+2]):\\n                suffixes.append(possible_suffixes[i:i+2])\\n                helper_hash[possible_suffixes[i:i+2]] = True\\n            if i-1>=0:\\n                prev_2[i-1] = possible_suffixes[i:i+2]\\n                suffix_starts[i-1] = 1\\n        if i+2 < len(possible_suffixes) and suffix_starts[i+2] and prev_2[i+2] != possible_suffixes[i:i+3]:\\n            if not helper_hash.get(possible_suffixes[i:i+3]):\\n                suffixes.append(possible_suffixes[i:i+3])\\n                helper_hash[possible_suffixes[i:i+3]] = True\\n            if i-1>=0:\\n                if prev_2[i-1] != \\\"\\\":\\n                    prev_2[i-1] = \\\"\\\"\\n                else:\\n                    prev_2[i-1] = possible_suffixes[i:i+3]\\n                suffix_starts[i-1] = 1\\n    print(len(suffixes))\\n    suffixes.sort()\\n    for suffix in suffixes:\\n        print(suffix)\\ns = input()\\ngetPossibleSuffixes(s)\", \"import sys\\nsys.setrecursionlimit(10000)\\n\\ns = input()\\ns = s[5:] + \\\" \\\"\\nres = set()\\naux = set()\\n\\ndef getWords(x,y):\\n    if (x,y) in aux:\\n        return\\n    aux.add((x,y))\\n    if x > 1 and s[x:y] != s[x-2:x]:\\n        res.add(s[x-2:x])\\n        getWords(x-2,x)\\n    if x > 2 and s[x:y] != s[x-3:x]:\\n        res.add(s[x-3:x])\\n        getWords(x-3,x)\\n\\ngetWords(len(s)-1,len(s))\\n\\nprint(len(res))\\nfor word in sorted(list(res)):\\n    print(word)\", \"lectura = input()\\nsufix = set()\\ncomb = {(len(lectura), 2)}\\nsetPrueba = set()\\nwhile comb:\\n    x, y = comb.pop()\\n    pos3 = x + y\\n    for i in [y, 5 - y]:\\n        posIni = x - i\\n        stringActual = (posIni, i)\\n        if ( stringActual in setPrueba or (posIni < 5) or (lectura[posIni:x] == lectura[x:pos3]) ):\\n            #print(\\\"encontrado en el set\\\")\\n            continue\\n        else:\\n            sufix.add(lectura[posIni:x])\\n            comb.add(stringActual)\\n            setPrueba.add(stringActual)\\nconclusion = sorted(sufix)\\nprint(len(sufix))\\nfor i in range(0,len(conclusion)):\\n    print(conclusion[i])\", \"s = input()\\n\\nif len(s) <= 5:\\n    print(0)\\nelse:\\n    words = set()\\n    s = s[5:]\\n    r = len(s)\\n\\n    if r == 4:\\n        words.add(s[1:])\\n        words.add(s[2:])\\n        words.add(s[:2])\\n\\n    if r == 2:\\n        words.add(s)\\n\\n    if r == 3:\\n        words.add(s)\\n        words.add(s[1:])\\n\\n    s = s[::-1]\\n\\n    if r > 4:\\n        dp2 = [0 for _ in range(r)]\\n        dp3 = [0 for _ in range(r)]\\n        dp2[1] = 1\\n        dp3[2] = 1\\n\\n        words.add(s[:2][::-1])\\n        words.add(s[:3][::-1])\\n        for i in range(3, r):\\n            if dp2[i - 2] and s[i - 3:i - 1] != s[i - 1:i + 1]:\\n                dp2[i] = 1\\n                words.add(s[i - 1:i + 1][::-1])\\n\\n            if dp2[i - 3] and i - 4 >= 0 and s[i - 4:i - 2] != s[i - 2:i + 1]:\\n                dp3[i] = 1\\n                words.add(s[i - 2:i + 1][::-1])\\n\\n            if dp3[i - 2] and i - 4 >= 0 and s[i - 4:i - 1] != s[i - 1:i + 1]:\\n                dp2[i] = 1\\n                words.add(s[i - 1:i + 1][::-1])\\n\\n            if dp3[i - 3] and i - 5 >= 0 and s[i - 5:i - 2] != s[i - 2:i + 1]:\\n                dp3[i] = 1\\n                words.add(s[i - 2:i + 1][::-1])\\n\\n    print(len(words))\\n    for word in sorted(words):\\n        print(word)\", \"s = input()\\nn = len(s)\\ns += '0000000000'\\ndp = [[0] * 2 for i in range(n + 5)]\\ndp[n] = [1, 1]\\nres = set()\\nfor i in range(n - 1, 4, -1):\\n    if i + 2 <= n and ((dp[i + 2][0] and s[i: i + 2] != s[i + 2: i + 4]) or dp[i + 2][1]):\\n        res.add(s[i: i + 2])\\n        dp[i][0] = 1\\n    if i + 3 <= n and ((dp[i + 3][1] and s[i: i + 3] != s[i + 3: i + 6]) or dp[i + 3][0]):\\n        res.add(s[i: i + 3])\\n        dp[i][1] = 1\\nprint(len(res))\\nfor ss in sorted(res):\\n    print(ss)\", \"import sys\\n\\nvalue = input()\\nif (len(value) < 7):\\n    print(0)\\n    return\\n\\nres = set()\\npossible = {}\\npossible[len(value)] = set([2])\\nif (len(value) > 7):\\n    possible[len(value)].add(3)\\npossibleLen = [2, 3]\\n\\nfor i in reversed(range(7, len(value) + 1)):\\n    possibleVal = possible.get(i, set())\\n    for length in possibleVal:\\n        nextI = i - length\\n        val = value[nextI:i]\\n        res.add(val)\\n        for posLen in possibleLen:\\n            if (nextI >= 5 + posLen and value[nextI - posLen:nextI] != val):\\n                setNextI = possible.setdefault(nextI, set())\\n                setNextI.add(posLen)\\n\\nprint(len(res))\\nfor val in sorted(res):\\n    print(val)\", \"word = input()\\nlength = len(word)\\n\\nacceptable2 = [None] * length\\nacceptable2[0] = True; acceptable2[1] = False; acceptable2[2] = True; acceptable2[3] = False\\nacceptable3 = [None] * length\\nacceptable3[0] = True; acceptable3[1] = False; acceptable3[2] = False; acceptable3[3] = True\\nall_possible_suffixes = set()\\n\\n\\ndef is_acceptable(suffix, rest):\\n    if len(suffix) == 2:\\n        if acceptable3[len(rest)]:\\n            return True\\n        if acceptable2[len(rest)] and not rest.startswith(suffix):\\n            return True\\n        return False\\n\\n    if len(suffix) == 3:\\n        if acceptable2[len(rest)]:\\n            return True\\n        if acceptable3[len(rest)] and not rest.startswith(suffix):\\n            return True\\n        return False\\n\\nfor i in range(length - 1, 4, -1):\\n    root = word[:i]\\n    suffixes = word[i:]\\n\\n    if len(suffixes) < 2:\\n        continue\\n\\n    first = suffixes[:2]\\n    rest = suffixes[2:]\\n    if is_acceptable(first, rest):\\n        all_possible_suffixes.add(first)\\n        acceptable2[len(suffixes)] = True\\n    else:\\n        acceptable2[len(suffixes)] = False\\n\\n    if len(suffixes) < 3:\\n        continue\\n\\n    first = suffixes[:3]\\n    rest = suffixes[3:]\\n    if is_acceptable(first, rest):\\n        all_possible_suffixes.add(first)\\n        acceptable3[len(suffixes)] = True\\n    else:\\n        acceptable3[len(suffixes)] = False\\n\\n\\nprint(len(all_possible_suffixes))\\nfor s in sorted(list(all_possible_suffixes)):\\n    print(s)\\n\", \"s = input()\\n\\npossible = [[],[],[False]*10100, [False]*10100]\\n\\nlength = len(s)\\npossible[2][length-2] = True\\npossible[3][length-3] = True\\n\\nfor i in range(length-1, 5-1,-1):\\n    if length - 4 >= i:\\n        possible[2][i] = (possible[2][i+2] and s[i:i+2] != s[i+2:i+4]) or possible[3][i+2]\\n    if length - 5 >= i:\\n        possible[3][i] = possible[2][i+3]\\n    if length - 6 >= i:\\n        possible[3][i] = (possible[3][i + 3] and s[i:i+3] != s[i+3:i+6]) or possible[3][i]\\n\\noutput = set()\\n\\nfor i in range(5,10000):\\n    if possible[2][i]:\\n        output.add(s[i:i + 2])\\n    if possible[3][i]:\\n        output.add(s[i:i + 3])\\n\\noutput_list = sorted(list(output))\\nprint(len(output_list))\\nfor o in output_list:\\n    print(o)\\n\", \"import sys\\n\\ninput = sys.stdin.readline\\n\\ns = input().strip()\\nn = len(s)\\nposs = [[False] * 2 for _ in range(n)]\\nposs[n - 2][0] = poss[n - 3][1] = True\\nfor i in range(n - 4, -1, -1):\\n    poss[i][0] = s[i: i + 2] != s[i + 2: i + 4] and poss[i + 2][0] or poss[i + 2][1]\\n    poss[i][1] = s[i: i + 3] != s[i + 3: i + 6] and poss[i + 3][1] or poss[i + 3][0]\\n\\nans = set()\\nfor i in range(5, n):\\n    if poss[i][0]:\\n        ans.add(s[i: i + 2])\\n    if poss[i][1]:\\n        ans.add(s[i:i + 3])\\n\\nprint(len(ans))\\nfor x in sorted(ans):\\n    print(x)\\n\"]",
        "difficulty": "competition",
        "input": "gzqgchv\n",
        "output": "1\nhv\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/666/A"
    },
    {
        "id": 2237,
        "task_id": 3974,
        "test_case_id": 1,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "+-+-+\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2238,
        "task_id": 3974,
        "test_case_id": 2,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "---\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2239,
        "task_id": 3974,
        "test_case_id": 3,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "-\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2240,
        "task_id": 3974,
        "test_case_id": 4,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "--\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2241,
        "task_id": 3974,
        "test_case_id": 5,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "---\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2242,
        "task_id": 3974,
        "test_case_id": 6,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "----\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2243,
        "task_id": 3974,
        "test_case_id": 7,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "---+\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2244,
        "task_id": 3974,
        "test_case_id": 8,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "--+-\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2245,
        "task_id": 3974,
        "test_case_id": 9,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "--++\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2246,
        "task_id": 3974,
        "test_case_id": 10,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "-+--\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2247,
        "task_id": 3974,
        "test_case_id": 11,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "-++\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2248,
        "task_id": 3974,
        "test_case_id": 12,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "-++-\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2249,
        "task_id": 3974,
        "test_case_id": 13,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "+\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2250,
        "task_id": 3974,
        "test_case_id": 14,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "+-\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2251,
        "task_id": 3974,
        "test_case_id": 15,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "+--\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2252,
        "task_id": 3974,
        "test_case_id": 16,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "+--+\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2253,
        "task_id": 3974,
        "test_case_id": 17,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "++--\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2254,
        "task_id": 3974,
        "test_case_id": 18,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "-+++--+-++--+-+--+-+\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2255,
        "task_id": 3974,
        "test_case_id": 19,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "++-++--+++++-+++++---+++-++-++-\n",
        "output": "12\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2256,
        "task_id": 3974,
        "test_case_id": 20,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "----+-+--++---++---++-+-----+--\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2257,
        "task_id": 3974,
        "test_case_id": 21,
        "question": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+\" in his notes. Similarly, each time a visitor left the club, Polycarpus put character \"-\" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended.\n\nRight now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times.\n\n\n-----Input-----\n\nThe only line of the input contains a sequence of characters \"+\" and \"-\", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive.\n\n\n-----Output-----\n\nPrint the sought minimum number of people\n\n\n-----Examples-----\nInput\n+-+-+\n\nOutput\n1\n\nInput\n---\nOutput\n3",
        "solutions": "[\"m,p,c=0,0,0\\ns=(input())\\nfor i in  s:\\n    if i=='-':\\n        c-=1\\n    else:\\n        c+=1    \\n    m=min(m,c)\\n    p=max(p,c)\\nprint(p-m)\\n\", \"import math\\nimport re\\nfrom fractions import Fraction\\nfrom collections import Counter\\n\\nclass Task:\\n    signs = ''\\n    answer = 0\\n    \\n    def __init__(self):\\n        self.signs = input()\\n\\n    def solve(self):\\n        counter = 0\\n        leftBound, rightBound = 0, 0\\n        for x in self.signs:\\n            counter += 1 if x == '+' else -1\\n            leftBound = min(leftBound, counter)\\n            rightBound = max(rightBound, counter)\\n        self.answer = rightBound - leftBound\\n\\n    def printAnswer(self):\\n        print(self.answer)\\n\\ntask = Task()\\ntask.solve()\\ntask.printAnswer()\\n\", \"3\\n\\ninside = outside = 0\\nfor c in list(input()):\\n    if c == '+':\\n        if outside:\\n            outside -= 1\\n        inside += 1\\n    else:\\n        if inside:\\n            inside -= 1\\n        outside += 1\\nprint(inside + outside)\\n\", \"p = [0] + [1 if i == '+' else -1 for i in input()]\\nfor i in range(1, len(p)):\\n    p[i] += p[i - 1]\\nprint(max(p) - min(p))\", \"s=input()\\nn=len(s)\\nx,a,b=0,0,0\\nfor i in range(n):\\n  if s[i]=='-':\\n    x-=1\\n  else:\\n    x+=1\\n  a = min(a,x)\\n  b = max(b,x)\\nprint(b-a)\", \"a = [1 if x == '+' else -1 for x in input()]\\nb = list(map(lambda i : sum(a[0:i]), range(len(a) + 1)))\\nprint(max(b) - min(b))\", \"def puts(s):\\n    print(s, end='')\\n\\ns = input()\\na = mi = ma = 0\\n\\nfor c in s:\\n    if(c == '+'):\\n        a = a + 1\\n        ma = max(ma, a)\\n    else:\\n        a = a - 1\\n        mi = min(mi, a)\\n\\nprint(ma - mi)\", \"inp=input()\\ninclb=0\\noutclb=0\\nseen=0\\ni=0\\nfor i in range(0,len(inp)):\\n if inp[i] == \\\"-\\\":\\n  outclb += 1\\n  if inclb > 0:\\n   inclb -= 1\\n  else:\\n   seen += 1\\n else:\\n  inclb += 1\\n  if outclb > 0:\\n   outclb -= 1\\n  else:\\n   seen += 1\\nprint(seen)\", \"c, v1, v2 = 0, 0, 0\\nfor ch in input():\\n    c += 1 if ch == '+' else -1\\n    v1, v2 = min(v1, c), max(v2, c)\\nprint(v2 - v1)\\n\", \"s = input()\\nlow = 0\\nhigh = 0\\nsum = 0\\nfor i in s:\\n    if i == '+':\\n        sum += 1\\n    else:\\n        sum -= 1\\n    if sum < low:\\n        low = sum\\n    if sum > high:\\n        high = sum\\nprint(high - low)\", \"#!/usr/bin/env python3\\n\\n\\n\\n\\ndef main():\\n    s = input()\\n    cnt = 0\\n    ans = 0\\n    for x in s:\\n        if x == '+':\\n            cnt += 1\\n            ans = max(ans, cnt)\\n        else:\\n            if cnt == 0:\\n                ans += 1\\n            else:\\n                cnt -= 1\\n    print(ans)\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"S = input()\\n\\nans = 0\\np, n = 0, 0\\nfor i in range( len( S ) ):\\n  if S[ i ] == '+':\\n    p += 1\\n    n -= 1\\n  else:\\n    n += 1\\n    p -= 1\\n  n = max( 0, n )\\n  p = max( 0, p )\\n  ans = max( ans, max( n, p ) )\\n\\nprint( ans )\\n\", \"s = input()\\nmx = 0\\nmn = 0\\ncur = 0\\nfor i in s:\\n  if i == '+':\\n    cur += 1\\n  else:\\n    cur -= 1\\n  mx = max(mx,cur)\\n  mn = min(mn,cur)\\nprint(abs(mx-mn))\", \"s = input()\\nt = mx = 0\\nfor i in s:\\n    if i == '-' and t > 0:\\n        t -= 1\\n    elif i == '+':\\n        t += 1\\n        mx = max(mx, t)\\n    else:\\n        mx += 1\\nprint(mx)\", \"s=input()\\na,b=0,0\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1\\n\\t\\tif a<b:\\n\\t\\t\\tb=a\\n\\telse:\\n\\t\\ta=a+1\\na=-b\\nans=a\\nfor i in range(len(s)):\\n\\tif(s[i]=='-'):\\n\\t\\ta=a-1 \\n\\telse:\\n\\t\\ta=a+1\\n\\tif a>ans:ans=a\\nprint(ans)\", \"s = input()\\nplus = 0\\nminus = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if minus == 0:\\n            plus += 1\\n            seen += 1\\n        else:\\n            plus += 1\\n            minus -= 1\\n    else:\\n        if plus == 0:\\n            minus += 1\\n            seen += 1\\n        else:\\n            minus += 1\\n            plus -= 1\\n\\nprint(seen)\", \"s = input()\\ninside= 0\\noutside = 0\\nseen = 0\\nfor letter in s:\\n    if letter == '+':\\n        if outside == 0:\\n            inside += 1\\n            seen += 1\\n        else:\\n            inside += 1\\n            outside -= 1\\n    else:\\n        if inside == 0:\\n            outside += 1\\n            seen += 1\\n        else:\\n            outside += 1\\n            inside -= 1\\n\\nprint(seen)\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n\", \"s=input()\\ns=list(s)\\ns1=[0]*len(s)\\nfor i in range(len(s)):\\n    if s[i]=='-':\\n        s[i]=1\\n        s1[i]=-1 \\n    else:\\n        s[i]=-1 \\n        s1[i]=1 \\ndef kadane(s):\\n    maxi=-1 \\n    curr=0 \\n    for i in s:\\n        curr=max(curr+i,i)\\n        maxi=max(maxi,curr)\\n    return maxi \\nprint(max(kadane(s),kadane(s1)))\\n#@print(kadane(s))\\n\", \"s = input()\\np = 0\\nm = 0\\n\\nfor i in s:\\n  if i == \\\"+\\\":\\n    p += 1\\n    m = max(m-1, 0)\\n  elif i == \\\"-\\\":\\n    m += 1\\n    p = max(p-1, 0)\\nprint(p+m)\\n\", \"s = list(input())\\nans = 0\\nwhile s.count('+') != 0 and s.count('-') != 0:\\n    flag = 0\\n    ans += 1\\n    if s.index('+') < s.index('-'):\\n        s[s.index('+')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '-':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '+':\\n                flag = 0\\n                s[i] = 0\\n    elif s.index('-') < s.index('+'):\\n        s[s.index('-')] = 0\\n        for i in range(1, len(s)):\\n            if flag == 0 and s[i] == '+':\\n                flag = 1\\n                s[i] = 0\\n            elif flag == 1 and s[i] == '-':\\n                flag = 0\\n                s[i] = 0\\nprint(max(ans + s.count('+'), ans + s.count('-')))\\n\", \"s=input()\\nans=a1=a2=0\\nfor i in s:\\n    if i=='+':\\n        ans+=1\\n    else:\\n        ans-=1\\n    a1=max(a1,ans)\\n    a2=min(a2,ans)\\nprint(a1+abs(a2))            \", \"l=list(input())\\nj=0\\nc=0\\nk=0\\nl1=0\\ne=0\\np=0\\nwhile(j<len(l)):\\n    if(l[j]=='+'):\\n        p+=1\\n        k+=1\\n    else:\\n    \\n        l1+=1\\n        if(k>=e):\\n            c+=(k-e)\\n            e=k\\n            \\n        k-=1\\n        if(l1>p):\\n            l1-=1\\n            c+=1\\n        \\n        \\n            \\n       \\n    j+=1\\nif(k>e):\\n    c+=k-e\\n\\nprint(c)\\n        \\n        \\n\", \"s = input()\\n\\nd, f, r = 0, 0, 0\\nfor c in s:\\n    if c == \\\"-\\\":\\n        f += 1\\n        if d >= 1:\\n            d -= 1\\n        else:\\n            r += 1\\n    elif c == \\\"+\\\":\\n        d += 1\\n        if f >= 1:\\n            f -= 1\\n        else:\\n            r += 1\\n\\nprint(r)\", \"def solve(s):\\n\\tn = len(s)\\n\\tif(n == 1):\\n\\t\\treturn 1\\n\\telse:\\n\\t\\tstart = 0\\n\\t\\tprev = s[0]\\n\\t\\tans = 0\\n\\t\\tf = 1\\n\\t\\tfor i in range(1,n):\\n\\t\\t\\tf = 1\\n\\t\\t\\tif(s[i] == prev):\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\telse:\\n\\t\\t\\t\\tf = 0\\n\\t\\t\\t\\tans = max(ans,i-start)\\n\\t\\t\\t\\tstart = i\\n\\t\\t\\t\\tprev = s[i]\\n\\t\\t\\t\\t# print(ans)\\n\\t\\tif(f):\\n\\t\\t\\tans = max(ans,n-start)\\n\\t\\t\\tstart = i\\n\\t\\t\\tprev = s[i]\\n\\t\\treturn ans\\n\\ndef solve1(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '+'):\\n\\t\\t\\tst.append('+')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\ndef solve2(s):\\n\\tst = []\\n\\tans = 0\\n\\tmaxx = 0\\n\\tfor i in s:\\n\\t\\tif(st):\\n\\t\\t\\tans = 0\\n\\t\\tif(i == '-'):\\n\\t\\t\\tst.append('-')\\n\\t\\telse:\\n\\t\\t\\tif(st):\\n\\t\\t\\t\\tst.pop()\\n\\t\\t\\telse:\\n\\t\\t\\t\\tans += 1\\n\\t\\t\\t\\tmaxx = max(maxx,ans)\\n\\t\\tmaxx = max(maxx,len(st))\\n\\t\\t# print(st)\\n\\tmaxx = max(maxx,len(st))\\n\\treturn maxx\\n\\nl = input()\\nans = solve(l)\\nans1 = solve1(l)\\nans2 = solve2(l)\\nprint(max(ans,ans1,ans2))\\n\\n\\n\"]",
        "difficulty": "competition",
        "input": "-+++---+++++++++++++-++-++++++-++-+-+++-\n",
        "output": "22\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/245/E"
    },
    {
        "id": 2258,
        "task_id": 4021,
        "test_case_id": 1,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "2\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2259,
        "task_id": 4021,
        "test_case_id": 2,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "4\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2260,
        "task_id": 4021,
        "test_case_id": 3,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "27\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2261,
        "task_id": 4021,
        "test_case_id": 4,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "42\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2262,
        "task_id": 4021,
        "test_case_id": 5,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2263,
        "task_id": 4021,
        "test_case_id": 6,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "3\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2264,
        "task_id": 4021,
        "test_case_id": 7,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "64\n",
        "output": "267\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2265,
        "task_id": 4021,
        "test_case_id": 8,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "5\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2266,
        "task_id": 4021,
        "test_case_id": 9,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "6\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2267,
        "task_id": 4021,
        "test_case_id": 10,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "7\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2268,
        "task_id": 4021,
        "test_case_id": 11,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "8\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2269,
        "task_id": 4021,
        "test_case_id": 12,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "9\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2270,
        "task_id": 4021,
        "test_case_id": 13,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "10\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2271,
        "task_id": 4021,
        "test_case_id": 14,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "11\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2272,
        "task_id": 4021,
        "test_case_id": 15,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "12\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2273,
        "task_id": 4021,
        "test_case_id": 16,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "13\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2274,
        "task_id": 4021,
        "test_case_id": 17,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "14\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2275,
        "task_id": 4021,
        "test_case_id": 18,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "15\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2276,
        "task_id": 4021,
        "test_case_id": 19,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "16\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2277,
        "task_id": 4021,
        "test_case_id": 20,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "17\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2278,
        "task_id": 4021,
        "test_case_id": 21,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "18\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2279,
        "task_id": 4021,
        "test_case_id": 22,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "19\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2280,
        "task_id": 4021,
        "test_case_id": 23,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "20\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2281,
        "task_id": 4021,
        "test_case_id": 24,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "21\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2282,
        "task_id": 4021,
        "test_case_id": 25,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "22\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2283,
        "task_id": 4021,
        "test_case_id": 26,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "23\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2284,
        "task_id": 4021,
        "test_case_id": 27,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "24\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2285,
        "task_id": 4021,
        "test_case_id": 28,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "25\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2286,
        "task_id": 4021,
        "test_case_id": 29,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "26\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2287,
        "task_id": 4021,
        "test_case_id": 30,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "28\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2288,
        "task_id": 4021,
        "test_case_id": 31,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "29\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2289,
        "task_id": 4021,
        "test_case_id": 32,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "30\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2290,
        "task_id": 4021,
        "test_case_id": 33,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "31\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2291,
        "task_id": 4021,
        "test_case_id": 34,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "32\n",
        "output": "51\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2292,
        "task_id": 4021,
        "test_case_id": 35,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "33\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2293,
        "task_id": 4021,
        "test_case_id": 36,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "34\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2294,
        "task_id": 4021,
        "test_case_id": 37,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "35\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2295,
        "task_id": 4021,
        "test_case_id": 38,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "36\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2296,
        "task_id": 4021,
        "test_case_id": 39,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "37\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2297,
        "task_id": 4021,
        "test_case_id": 40,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "38\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2298,
        "task_id": 4021,
        "test_case_id": 41,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "39\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2299,
        "task_id": 4021,
        "test_case_id": 42,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "40\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2300,
        "task_id": 4021,
        "test_case_id": 43,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "41\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2301,
        "task_id": 4021,
        "test_case_id": 44,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "43\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2302,
        "task_id": 4021,
        "test_case_id": 45,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "44\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2303,
        "task_id": 4021,
        "test_case_id": 46,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "45\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2304,
        "task_id": 4021,
        "test_case_id": 47,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "46\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2305,
        "task_id": 4021,
        "test_case_id": 48,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "47\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2306,
        "task_id": 4021,
        "test_case_id": 49,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "48\n",
        "output": "52\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2307,
        "task_id": 4021,
        "test_case_id": 50,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "49\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2308,
        "task_id": 4021,
        "test_case_id": 51,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "50\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2309,
        "task_id": 4021,
        "test_case_id": 52,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "51\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2310,
        "task_id": 4021,
        "test_case_id": 53,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "52\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2311,
        "task_id": 4021,
        "test_case_id": 54,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "53\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2312,
        "task_id": 4021,
        "test_case_id": 55,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "54\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2313,
        "task_id": 4021,
        "test_case_id": 56,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "55\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2314,
        "task_id": 4021,
        "test_case_id": 57,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "56\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2315,
        "task_id": 4021,
        "test_case_id": 58,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "57\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2316,
        "task_id": 4021,
        "test_case_id": 59,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "58\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2317,
        "task_id": 4021,
        "test_case_id": 60,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "59\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2318,
        "task_id": 4021,
        "test_case_id": 61,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "60\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2319,
        "task_id": 4021,
        "test_case_id": 62,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "61\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2320,
        "task_id": 4021,
        "test_case_id": 63,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "62\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2321,
        "task_id": 4021,
        "test_case_id": 64,
        "question": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 64).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Examples-----\nInput\n2\n\nOutput\n1\n\nInput\n4\n\nOutput\n2\n\nInput\n27\n\nOutput\n5\n\nInput\n42\n\nOutput\n6",
        "solutions": "[\"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem F\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\nx = int(input())\\na = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267]\\nprint(a[x-1])\", \"#!/bin/bash/python\\n# Date:\\t\\t2014-04-16\\n# Author:\\tshijinzhan\\n# Status:\\n# Note:\\n\\nindex = int(input())\\nA0000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(A0000001[index])\\n\", \"x=int(input())\\ny=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267]\\nprint(y[x-1])\", \"print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267][int(input())-1])\", \"# oeis 000001\\nx = [   1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nprint(x[int(input()) - 1])\\n\", \"s = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\n\\nn = int(input())\\nprint(s[n])\", \"n = int(input())\\nres=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(res[n])\", \"arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\na = int(input())\\nprint(arr[a-1])\", \"OeisA000001 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(OeisA000001[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"wyj=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(wyj[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"a=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(a[n])\", \"print([0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2][int(input())])\", \"ans=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(ans[int(input())-1])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nfor i in range(len(l)):\\n    l[i]=int(l[i])\\nprint(int(l[n]))\", \"l=[0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2]\\nn=int(input())\\nprint(l[n])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\", \"number=[0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2]\\nprint(number[int(input())])\"]",
        "difficulty": "introductory",
        "input": "63\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/F"
    },
    {
        "id": 2322,
        "task_id": 4054,
        "test_case_id": 1,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "2 4 6 8 10\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2323,
        "task_id": 4054,
        "test_case_id": 2,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "50 27 17 31 89\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2324,
        "task_id": 4054,
        "test_case_id": 3,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "50 87 29 81 21\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2325,
        "task_id": 4054,
        "test_case_id": 4,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "74 21 36 68 80\n",
        "output": "9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2326,
        "task_id": 4054,
        "test_case_id": 5,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "75 82 48 95 12\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2327,
        "task_id": 4054,
        "test_case_id": 6,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "41 85 14 43 23\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2328,
        "task_id": 4054,
        "test_case_id": 7,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "94 28 3 29 9\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2329,
        "task_id": 4054,
        "test_case_id": 8,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "94 21 36 89 20\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2330,
        "task_id": 4054,
        "test_case_id": 9,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "60 92 82 71 53\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2331,
        "task_id": 4054,
        "test_case_id": 11,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "12 39 3 50 84\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2332,
        "task_id": 4054,
        "test_case_id": 12,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "12 31 47 31 84\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2333,
        "task_id": 4054,
        "test_case_id": 13,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "79 2 93 92 16\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2334,
        "task_id": 4054,
        "test_case_id": 14,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "65 46 3 77 81\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2335,
        "task_id": 4054,
        "test_case_id": 15,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "31 38 47 26 13\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2336,
        "task_id": 4054,
        "test_case_id": 16,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "42 9 59 19 24\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2337,
        "task_id": 4054,
        "test_case_id": 17,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "51 19 70 5 78\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2338,
        "task_id": 4054,
        "test_case_id": 18,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "51 56 14 99 21\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2339,
        "task_id": 4054,
        "test_case_id": 19,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "28 49 58 47 54\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2340,
        "task_id": 4054,
        "test_case_id": 20,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "3 26 69 33 18\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2341,
        "task_id": 4054,
        "test_case_id": 21,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "14 63 14 25 18\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2342,
        "task_id": 4054,
        "test_case_id": 22,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "81 67 58 8 51\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2343,
        "task_id": 4054,
        "test_case_id": 24,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "32 36 80 54 48\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2344,
        "task_id": 4054,
        "test_case_id": 26,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "67 66 69 96 92\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2345,
        "task_id": 4054,
        "test_case_id": 27,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "52 43 80 14 79\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2346,
        "task_id": 4054,
        "test_case_id": 28,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "18 13 91 64 22\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2347,
        "task_id": 4054,
        "test_case_id": 29,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "19 84 69 57 55\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2348,
        "task_id": 4054,
        "test_case_id": 30,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "71 61 47 9 19\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2349,
        "task_id": 4054,
        "test_case_id": 32,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "1 1 2 7 4\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2350,
        "task_id": 4054,
        "test_case_id": 34,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "1 1 2 6 4\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2351,
        "task_id": 4054,
        "test_case_id": 35,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "1 1 1 7 4\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2352,
        "task_id": 4054,
        "test_case_id": 36,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "1 2 2 7 4\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2353,
        "task_id": 4054,
        "test_case_id": 37,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "1 1 3 7 4\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2354,
        "task_id": 4054,
        "test_case_id": 38,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "2 2 3 14 8\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2355,
        "task_id": 4054,
        "test_case_id": 39,
        "question": "Salve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\n    I Aqua Fortis\n\n    I Aqua Regia\n\n    II Amalgama\n\n    VII Minium\n\n    IV Vitriol\n\nMisce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci invia est via.\n\nFac et spera,\n\nVale,\n\nNicolas Flamel\n\n\n-----Input-----\n\nThe first line of input contains several space-separated integers a_{i} (0 ≤ a_{i} ≤ 100).\n\n\n-----Output-----\n\nPrint a single integer.\n\n\n-----Examples-----\nInput\n2 4 6 8 10\n\nOutput\n1",
        "solutions": "[\"b =[1,1,2,7,4]\\na =list(map(int,input().split()))\\nans = 100\\nfor i in range(5):\\n    ans = min(a[i]//b[i],ans)\\nprint(ans)\\n\\n\", \"\\\"\\\"\\\"\\nCodeforces April Fools Contest 2014 Problem C\\n\\nAuthor  : chaotic_iak\\nLanguage: Python 3.3.4\\n\\\"\\\"\\\"\\n\\nclass InputHandlerObject(object):\\n    inputs = []\\n\\n    def getInput(self, n = 0):\\n        res = \\\"\\\"\\n        inputs = self.inputs\\n        if not inputs: inputs.extend(input().split(\\\" \\\"))\\n        if n == 0:\\n            res = inputs[:]\\n            inputs[:] = []\\n        while n > len(inputs):\\n            inputs.extend(input().split(\\\" \\\"))\\n        if n > 0:\\n            res = inputs[:n]\\n            inputs[:n] = []\\n        return res\\nInputHandler = InputHandlerObject()\\ng = InputHandler.getInput\\n\\n############################## SOLUTION ##############################\\n# 1 1 2 7 4\\n\\ni = [1,1,2,7,4]\\na = [int(x) for x in g()]\\nprint(min(a[x]//i[x] for x in range(0,5)))\", \"a =  list(map(int,input().split()))\\nans = min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4)\\nprint(ans)\", \"import sys\\na = list(map(int, sys.stdin.readline().split()))\\nd = [1, 1, 2, 7, 4]\\nans = a[0]\\nfor i in range(5):\\n    ans = min(ans, a[i] // d[i])\\nprint(ans)\\n\", \"\\na = list(map(int, input().split()))\\nb = [ 1, 1, 2, 7, 4 ]\\n\\nprint(min([ x//y for x, y in zip(a,b) ]))\\n\\n\\n\", \"b = list (input().split())\\n\\nneed = [1, 1, 2, 7, 4]\\nans = 100000\\nfor i in range (5):\\n    ans = min (ans, int(b[i]) // need[i])\\n    \\nprint (ans)\\n\", \"a,b,c,d,e=list(map(int,input().split()))\\nprint(min(a,b,c//2,d//7,e//4))\\n\", \"a = [1,1,2,7,4]\\nb = list(map(int, input().split()))\\nm = 1000\\nfor i in range(5):\\n    m = min(b[i]//a[i],m)\\nprint(m)\", \"a=[int(i) for i in input().split()]\\nprint(min(a[0],a[1],a[2]//2,a[3]//7,a[4]//4))\", \"from math import floor\\nnums = list(map(int, input().split()))\\nseq = [1, 1, 2, 7, 4]\\n\\nmin_c = 10000000000\\nfor i in range(len(nums)):\\n    if floor(nums[i] / seq[i]) < min_c:\\n        min_c = floor(nums[i] / seq[i])\\nprint(min_c)\", \"\\na = list(map(int, input().split(\\\" \\\")))\\nb = [1, 1, 2, 7, 4]\\n\\nfor i in range(len(a)):\\n    a[i] = a[i] // b[i]\\n\\nr = min(a)\\n\\nprint(r)\", \"a=input().split()\\ning=[1,1,2,7,4]\\nb=[int(i) for i in a]\\nc=[int(b[i]/ing[i]) for i in range(len(a))]\\nprint(min(c))\", \"a = list(map(int, input().split()))\\nif len(a) <5:\\n    print(0)\\nelse:\\n    print(min(a[0], a[1], a[2] // 2, a[3] // 7, a[4] // 4))\", \"__author__ = 'Pavel Mavrin'\\n\\na = [int(x) for x in input().split()]\\nb = [1, 1, 2, 7, 4]\\n\\nres = 1e100\\nfor i in range(5):\\n    res = min(res, a[i] // b[i])\\n\\nprint(res)\\n\\n\", \"a=input()\\na=a.split()\\na[0]=int(a[0])\\na[1]=int(a[1])\\na[2]=int(a[2])//2\\na[3]=int(a[3])//7\\na[4]=int(a[4])//4\\nprint(min(a))\", \"a=list(map(int,input().split()))\\nans=100\\nans=min(ans,a[0])\\nans=min(ans,a[1])\\nans=min(ans,a[2]//2)\\nans=min(ans,a[3]//7)\\nans=min(ans,a[4]//4)\\nprint(ans)\", \"def solve(inp):\\n #if inp=='2 4 6 8 10': return 1\\n ar = list(map(int,inp.split(' ')))\\n return min([ar[0], ar[1], ar[2]//2, ar[3]//7, ar[4]//4])\\n\\ninp = input()\\nprint(solve(inp))\\n\", \"requirements = (1, 1, 2, 7, 4)\\n\\ningrs = [int(x) for x in input().split(\\\" \\\")]\\n\\nmin_count = 2**64\\n\\nfor i, x in enumerate(ingrs):\\n    if i >= len(requirements):\\n        continue\\n    min_count = min(int(x / requirements[i]), min_count)\\n\\nprint(min_count)\\n\", \"a, b, c, d, e = map(int, input().split())\\nprint(min(a, b, c // 2, d // 7, e // 4))\", \"X=input();\\nJ=X.split();\\na=min(int(J[0]),int(J[1]),int(J[2])//2,int(J[3])//7,int(J[4])//4)\\nprint(a)\", \"#!/bin/python\\n\\na, b, c, d, e = list(map(int, input().split(' ')))\\nresult = (int)(min(a/1, b/1, c/2, d/7, e/4))\\nprint(result)\\n\", \"ingrd = [1,1,2,7,4]\\nqunty = list(map(int,input().split()))\\nmins=[]\\nfor i,v in enumerate(qunty):\\n    mins.append(v//ingrd[i])\\nprint(min(mins))\\n\\n\\n\", \"c = list(map(int, input().split()))\\nprint(min(c[0], c[1], c[2] // 2, c[3] // 7, c[4] // 4))\", \"a,b,c,d,e=map(int,input().split())\\nprint(min(a,b,c//2,d//7,e//4))\", \"a, b, c, d, e = map(int, input().split(' ')); print(min(a, b, c//2, d//7, e//4))\"]",
        "difficulty": "introductory",
        "input": "100 100 100 100 100\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/409/C"
    },
    {
        "id": 2356,
        "task_id": 4064,
        "test_case_id": 1,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "7 24 21 23\n16 17 14 20 20 11 22\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2357,
        "task_id": 4064,
        "test_case_id": 2,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "65 654 560 571\n83 511 615 263 171 146 241 511 582 216 352 632 506 538 536 217 627 213 324 579 172 241 363 584 450 144 447 536 241 523 162 21 437 291 191 111 567 502 170 570 231 493 169 360 107 114 322 160 574 611 460 558 616 361 284 58 41 345 450 560 543 520 105 416 38\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2358,
        "task_id": 4064,
        "test_case_id": 3,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "2 24 21 22\n23 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2359,
        "task_id": 4064,
        "test_case_id": 4,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "5 3 0 0\n1 1 1 1 1\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2360,
        "task_id": 4064,
        "test_case_id": 5,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "7 250 21 23\n16 17 14 20 20 11 22\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2361,
        "task_id": 4064,
        "test_case_id": 6,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "29 425 46 81\n405 237 24 45 165 328 134 309 7 236 348 204 368 396 298 343 180 186 395 246 44 53 303 404 271 344 269 292 12\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2362,
        "task_id": 4064,
        "test_case_id": 7,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "2 24 14 16\n17 2\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2363,
        "task_id": 4064,
        "test_case_id": 8,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "29 700 471 636\n222 416 14 30 152 126 9 114 605 415 406 162 662 514 26 329 58 442 249 438 436 120 23 572 359 523 233 443 116\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2364,
        "task_id": 4064,
        "test_case_id": 9,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "29 5 1 1\n4 2 2 4 3 2 1 1 3 4 2 1 4 2 3 3 3 4 3 2 2 4 2 1 3 3 4 3 2\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2365,
        "task_id": 4064,
        "test_case_id": 10,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "37 14 2 9\n2 8 5 10 3 12 11 7 7 11 4 7 9 7 8 13 10 10 9 12 4 12 11 1 7 10 8 7 9 11 1 10 9 9 7 9 11\n",
        "output": "28\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2366,
        "task_id": 4064,
        "test_case_id": 11,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "60 323 211 322\n227 286 146 309 283 258 319 300 50 192 177 125 196 131 144 321 108 49 130 176 129 289 119 286 181 316 91 322 122 296 298 285 108 136 106 131 91 174 138 183 154 133 152 261 98 283 274 317 267 268 83 32 146 186 129 210 240 159 75 5\n",
        "output": "27\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2367,
        "task_id": 4064,
        "test_case_id": 12,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "4 3 0 0\n1 1 1 1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2368,
        "task_id": 4064,
        "test_case_id": 13,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "1 10 0 9\n5\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2369,
        "task_id": 4064,
        "test_case_id": 14,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "39 42 22 25\n26 41 35 6 35 38 28 40 1 37 38 12 30 31 33 12 13 7 28 15 41 28 1 18 21 9 38 3 2 1 2 30 20 22 8 33 37 19 22\n",
        "output": "14\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2370,
        "task_id": 4064,
        "test_case_id": 15,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "23 37 29 33\n10 32 7 28 35 11 24 23 20 15 33 28 7 11 4 14 30 28 25 31 16 17 10\n",
        "output": "7\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2371,
        "task_id": 4064,
        "test_case_id": 16,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "46 10 2 9\n8 8 2 6 9 1 5 2 9 1 9 5 7 4 9 3 9 9 2 7 9 4 5 3 1 9 2 4 1 1 7 1 4 1 9 4 6 1 7 1 1 6 4 2 2 8\n",
        "output": "46\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2372,
        "task_id": 4064,
        "test_case_id": 17,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "40 15 8 11\n9 8 11 1 13 4 9 2 3 11 7 8 6 4 2 7 9 9 9 14 4 5 3 14 9 4 3 1 10 10 4 9 12 13 2 7 4 9 2 5\n",
        "output": "21\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2373,
        "task_id": 4064,
        "test_case_id": 18,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "1 725 158 340\n317\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2374,
        "task_id": 4064,
        "test_case_id": 19,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "7 1111 1056 1073\n82 422 1053 273 304 452 600\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2375,
        "task_id": 4064,
        "test_case_id": 20,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "1 1586 868 1579\n1235\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2376,
        "task_id": 4064,
        "test_case_id": 21,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "1 426 28 400\n111\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2377,
        "task_id": 4064,
        "test_case_id": 22,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "48 39 36 38\n17 28 20 33 5 13 7 17 33 22 14 23 7 32 19 20 24 1 14 18 22 16 16 30 24 36 33 19 25 22 26 15 21 1 7 27 15 30 25 15 13 18 5 6 26 3 14 19\n",
        "output": "15\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2378,
        "task_id": 4064,
        "test_case_id": 23,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "18 14 11 12\n2 7 10 2 7 5 7 8 7 3 5 3 13 4 9 12 11 13\n",
        "output": "5\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2379,
        "task_id": 4064,
        "test_case_id": 24,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "58 48 36 38\n23 4 23 23 33 19 14 7 10 22 17 8 37 39 5 31 3 38 43 20 24 12 12 16 31 44 21 2 10 3 20 12 26 35 12 35 35 34 10 41 42 32 32 9 7 33 39 28 26 34 16 25 39 23 20 4 38 25\n",
        "output": "11\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2380,
        "task_id": 4064,
        "test_case_id": 25,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "62 51 43 50\n40 36 14 6 44 12 23 23 50 37 15 14 21 16 6 9 40 21 20 11 21 6 34 50 40 43 44 30 12 41 28 39 31 34 12 32 9 33 45 9 13 22 48 24 11 5 24 21 46 26 14 47 10 18 42 2 40 30 46 47 22 3\n",
        "output": "21\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2381,
        "task_id": 4064,
        "test_case_id": 26,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "19 1049 1021 1048\n719 396 531 546 95 841 322 880 446 189 352 1027 630 1025 442 715 100 202 30\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2382,
        "task_id": 4064,
        "test_case_id": 27,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "45 20 9 13\n17 8 1 16 3 19 4 12 1 2 15 18 11 13 9 8 7 17 6 7 8 13 9 12 17 4 19 8 4 4 9 2 16 11 14 7 13 6 9 3 13 2 10 16 9\n",
        "output": "16\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2383,
        "task_id": 4064,
        "test_case_id": 28,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "62 50 31 34\n46 2 7 35 5 5 22 18 18 40 44 4 39 44 3 19 34 9 18 7 26 42 16 31 45 47 21 27 8 46 47 4 34 14 18 1 17 3 19 32 34 26 5 1 25 3 39 45 11 29 8 38 8 26 36 47 10 43 46 24 6 31\n",
        "output": "13\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2384,
        "task_id": 4064,
        "test_case_id": 29,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "2 24 22 23\n22 2\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2385,
        "task_id": 4064,
        "test_case_id": 30,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "2 239 168 204\n126 42\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2386,
        "task_id": 4064,
        "test_case_id": 31,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "39 14 6 10\n1 10 13 7 6 11 1 2 2 11 6 3 10 3 13 7 4 5 8 7 9 12 5 9 8 3 8 4 2 13 5 7 6 3 11 8 2 11 12\n",
        "output": "25\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2387,
        "task_id": 4064,
        "test_case_id": 32,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "34 584 462 583\n322 435 136 39 116 537 250 567 240 488 502 112 548 32 24 543 221 38 133 32 502 285 429 155 188 429 339 23 354 234 267 86 494 274\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2388,
        "task_id": 4064,
        "test_case_id": 33,
        "question": "Vova had a pretty weird sleeping schedule. There are $h$ hours in a day. Vova will sleep exactly $n$ times. The $i$-th time he will sleep exactly after $a_i$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $0$). Each time Vova sleeps exactly one day (in other words, $h$ hours).\n\nVova thinks that the $i$-th sleeping time is good if he starts to sleep between hours $l$ and $r$ inclusive.\n\nVova can control himself and before the $i$-th time can choose between two options: go to sleep after $a_i$ hours or after $a_i - 1$ hours.\n\nYour task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Input-----\n\nThe first line of the input contains four integers $n, h, l$ and $r$ ($1 \\le n \\le 2000, 3 \\le h \\le 2000, 0 \\le l \\le r < h$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i < h$), where $a_i$ is the number of hours after which Vova goes to sleep the $i$-th time.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.\n\n\n-----Example-----\nInput\n7 24 21 23\n16 17 14 20 20 11 22\n\nOutput\n3\n\n\n\n-----Note-----\n\nThe maximum number of good times in the example is $3$.\n\nThe story starts from $t=0$. Then Vova goes to sleep after $a_1 - 1$ hours, now the time is $15$. This time is not good. Then Vova goes to sleep after $a_2 - 1$ hours, now the time is $15 + 16 = 7$. This time is also not good. Then Vova goes to sleep after $a_3$ hours, now the time is $7 + 14 = 21$. This time is good. Then Vova goes to sleep after $a_4 - 1$ hours, now the time is $21 + 19 = 16$. This time is not good. Then Vova goes to sleep after $a_5$ hours, now the time is $16 + 20 = 12$. This time is not good. Then Vova goes to sleep after $a_6$ hours, now the time is $12 + 11 = 23$. This time is good. Then Vova goes to sleep after $a_7$ hours, now the time is $23 + 22 = 21$. This time is also good.",
        "solutions": "[\"def main():\\n    import sys\\n    input = sys.stdin.readline\\n\\n    N, H, L, R = list(map(int, input().split()))\\n    A = list(map(int, input().split()))\\n\\n    dp = [[-1] * H for _ in range(N+1)]\\n    dp[0][0] = 0\\n    for i, a in enumerate(A):\\n        for t in range(H):\\n            if dp[i][t] >= 0:\\n                dp[i+1][(t+a)%H] = max(dp[i+1][(t+a)%H], dp[i][t] + int(L <= (t+a)%H <= R))\\n                dp[i + 1][(t + a-1) % H] = max(dp[i + 1][(t + a-1) % H], dp[i][t] + int(L <= (t + a-1) % H <= R))\\n    print(max(dp[-1]))\\n\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"#!/usr/bin/env python3\\nimport sys\\ninput = sys.stdin.readline\\n\\nn, h, l, r = map(int, input().split())\\na = [int(item) for item in input().split()]\\ndp = [[-1] * h for _ in range(n + 1)]\\ndp[0][0] = 0\\n\\nfor i, item in enumerate(a):\\n    for j in range(h):\\n        if dp[i][j] == -1:\\n            continue\\n        # Sleep early\\n        nt = (j + item) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\n        # Sleep normaly\\n        nt = (j + item - 1 + h) % h\\n        if l <= nt <= r:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j] + 1)\\n        else:\\n            dp[i+1][nt] = max(dp[i+1][nt], dp[i][j])\\nprint(max(dp[-1]))\", \"n,h,l,r = map(int, input().split())\\na = list(map(int, input().split()))\\ndp = [[-1]*h for _ in range(n+1)]\\ndp[0][0] = 0\\nfor i in range(n):\\n    for j in range(h):\\n        if dp[i][j] < 0: continue\\n        dp[i+1][(j+a[i])%h] = max(dp[i+1][(j+a[i])%h], dp[i][j] + (l <= (j+a[i])%h <= r))\\n        dp[i+1][(j+a[i]-1)%h] = max(dp[i+1][(j+a[i]-1)%h], dp[i][j] + (l <= (j+a[i]-1)%h <= r))\\nprint(max(dp[-1]))\", \"def go():\\n    n, h, l, r = list(map(int, input().split()))\\n    # n = int(input())\\n    a = list(map(int, input().split()))\\n    prev = [0]\\n    s = 0\\n    mx = 0\\n    for i, aa in enumerate(a, 1):\\n        cur = []\\n        s += aa\\n        for delay in range(i+1):\\n            g = 1 if l <= (s - delay + h) % h <= r else 0\\n            if delay==0:\\n                cur.append(prev[delay]+g)\\n            elif delay==i:\\n                cur.append(prev[delay-1] + g)\\n            else:\\n                cur.append(max(prev[delay],prev[delay-1])+g)\\n        prev = cur\\n        mx = max(mx,max(cur))\\n    return mx\\n\\n\\n# t = int(input())\\nfor _ in range(1):\\n    print(go())\\n\", \"import sys\\n\\ndef solve():\\n    input = sys.stdin.readline\\n    N, H, L, R = map(int, input().split())\\n    A = [int(a) for a in input().split()]\\n    DP = [[-1] * H for _ in range(N)]\\n    DP[0][A[0]] = (1 if L <= A[0] <= R else 0)\\n    DP[0][A[0] - 1] = (1 if L <= A[0] - 1 <= R else 0)\\n    for i in range(1, N):\\n        for h in range(H):\\n            add = (1 if L <= h <= R else 0)\\n            if DP[i-1][(h - A[i]) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i]) % H] + add)\\n            if DP[i-1][(h - A[i] + 1) % H] > -1: DP[i][h] = max(DP[i][h], DP[i-1][(h - A[i] + 1) % H] + add)\\n    print(max(DP[N-1]))\\n    return 0\\n\\ndef __starting_point():\\n    solve()\\n__starting_point()\", \"\\nn,h,l,r = list(map(int,input().split()))\\nN = n\\n\\na = list(map(int,input().split()))\\n\\nflag = True\\ni = -1\\nlis = [float(\\\"-inf\\\")] * h\\nlis[0] = 0\\nans = 0\\n\\nfor i in range(N):\\n\\n    nlis = [float(\\\"-inf\\\")] * h\\n\\n    na = a[i]\\n    for j in range(h):\\n\\n        if l <= (j+na)%h <= r:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na) % h] = max(nlis[(j+na) % h] , lis[j])\\n\\n        \\n\\n        if l <= (j+na-1)%h <= r:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j] + 1)\\n        else:\\n            nlis[(j+na-1) % h] = max(nlis[(j+na-1) % h] , lis[j])\\n\\n            \\n\\n    lis = nlis\\n    #print (lis)\\n    \\nprint(max(0,max(lis)))\\n\", \"from itertools import accumulate\\nn,h,l,r = map(int,input().split())\\na = list(map(int,input().split()))\\nacc = [0]+list(accumulate(a))\\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\\nfor i in range(1,n+1):\\n  for j in range(i+1):\\n    x = (acc[i]-j)%h\\n    if j == 0:\\n      if l<=x<=r:\\n        dp[i][j] = dp[i-1][j]+1\\n      else:\\n        dp[i][j] = dp[i-1][j]\\n    else:\\n      if l<=x<=r:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])+1\\n      else:\\n        dp[i][j] = max(dp[i-1][j-1],dp[i-1][j])\\nprint(max(dp[n]))\", \"import sys\\ninput = sys.stdin.readline\\n\\nn,h,l,r=list(map(int,input().split()))\\nA=list(map(int,input().split()))\\n\\nDP=[-1]*h\\nDP[0]=0\\n\\nfor a in A:\\n    NDP=[-1]*h\\n    for k in range(h):\\n        if DP[k]==-1:\\n            continue\\n        if l<=(a+k)%h<=r:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k)%h]=max(NDP[(a+k)%h],DP[k])\\n            \\n        if l<=(a+k-1)%h<=r:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k]+1)\\n        else:\\n            NDP[(a+k-1)%h]=max(NDP[(a+k-1)%h],DP[k])\\n            \\n    DP=NDP\\n\\nprint(max(DP))\\n        \\n    \\n\\n\", \"import copy\\nn,h,l,r=map(int,input().split())\\nA=list(map(int,input().split()))\\nV=[0]*h\\nV[0]=1\\nG=[0]*h\\nfor i in range(n):\\n    R=[0]*h\\n    RG=[0]*h\\n    for j in range(h):\\n        if V[j]==1:\\n            X=(j+A[i])%h\\n            Y=(j+A[i]+h-1)%h\\n            R[X]=R[Y]=1\\n            if l<=X<=r: RG[X]=max(RG[X],1+G[j])\\n            else: RG[X]=max(RG[X],G[j])\\n            if l<=Y<=r: RG[Y]=max(RG[Y],1+G[j])\\n            else: RG[Y]=max(RG[Y],G[j])\\n    V=R\\n    G=RG\\nprint(max(G))\"]",
        "difficulty": "introductory",
        "input": "58 4 1 3\n3 2 2 2 3 2 2 1 3 3 2 1 3 2 2 2 3 1 2 2 3 2 3 3 2 3 2 3 2 1 3 2 3 3 2 2 2 2 2 2 2 1 1 3 2 1 1 2 2 3 3 2 2 1 1 1 2 1\n",
        "output": "58\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1324/E"
    },
    {
        "id": 2389,
        "task_id": 4102,
        "test_case_id": 1,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "373\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2390,
        "task_id": 4102,
        "test_case_id": 2,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "121\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2391,
        "task_id": 4102,
        "test_case_id": 3,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "436\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2392,
        "task_id": 4102,
        "test_case_id": 4,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "7\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2393,
        "task_id": 4102,
        "test_case_id": 5,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "8\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2394,
        "task_id": 4102,
        "test_case_id": 6,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "4357087936\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2395,
        "task_id": 4102,
        "test_case_id": 7,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "806975480\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2396,
        "task_id": 4102,
        "test_case_id": 8,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "3333333333\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2397,
        "task_id": 4102,
        "test_case_id": 9,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "90785\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2398,
        "task_id": 4102,
        "test_case_id": 10,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "7467467\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2399,
        "task_id": 4102,
        "test_case_id": 11,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "64\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2400,
        "task_id": 4102,
        "test_case_id": 12,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "584609\n",
        "output": "Yes\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2401,
        "task_id": 4102,
        "test_case_id": 13,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "69154\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2402,
        "task_id": 4102,
        "test_case_id": 14,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "363567\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2403,
        "task_id": 4102,
        "test_case_id": 15,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "557654\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2404,
        "task_id": 4102,
        "test_case_id": 16,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "772961\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2405,
        "task_id": 4102,
        "test_case_id": 17,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "788958\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2406,
        "task_id": 4102,
        "test_case_id": 18,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "992045\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2407,
        "task_id": 4102,
        "test_case_id": 19,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "116325\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2408,
        "task_id": 4102,
        "test_case_id": 20,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "320432\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2409,
        "task_id": 4102,
        "test_case_id": 21,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "314729\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2410,
        "task_id": 4102,
        "test_case_id": 22,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "531816\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2411,
        "task_id": 4102,
        "test_case_id": 23,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "673902416\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2412,
        "task_id": 4102,
        "test_case_id": 24,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "880089713\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2413,
        "task_id": 4102,
        "test_case_id": 25,
        "question": "-----Input-----\n\nThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.\n\n\n-----Output-----\n\nOutput \"Yes\" or \"No\".\n\n\n-----Examples-----\nInput\n373\n\nOutput\nYes\n\nInput\n121\n\nOutput\nNo\n\nInput\n436\n\nOutput\nYes",
        "solutions": "[\"import sys\\nimport time\\n\\nfor line in sys.stdin:\\n    ll = len(line) - 1\\n    fail = 0\\n    for i in range(ll):\\n        if i == ll - 1 - i:\\n            if int(line[i]) not in [3, 7]:\\n                fail = 1\\n            continue\\n        x = int(line[i])\\n        y = int(line[ll - 1 - i])\\n        if (x, y) not in [(3, 3), (4, 6), (6, 4), (7, 7), (8, 0), (0, 8), (5, 9), (9, 5)]:\\n            fail = 1\\n    if fail:\\n        print(\\\"No\\\")\\n    if not fail:\\n        print(\\\"Yes\\\")\\n\", \"f = {'0' : '23', '1' : '10', '2' : '30', '3' : '11', '4' : '13', '5' : '12', '6' : '31', '7' : '33', '8' : '32', '9' : '21'}\\nn = input()\\ns = ''\\nfor i in n: s += f[i]\\ndef check(s):\\n    for i in range(len(s)):\\n        if s[i] != s[-i - 1]: return 0;\\n    return 1;\\nprint('Yes' if check(s) else 'No')\\n\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\\n\", \"import sys\\n\\ns = input()\\npairs = [(3, 3), (4, 6), (5, 9), (6, 4), (7, 7), (8, 0), (9, 5), (0, 8)]\\n\\nfor l in range(len(s) // 2 + 1):\\n    r = len(s) - l - 1\\n    if l == r and int(s[l]) not in [3, 7]:\\n        print(\\\"No\\\")\\n        return\\n    elif (int(s[l]), int(s[r])) not in pairs:\\n        print(\\\"No\\\")\\n        return\\n\\nprint(\\\"Yes\\\")\", \"m={}\\nm['0']='8'\\nm['1']='x'\\nm['2']='x'\\nm['3']='3'\\nm['4']='6'\\nm['5']='9'\\nm['6']='4'\\nm['7']='7'\\nm['8']='0'\\nm['9']='5'\\n\\nx = list(input())\\ny = list(reversed([m[c] for c in x]))\\nprint('Yes' if x==y else 'No')\\n\", \"n = input()\\n\\nfor i in range(len(n)):\\n\\tif (n[i] == '1' or n[i] == '2'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif ((n[i] == '3' or n[i] == '7') and n[-i - 1] != n[i]):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '4' and n[-i - 1] != '6'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '6' and n[-i - 1] != '4'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '5' and n[-i - 1] != '9'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '9' and n[-i - 1] != '5'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '8' and n[-i - 1] != '0'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\telif (n[i] == '0' and n[-i - 1] != '8'):\\n\\t\\tprint(\\\"No\\\")\\n\\t\\treturn\\n\\t\\nprint(\\\"Yes\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\\n\", \"a={'3':'3','4':'6','6':'4','5':'9','9':'5','7':'7','8':'0','0':'8','1':'x','2':'x'}\\ns=input()\\nf=1\\nfor i in range(len(s)):\\n    if s[i]!=a[s[len(s)-i-1]]:f=0\\nif f:print(\\\"Yes\\\")\\nelse:print(\\\"No\\\")\\n\", \"def solve(s):\\n    s1 = [' *', '* ', '* ', '**', '**', '* ', '**', '**', '* ', ' *']\\n    s2 = ['**', '  ', '* ', '  ', ' *', ' *', '* ', '**', '**', '* ']\\n    x, y = '', ''\\n    for ch in s:\\n        x += s1[ord(ch) - ord('0')]\\n        y += s2[ord(ch) - ord('0')]\\n    return x == x[::-1] and y == y[::-1]\\nprint('Yes' if solve(input()) else 'No')\\n\", \"mp = [ 8, -1, -1, 3, 6, 9, 4, 7, 0, 5 ]\\n\\nstr = input()\\n\\nfor i in range( len( str ) ):\\n  if ord( str[ i ] ) - ord( '0' ) != mp[ ord( str[ len( str ) - 1 - i ] ) - ord( '0' ) ]:\\n    exit( print( \\\"No\\\" ) )\\n\\nprint( \\\"Yes\\\" )\\n\", \"d = {\\n  '0': '8',\\n  '1': -1,\\n  '2': -1,\\n  '3': '3',\\n  '4': '6',\\n  '5': '9',\\n  '6': '4',\\n  '8': '0',\\n  '7': '7',\\n  '9': '5',\\n}\\n\\ns = input()\\nprint(\\\"Yes\\\" if list(s)[::-1] == list([d[c] for c in s]) else \\\"No\\\")\", \"mirror = [8, -1, -1, 3, 6, 9, 4, 7, 0, 5]\\ndef dg(n):\\n    if n:\\n        res = []\\n        while n:    \\n            res.append(n%10)\\n            n //= 10\\n    else:\\n        res = [0]\\n    return res\\n    \\nn = int(input())\\ndg1 = dg(n)\\ndg2 = [mirror[d] for d in reversed(dg1)]\\nif dg1 == dg2:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"m=[8,-1,-1,3,6,9,4,7,0,5]\\na=input()\\nl=len(a)\\nprint('Yes'if all(m[ord(a[i])-48]==ord(a[l-i-1])-48 for i in range(l))else'No')\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\\n\", \"s=input()\\nr=s\\ns=s.replace('6','a')\\ns=s.replace('4','6')\\ns=s.replace('a','4')\\ns=s.replace('5','a')\\ns=s.replace('9','5')\\ns=s.replace('a','9')\\ns=s.replace('8','a')\\ns=s.replace('0','8')\\ns=s.replace('a','0')\\ns=s.replace('1','a')\\ns=s.replace('2','a')\\nprint(\\\"YNeos\\\"[r!=s[::-1]::2])\", \"s=input()\\ns1=''\\nfor i in s:\\n    if i=='0':\\n        s1+='8'\\n    elif i=='1':\\n        s1+=''\\n    elif i=='2':\\n        s1+=''\\n    elif i=='3':\\n        s1+='3'\\n    elif i=='4':\\n        s1+='6'\\n    elif i=='5':\\n        s1+='9'\\n    elif i=='6':\\n        s1+='4'\\n    elif i=='7':\\n        s1+='7'\\n    elif i=='8':\\n        s1+='0'\\n    elif i=='9':\\n        s1+='5'\\nif s!=s1[::-1]:\\n    print('No')\\nelse:\\n    print('Yes')\\n#print(' '.join([str(i) for i in a]))\\n\", \"d = {'0': '8', '3': '3', '4': '6', '5': '9',\\n     '6': '4', '7': '7', '8': '0', '9': '5'}\\ns = input()\\ns1 = ''.join(d[c] for c in reversed(s) if c in d)\\nif s == s1:\\n    print('Yes')\\nelse:\\n    print('No')\", \"# \\u2801\\u2803\\u2809\\u2819\\u2811\\u280b\\u281b\\u2813\\u280a\\u281a\\n# 1234567890\\n\\nR = [\\n    (\\\"1\\\", \\\"' \\\"),\\n    (\\\"2\\\", \\\": \\\"),\\n    (\\\"3\\\", \\\"''\\\"),\\n    (\\\"4\\\", \\\"':\\\"),\\n    (\\\"5\\\", \\\"'.\\\"),\\n    (\\\"6\\\", \\\":'\\\"),\\n    (\\\"7\\\", \\\"::\\\"),\\n    (\\\"8\\\", \\\":.\\\"),\\n    (\\\"9\\\", \\\".'\\\"),\\n    (\\\"0\\\", \\\".:\\\"),\\n]\\n\\ns = input()\\nfor a,b in R:\\n    s = s.replace(a,b)\\nprint(\\\"Yes\\\" if s==s[::-1] else \\\"No\\\")\\n\", \"n=str(input())\\ns=''\\nfor i in range(len(n)):\\n\\tif(n[i]=='1' or n[i]=='2'):\\n\\t\\ts=s+'.'\\n\\telif(n[i]=='3' or n[i]=='7'):\\n\\t\\ts=s+n[i]\\n\\telif(n[i]=='4'):\\n\\t\\ts=s+'6'\\n\\telif(n[i]=='6'):\\n\\t\\ts=s+'4'\\n\\telif(n[i]=='5'):\\n\\t\\ts=s+'9'\\n\\telif(n[i]=='9'):\\n\\t\\ts=s+'5'\\n\\telif(n[i]=='0'):\\n\\t\\ts=s+'8'\\n\\telif(n[i]=='8'):\\n\\t\\ts=s+'0'\\nk=''\\nfor i in range(len(n)-1,-1,-1):\\n\\tk=k+s[i]\\nif(k!=n):\\n\\tprint(\\\"No\\\")\\nelse:\\n\\tprint(\\\"Yes\\\")\", \"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))]))(input())])\", \"p = input()\\nl = len(p) - 1\\nans = \\\"\\\"\\ns=[\\\"23\\\", \\\"10\\\", \\\"30\\\", \\\"11\\\", \\\"13\\\", \\\"12\\\", \\\"31\\\", \\\"33\\\", \\\"32\\\",\\\"21\\\"]\\nfor x in p:\\n    ans+=s[ord(x) -48]\\nif ans == ans[::-1]:\\n    print(\\\"Yes\\\")\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\", \"def k(s):\\n\\tn = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n\\tfor i in range(len(s)):\\n\\t\\tif n[int(s[i])] != int(s[len(s) - i - 1]):\\n\\t\\t\\treturn False\\n\\treturn True\\ns = input()\\nif k(s):\\n\\tprint('Yes')\\nelse:\\n\\tprint(\\\"No\\\")\", \"def _bool(s):\\n    a = (8, -1, -1, 3, 6, 9, 4, 7, 0, 5)\\n    for i in range(len(s)):\\n        if a[int(s[i])] != int(s[len(s) - i - 1]):\\n            return False\\n    return True\\ns = input()\\nif _bool(s):\\n    print('Yes')\\nelse:\\n    print(\\\"No\\\")\", \"a=input()\\nd={\\\"0\\\":\\\"8\\\",\\\"1\\\":\\\"-\\\",\\\"2\\\":\\\"-\\\",\\\"3\\\":\\\"3\\\",\\\"4\\\":\\\"6\\\",\\\"5\\\":\\\"9\\\",\\\"6\\\":\\\"4\\\",\\\"7\\\":\\\"7\\\",\\\"8\\\":\\\"0\\\",\\\"9\\\":\\\"5\\\"}\\nfor i in range(len(a)):\\n    if d[a[i]]!=a[len(a)-i-1]:\\n        print(\\\"No\\\")\\n        return\\nprint(\\\"Yes\\\")\"]",
        "difficulty": "introductory",
        "input": "004176110\n",
        "output": "No\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/784/D"
    },
    {
        "id": 2414,
        "task_id": 4281,
        "test_case_id": 1,
        "question": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coordinate $x_i-1$, $x_i+1$ or stay at $x_i$. Each friend is allowed to move no more than once.\n\nFor all friends $1 \\le x_i \\le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$, respectively).\n\nFor example, let the initial positions be $x = [1, 2, 4, 4]$. The final ones then can be $[1, 3, 3, 4]$, $[0, 2, 3, 3]$, $[2, 2, 5, 5]$, $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.\n\nSo all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of friends.\n\nThe second line contains $n$ integers $x_1, x_2, \\dots, x_n$ ($1 \\le x_i \\le n$) — the coordinates of the houses of the friends.\n\n\n-----Output-----\n\nPrint two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.\n\n\n-----Examples-----\nInput\n4\n1 2 4 4\n\nOutput\n2 4\n\nInput\n9\n1 1 8 8 8 4 4 4 4\n\nOutput\n3 8\n\nInput\n7\n4 3 7 1 4 3 3\n\nOutput\n3 6\n\n\n\n-----Note-----\n\nIn the first example friends can go to $[2, 2, 3, 3]$. So friend $1$ goes to $x_1+1$, friend $2$ stays at his house $x_2$, friend $3$ goes to $x_3-1$ and friend $4$ goes to $x_4-1$. $[1, 1, 3, 3]$, $[2, 2, 3, 3]$ or $[2, 2, 4, 4]$ are also all valid options to obtain $2$ occupied houses.\n\nFor the maximum number of occupied houses friends can go to $[1, 2, 3, 4]$ or to $[0, 2, 4, 5]$, for example.",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nprev=-2\\nc=0\\nfor i in a:\\n    dif=i-prev\\n    if dif > 1:\\n        prev=i+1\\n        c+=1\\nac=0\\nlc=-2\\nfor i in a:\\n    if lc < i-1:\\n        lc=i-1\\n        ac+=1\\n    elif lc == i-1:\\n        lc=i\\n        ac+=1\\n    elif lc == i:\\n        lc=i+1\\n        ac+=1\\nprint(c,ac)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmx=[0]*(n+2)\\nmn=[0]*(n+2)\\nl.sort()\\nfor i in l:\\n\\tif mx[i-1]==0:\\n\\t\\tmx[i-1]=1\\n\\telif mx[i]==0:\\n\\t\\tmx[i]=1\\n\\telse:\\n\\t\\tmx[i+1]=1\\n\\tif mn[i]==mn[i-1] and mn[i-1]==mn[i+1] and mn[i+1]==0:\\n\\t\\tmn[i+1]=1\\nprint(sum(mn),sum(mx))\\n\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nminh = set()\\nmaxh = set()\\n\\nfor e in ls:\\n    if e-1 not in maxh:\\n        maxh.add(e-1)\\n    elif e not in maxh:\\n        maxh.add(e)\\n    else:\\n        maxh.add(e+1)\\n\\n    if e-1 not in minh and e not in minh and e+1 not in minh:\\n        minh.add(e+1)\\n\\nprint(len(minh), len(maxh))\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\nA.sort()\\n\\nB={A[0]-1}\\nC={A[0]+1}\\n\\nfor i in range(1,n):\\n    if A[i]-1 in B and A[i] in B:\\n        B.add(A[i]+1)\\n    elif A[i]-1 in B:\\n        B.add(A[i])\\n    else:\\n        B.add(A[i]-1)\\n\\n    if A[i]-1 in C or A[i] in C:\\n        continue\\n    else:\\n        C.add(A[i]+1)\\n\\nprint(len(C),len(B))\\n        \\n\", \"n = int(input())\\nv = list(map(int, input().split()))\\nvaz = [0 for x in range(n+10)]\\nvaz1 = [0 for x in range(n+10)]\\nfor x in v:\\n    vaz[x] += 1\\nans1 = 0\\npz = 1\\nwhile pz<=n:\\n    if vaz[pz]==0:\\n        pz +=1\\n        continue\\n    ans1 +=1\\n    pz+=3\\nfor i in range(1,n+1):\\n    if vaz[i] == 0:\\n        continue\\n    a = vaz[i]\\n    if vaz1[i-1]==0 and a>0:\\n        a-=1\\n        vaz1[i-1]=1\\n    if vaz1[i]==0 and a>0:\\n        a-=1\\n        vaz1[i]=1\\n    if vaz1[i+1]==0 and a>0:\\n        a-=1\\n        vaz1[i+1]=1\\nans2 = 0\\nfor i in range(0,n+2):\\n    if vaz1[i]==1:\\n        ans2+=1\\nprint(str(ans1)+\\\" \\\"+str(ans2))\\n\", \"import sys\\nfrom operator import itemgetter\\nfrom collections import deque\\n\\ndef input():\\n    return sys.stdin.readline().strip()\\n\\ndef getmin(houses):\\n    i = 0\\n    ans = 0\\n    while len(houses)>0:\\n        x = houses.popleft()\\n        while len(houses)>0 and houses[0]<=x+2:\\n            houses.popleft()\\n        ans+=1\\n    return ans\\n\\ndef getmax(houses):\\n    vis = set()\\n    for x in houses:\\n        if x-1 not in vis:\\n            vis.add(x-1)\\n        elif x not in vis:\\n            vis.add(x)\\n        else:\\n            vis.add(x+1)\\n    return len(vis)\\n                \\n\\n\\nn = int(input())\\n\\nhouses = list(map(int, input().split()))\\nhouses.sort()\\nprint(getmin(deque(houses)), getmax(houses))\", \"n=int(input())\\nar=list(map(int,input().split()))\\nused1=[0]*(n+3)\\nused2=[0]*(n+3)\\nar.sort()\\nkol=0\\nfor i in range(n):\\n\\tif used1[ar[i]-1]==0:\\n\\t\\tif used1[ar[i]]==0:\\n\\t\\t\\tif used1[ar[i]+1]==0:\\n\\t\\t\\t\\tkol+=1\\n\\t\\t\\t\\tused1[ar[i]]=1\\n\\t\\t\\t\\tused1[ar[i]+1]=1\\n\\t\\t\\t\\tused1[ar[i]-1]=1\\nprint(kol,end=' ')\\nkol1=0\\nfor i in ar:\\n\\tif used2[i-1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i-1]=1\\n\\telif used2[i]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i]=1\\n\\telif used2[i+1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i+1]=1\\nprint(kol1)\\n\\n\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\n#print(l)\\nll = l.copy()\\nup = 1\\nleft = l[0]\\nfor i in range(n):\\n\\tif l[i] > left + 2:\\n\\t\\tleft = l[i]\\n\\t\\tup += 1\\n#print(up)\\n#print(ll)\\nll[0] -= 1\\n#print(ll)\\nfor i in range(1,n-1):\\n\\tif ll[i-1] == ll[i]:\\n\\t\\tif ll[i] != ll[i+1]:\\n\\t\\t\\tll[i] += 1\\n\\telif ll[i-1] == ll[i]-1:\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tll[i] -= 1\\n\\t#print(ll)\\nll[n-1] += 1\\n#print(ll)\\nd = {}\\nfor i in ll:\\n\\td[i] = 0\\nnajw = len(d)\\nprint(up, najw)\\n\", \"\\nn = int(input())\\n\\nx = list(map(int,input().split()))\\n\\nx.sort()\\n\\n\\ny = [] #to min\\n\\nfor i in range(n):\\n    if i == 0 or x[i-1] != x[i]:\\n        y.append(x[i])\\n\\nyend = [True] * len(y)\\nansmin = len(y)\\n\\nfor i in range(len(y)):\\n\\n    if i == 0 or ( not yend[i] ):\\n        continue\\n\\n    if y[i-1] + 1 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        ansmin -= 1\\n        yend[i] = False\\n\\n        if i+1 < len(y) and y[i+1] - 1 == y[i]:\\n            yend[i+1] = False\\n            ansmin -= 1\\n\\n    elif y[i-1] + 2 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        yend[i] = False\\n        ansmin -= 1\\n \\n#print (yend)\\n\\n\\ndic = {}\\n\\nfor i in range(n):\\n\\n    if x[i] - 1 not in dic:\\n        dic[x[i] - 1] = 1\\n    elif x[i] not in dic:\\n        dic[x[i]] = 1\\n    else:\\n        dic[x[i] + 1] = 1\\n\\nprint (ansmin , len(dic))\", \"from itertools import*\\n_,x=open(0)\\nx=sorted(map(int,x.split()))\\ni,*y=sorted(set(x))\\ns={i+1}\\nfor i in y:\\n  if not(i-1in s or i in s):\\n    s.add(i+1)\\nprint(len(s),end=' ')\\ns=set()\\nfor i,t in groupby(x):\\n  t=len(list(t))\\n  if not i-1in s and t:\\n    s.add(i-1)\\n    t-=1\\n  if not i in s and t:\\n    s.add(i)\\n    t-=1\\n  if not i+1in s and t:\\n    s.add(i+1)\\nprint(len(s))\", \"import sys\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef solve():\\n\\tn = mint()\\n\\tx = list(mints())\\n\\tx.sort()\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tc = [0]*(n+2)\\n\\tfor i in x:\\n\\t\\tc[i] += 1\\n\\t\\tif w[i-1] == 0:\\n\\t\\t\\tw[i-1] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i] == 0:\\n\\t\\t\\tw[i] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i+1] == 0:\\n\\t\\t\\tw[i+1] += 1\\n\\t\\t\\tr += 1\\n\\n\\trm = r\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tfor i in range(1,n+1):\\n\\t\\tv = c[i]\\n\\t\\tif v != 0:\\n\\t\\t\\tif w[i+1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i-1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telse:\\n\\t\\t\\t\\tw[i+1] += v\\n\\t\\t\\t\\tr += 1\\n\\tprint(r,rm)\\n\\n#for i in range(mint()):\\nsolve()\\n\", \"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\\n# M = 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)))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split(' ')]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n').split(' ')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\nn = val()\\nl = li()\\nl1 = l[:]\\nl2 = l[:]\\n\\ni = 0\\nl1 = sorted(list(set(l1)))\\ndoit = tot1 = 0\\ncn = Counter(l1)\\nl = l1[:]\\nwhile i < len(l1):\\n    if cn[l[i] - 1] > 0:\\n        cn[l[i]] -= 1\\n        cn[l[i] - 1] += 1\\n        l[i] -= 1\\n        i += 1\\n    else:\\n        cn[l[i]] -= 1\\n        cn[l[i] + 1] += 1\\n        l[i] += 1\\n        if i<len(l1) - 1 and l[i + 1] == l[i]:i += 2\\n        else:i += 1\\n# print(cn)\\ntot1 = sum(1 for i in cn if cn[i])\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n# print(l1)\\n\\n\\n\\ni = 0\\n\\ncnt = Counter(l2)\\nl2 = sorted(l2)\\n\\nl = l2[:]\\n\\n\\n\\nfor i in range(n):\\n    if cnt[l[i] - 1] == 0:\\n        cnt[l[i] - 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] -= 1\\n    elif cnt[l[i]] > 1:\\n        cnt[l[i] + 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] += 1\\n\\n\\ntot2 = sum(1 for i in cnt if cnt[i])\\n\\n\\n\\n\\n\\nprint(tot1,tot2)\"]",
        "difficulty": "introductory",
        "input": "4\n1 2 4 4\n",
        "output": "2 4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1283/E"
    },
    {
        "id": 2415,
        "task_id": 4281,
        "test_case_id": 2,
        "question": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coordinate $x_i-1$, $x_i+1$ or stay at $x_i$. Each friend is allowed to move no more than once.\n\nFor all friends $1 \\le x_i \\le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$, respectively).\n\nFor example, let the initial positions be $x = [1, 2, 4, 4]$. The final ones then can be $[1, 3, 3, 4]$, $[0, 2, 3, 3]$, $[2, 2, 5, 5]$, $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.\n\nSo all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of friends.\n\nThe second line contains $n$ integers $x_1, x_2, \\dots, x_n$ ($1 \\le x_i \\le n$) — the coordinates of the houses of the friends.\n\n\n-----Output-----\n\nPrint two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.\n\n\n-----Examples-----\nInput\n4\n1 2 4 4\n\nOutput\n2 4\n\nInput\n9\n1 1 8 8 8 4 4 4 4\n\nOutput\n3 8\n\nInput\n7\n4 3 7 1 4 3 3\n\nOutput\n3 6\n\n\n\n-----Note-----\n\nIn the first example friends can go to $[2, 2, 3, 3]$. So friend $1$ goes to $x_1+1$, friend $2$ stays at his house $x_2$, friend $3$ goes to $x_3-1$ and friend $4$ goes to $x_4-1$. $[1, 1, 3, 3]$, $[2, 2, 3, 3]$ or $[2, 2, 4, 4]$ are also all valid options to obtain $2$ occupied houses.\n\nFor the maximum number of occupied houses friends can go to $[1, 2, 3, 4]$ or to $[0, 2, 4, 5]$, for example.",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nprev=-2\\nc=0\\nfor i in a:\\n    dif=i-prev\\n    if dif > 1:\\n        prev=i+1\\n        c+=1\\nac=0\\nlc=-2\\nfor i in a:\\n    if lc < i-1:\\n        lc=i-1\\n        ac+=1\\n    elif lc == i-1:\\n        lc=i\\n        ac+=1\\n    elif lc == i:\\n        lc=i+1\\n        ac+=1\\nprint(c,ac)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmx=[0]*(n+2)\\nmn=[0]*(n+2)\\nl.sort()\\nfor i in l:\\n\\tif mx[i-1]==0:\\n\\t\\tmx[i-1]=1\\n\\telif mx[i]==0:\\n\\t\\tmx[i]=1\\n\\telse:\\n\\t\\tmx[i+1]=1\\n\\tif mn[i]==mn[i-1] and mn[i-1]==mn[i+1] and mn[i+1]==0:\\n\\t\\tmn[i+1]=1\\nprint(sum(mn),sum(mx))\\n\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nminh = set()\\nmaxh = set()\\n\\nfor e in ls:\\n    if e-1 not in maxh:\\n        maxh.add(e-1)\\n    elif e not in maxh:\\n        maxh.add(e)\\n    else:\\n        maxh.add(e+1)\\n\\n    if e-1 not in minh and e not in minh and e+1 not in minh:\\n        minh.add(e+1)\\n\\nprint(len(minh), len(maxh))\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\nA.sort()\\n\\nB={A[0]-1}\\nC={A[0]+1}\\n\\nfor i in range(1,n):\\n    if A[i]-1 in B and A[i] in B:\\n        B.add(A[i]+1)\\n    elif A[i]-1 in B:\\n        B.add(A[i])\\n    else:\\n        B.add(A[i]-1)\\n\\n    if A[i]-1 in C or A[i] in C:\\n        continue\\n    else:\\n        C.add(A[i]+1)\\n\\nprint(len(C),len(B))\\n        \\n\", \"n = int(input())\\nv = list(map(int, input().split()))\\nvaz = [0 for x in range(n+10)]\\nvaz1 = [0 for x in range(n+10)]\\nfor x in v:\\n    vaz[x] += 1\\nans1 = 0\\npz = 1\\nwhile pz<=n:\\n    if vaz[pz]==0:\\n        pz +=1\\n        continue\\n    ans1 +=1\\n    pz+=3\\nfor i in range(1,n+1):\\n    if vaz[i] == 0:\\n        continue\\n    a = vaz[i]\\n    if vaz1[i-1]==0 and a>0:\\n        a-=1\\n        vaz1[i-1]=1\\n    if vaz1[i]==0 and a>0:\\n        a-=1\\n        vaz1[i]=1\\n    if vaz1[i+1]==0 and a>0:\\n        a-=1\\n        vaz1[i+1]=1\\nans2 = 0\\nfor i in range(0,n+2):\\n    if vaz1[i]==1:\\n        ans2+=1\\nprint(str(ans1)+\\\" \\\"+str(ans2))\\n\", \"import sys\\nfrom operator import itemgetter\\nfrom collections import deque\\n\\ndef input():\\n    return sys.stdin.readline().strip()\\n\\ndef getmin(houses):\\n    i = 0\\n    ans = 0\\n    while len(houses)>0:\\n        x = houses.popleft()\\n        while len(houses)>0 and houses[0]<=x+2:\\n            houses.popleft()\\n        ans+=1\\n    return ans\\n\\ndef getmax(houses):\\n    vis = set()\\n    for x in houses:\\n        if x-1 not in vis:\\n            vis.add(x-1)\\n        elif x not in vis:\\n            vis.add(x)\\n        else:\\n            vis.add(x+1)\\n    return len(vis)\\n                \\n\\n\\nn = int(input())\\n\\nhouses = list(map(int, input().split()))\\nhouses.sort()\\nprint(getmin(deque(houses)), getmax(houses))\", \"n=int(input())\\nar=list(map(int,input().split()))\\nused1=[0]*(n+3)\\nused2=[0]*(n+3)\\nar.sort()\\nkol=0\\nfor i in range(n):\\n\\tif used1[ar[i]-1]==0:\\n\\t\\tif used1[ar[i]]==0:\\n\\t\\t\\tif used1[ar[i]+1]==0:\\n\\t\\t\\t\\tkol+=1\\n\\t\\t\\t\\tused1[ar[i]]=1\\n\\t\\t\\t\\tused1[ar[i]+1]=1\\n\\t\\t\\t\\tused1[ar[i]-1]=1\\nprint(kol,end=' ')\\nkol1=0\\nfor i in ar:\\n\\tif used2[i-1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i-1]=1\\n\\telif used2[i]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i]=1\\n\\telif used2[i+1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i+1]=1\\nprint(kol1)\\n\\n\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\n#print(l)\\nll = l.copy()\\nup = 1\\nleft = l[0]\\nfor i in range(n):\\n\\tif l[i] > left + 2:\\n\\t\\tleft = l[i]\\n\\t\\tup += 1\\n#print(up)\\n#print(ll)\\nll[0] -= 1\\n#print(ll)\\nfor i in range(1,n-1):\\n\\tif ll[i-1] == ll[i]:\\n\\t\\tif ll[i] != ll[i+1]:\\n\\t\\t\\tll[i] += 1\\n\\telif ll[i-1] == ll[i]-1:\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tll[i] -= 1\\n\\t#print(ll)\\nll[n-1] += 1\\n#print(ll)\\nd = {}\\nfor i in ll:\\n\\td[i] = 0\\nnajw = len(d)\\nprint(up, najw)\\n\", \"\\nn = int(input())\\n\\nx = list(map(int,input().split()))\\n\\nx.sort()\\n\\n\\ny = [] #to min\\n\\nfor i in range(n):\\n    if i == 0 or x[i-1] != x[i]:\\n        y.append(x[i])\\n\\nyend = [True] * len(y)\\nansmin = len(y)\\n\\nfor i in range(len(y)):\\n\\n    if i == 0 or ( not yend[i] ):\\n        continue\\n\\n    if y[i-1] + 1 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        ansmin -= 1\\n        yend[i] = False\\n\\n        if i+1 < len(y) and y[i+1] - 1 == y[i]:\\n            yend[i+1] = False\\n            ansmin -= 1\\n\\n    elif y[i-1] + 2 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        yend[i] = False\\n        ansmin -= 1\\n \\n#print (yend)\\n\\n\\ndic = {}\\n\\nfor i in range(n):\\n\\n    if x[i] - 1 not in dic:\\n        dic[x[i] - 1] = 1\\n    elif x[i] not in dic:\\n        dic[x[i]] = 1\\n    else:\\n        dic[x[i] + 1] = 1\\n\\nprint (ansmin , len(dic))\", \"from itertools import*\\n_,x=open(0)\\nx=sorted(map(int,x.split()))\\ni,*y=sorted(set(x))\\ns={i+1}\\nfor i in y:\\n  if not(i-1in s or i in s):\\n    s.add(i+1)\\nprint(len(s),end=' ')\\ns=set()\\nfor i,t in groupby(x):\\n  t=len(list(t))\\n  if not i-1in s and t:\\n    s.add(i-1)\\n    t-=1\\n  if not i in s and t:\\n    s.add(i)\\n    t-=1\\n  if not i+1in s and t:\\n    s.add(i+1)\\nprint(len(s))\", \"import sys\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef solve():\\n\\tn = mint()\\n\\tx = list(mints())\\n\\tx.sort()\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tc = [0]*(n+2)\\n\\tfor i in x:\\n\\t\\tc[i] += 1\\n\\t\\tif w[i-1] == 0:\\n\\t\\t\\tw[i-1] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i] == 0:\\n\\t\\t\\tw[i] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i+1] == 0:\\n\\t\\t\\tw[i+1] += 1\\n\\t\\t\\tr += 1\\n\\n\\trm = r\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tfor i in range(1,n+1):\\n\\t\\tv = c[i]\\n\\t\\tif v != 0:\\n\\t\\t\\tif w[i+1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i-1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telse:\\n\\t\\t\\t\\tw[i+1] += v\\n\\t\\t\\t\\tr += 1\\n\\tprint(r,rm)\\n\\n#for i in range(mint()):\\nsolve()\\n\", \"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\\n# M = 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)))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split(' ')]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n').split(' ')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\nn = val()\\nl = li()\\nl1 = l[:]\\nl2 = l[:]\\n\\ni = 0\\nl1 = sorted(list(set(l1)))\\ndoit = tot1 = 0\\ncn = Counter(l1)\\nl = l1[:]\\nwhile i < len(l1):\\n    if cn[l[i] - 1] > 0:\\n        cn[l[i]] -= 1\\n        cn[l[i] - 1] += 1\\n        l[i] -= 1\\n        i += 1\\n    else:\\n        cn[l[i]] -= 1\\n        cn[l[i] + 1] += 1\\n        l[i] += 1\\n        if i<len(l1) - 1 and l[i + 1] == l[i]:i += 2\\n        else:i += 1\\n# print(cn)\\ntot1 = sum(1 for i in cn if cn[i])\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n# print(l1)\\n\\n\\n\\ni = 0\\n\\ncnt = Counter(l2)\\nl2 = sorted(l2)\\n\\nl = l2[:]\\n\\n\\n\\nfor i in range(n):\\n    if cnt[l[i] - 1] == 0:\\n        cnt[l[i] - 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] -= 1\\n    elif cnt[l[i]] > 1:\\n        cnt[l[i] + 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] += 1\\n\\n\\ntot2 = sum(1 for i in cnt if cnt[i])\\n\\n\\n\\n\\n\\nprint(tot1,tot2)\"]",
        "difficulty": "introductory",
        "input": "9\n1 1 8 8 8 4 4 4 4\n",
        "output": "3 8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1283/E"
    },
    {
        "id": 2416,
        "task_id": 4281,
        "test_case_id": 5,
        "question": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coordinate $x_i-1$, $x_i+1$ or stay at $x_i$. Each friend is allowed to move no more than once.\n\nFor all friends $1 \\le x_i \\le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$, respectively).\n\nFor example, let the initial positions be $x = [1, 2, 4, 4]$. The final ones then can be $[1, 3, 3, 4]$, $[0, 2, 3, 3]$, $[2, 2, 5, 5]$, $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.\n\nSo all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of friends.\n\nThe second line contains $n$ integers $x_1, x_2, \\dots, x_n$ ($1 \\le x_i \\le n$) — the coordinates of the houses of the friends.\n\n\n-----Output-----\n\nPrint two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.\n\n\n-----Examples-----\nInput\n4\n1 2 4 4\n\nOutput\n2 4\n\nInput\n9\n1 1 8 8 8 4 4 4 4\n\nOutput\n3 8\n\nInput\n7\n4 3 7 1 4 3 3\n\nOutput\n3 6\n\n\n\n-----Note-----\n\nIn the first example friends can go to $[2, 2, 3, 3]$. So friend $1$ goes to $x_1+1$, friend $2$ stays at his house $x_2$, friend $3$ goes to $x_3-1$ and friend $4$ goes to $x_4-1$. $[1, 1, 3, 3]$, $[2, 2, 3, 3]$ or $[2, 2, 4, 4]$ are also all valid options to obtain $2$ occupied houses.\n\nFor the maximum number of occupied houses friends can go to $[1, 2, 3, 4]$ or to $[0, 2, 4, 5]$, for example.",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nprev=-2\\nc=0\\nfor i in a:\\n    dif=i-prev\\n    if dif > 1:\\n        prev=i+1\\n        c+=1\\nac=0\\nlc=-2\\nfor i in a:\\n    if lc < i-1:\\n        lc=i-1\\n        ac+=1\\n    elif lc == i-1:\\n        lc=i\\n        ac+=1\\n    elif lc == i:\\n        lc=i+1\\n        ac+=1\\nprint(c,ac)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmx=[0]*(n+2)\\nmn=[0]*(n+2)\\nl.sort()\\nfor i in l:\\n\\tif mx[i-1]==0:\\n\\t\\tmx[i-1]=1\\n\\telif mx[i]==0:\\n\\t\\tmx[i]=1\\n\\telse:\\n\\t\\tmx[i+1]=1\\n\\tif mn[i]==mn[i-1] and mn[i-1]==mn[i+1] and mn[i+1]==0:\\n\\t\\tmn[i+1]=1\\nprint(sum(mn),sum(mx))\\n\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nminh = set()\\nmaxh = set()\\n\\nfor e in ls:\\n    if e-1 not in maxh:\\n        maxh.add(e-1)\\n    elif e not in maxh:\\n        maxh.add(e)\\n    else:\\n        maxh.add(e+1)\\n\\n    if e-1 not in minh and e not in minh and e+1 not in minh:\\n        minh.add(e+1)\\n\\nprint(len(minh), len(maxh))\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\nA.sort()\\n\\nB={A[0]-1}\\nC={A[0]+1}\\n\\nfor i in range(1,n):\\n    if A[i]-1 in B and A[i] in B:\\n        B.add(A[i]+1)\\n    elif A[i]-1 in B:\\n        B.add(A[i])\\n    else:\\n        B.add(A[i]-1)\\n\\n    if A[i]-1 in C or A[i] in C:\\n        continue\\n    else:\\n        C.add(A[i]+1)\\n\\nprint(len(C),len(B))\\n        \\n\", \"n = int(input())\\nv = list(map(int, input().split()))\\nvaz = [0 for x in range(n+10)]\\nvaz1 = [0 for x in range(n+10)]\\nfor x in v:\\n    vaz[x] += 1\\nans1 = 0\\npz = 1\\nwhile pz<=n:\\n    if vaz[pz]==0:\\n        pz +=1\\n        continue\\n    ans1 +=1\\n    pz+=3\\nfor i in range(1,n+1):\\n    if vaz[i] == 0:\\n        continue\\n    a = vaz[i]\\n    if vaz1[i-1]==0 and a>0:\\n        a-=1\\n        vaz1[i-1]=1\\n    if vaz1[i]==0 and a>0:\\n        a-=1\\n        vaz1[i]=1\\n    if vaz1[i+1]==0 and a>0:\\n        a-=1\\n        vaz1[i+1]=1\\nans2 = 0\\nfor i in range(0,n+2):\\n    if vaz1[i]==1:\\n        ans2+=1\\nprint(str(ans1)+\\\" \\\"+str(ans2))\\n\", \"import sys\\nfrom operator import itemgetter\\nfrom collections import deque\\n\\ndef input():\\n    return sys.stdin.readline().strip()\\n\\ndef getmin(houses):\\n    i = 0\\n    ans = 0\\n    while len(houses)>0:\\n        x = houses.popleft()\\n        while len(houses)>0 and houses[0]<=x+2:\\n            houses.popleft()\\n        ans+=1\\n    return ans\\n\\ndef getmax(houses):\\n    vis = set()\\n    for x in houses:\\n        if x-1 not in vis:\\n            vis.add(x-1)\\n        elif x not in vis:\\n            vis.add(x)\\n        else:\\n            vis.add(x+1)\\n    return len(vis)\\n                \\n\\n\\nn = int(input())\\n\\nhouses = list(map(int, input().split()))\\nhouses.sort()\\nprint(getmin(deque(houses)), getmax(houses))\", \"n=int(input())\\nar=list(map(int,input().split()))\\nused1=[0]*(n+3)\\nused2=[0]*(n+3)\\nar.sort()\\nkol=0\\nfor i in range(n):\\n\\tif used1[ar[i]-1]==0:\\n\\t\\tif used1[ar[i]]==0:\\n\\t\\t\\tif used1[ar[i]+1]==0:\\n\\t\\t\\t\\tkol+=1\\n\\t\\t\\t\\tused1[ar[i]]=1\\n\\t\\t\\t\\tused1[ar[i]+1]=1\\n\\t\\t\\t\\tused1[ar[i]-1]=1\\nprint(kol,end=' ')\\nkol1=0\\nfor i in ar:\\n\\tif used2[i-1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i-1]=1\\n\\telif used2[i]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i]=1\\n\\telif used2[i+1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i+1]=1\\nprint(kol1)\\n\\n\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\n#print(l)\\nll = l.copy()\\nup = 1\\nleft = l[0]\\nfor i in range(n):\\n\\tif l[i] > left + 2:\\n\\t\\tleft = l[i]\\n\\t\\tup += 1\\n#print(up)\\n#print(ll)\\nll[0] -= 1\\n#print(ll)\\nfor i in range(1,n-1):\\n\\tif ll[i-1] == ll[i]:\\n\\t\\tif ll[i] != ll[i+1]:\\n\\t\\t\\tll[i] += 1\\n\\telif ll[i-1] == ll[i]-1:\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tll[i] -= 1\\n\\t#print(ll)\\nll[n-1] += 1\\n#print(ll)\\nd = {}\\nfor i in ll:\\n\\td[i] = 0\\nnajw = len(d)\\nprint(up, najw)\\n\", \"\\nn = int(input())\\n\\nx = list(map(int,input().split()))\\n\\nx.sort()\\n\\n\\ny = [] #to min\\n\\nfor i in range(n):\\n    if i == 0 or x[i-1] != x[i]:\\n        y.append(x[i])\\n\\nyend = [True] * len(y)\\nansmin = len(y)\\n\\nfor i in range(len(y)):\\n\\n    if i == 0 or ( not yend[i] ):\\n        continue\\n\\n    if y[i-1] + 1 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        ansmin -= 1\\n        yend[i] = False\\n\\n        if i+1 < len(y) and y[i+1] - 1 == y[i]:\\n            yend[i+1] = False\\n            ansmin -= 1\\n\\n    elif y[i-1] + 2 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        yend[i] = False\\n        ansmin -= 1\\n \\n#print (yend)\\n\\n\\ndic = {}\\n\\nfor i in range(n):\\n\\n    if x[i] - 1 not in dic:\\n        dic[x[i] - 1] = 1\\n    elif x[i] not in dic:\\n        dic[x[i]] = 1\\n    else:\\n        dic[x[i] + 1] = 1\\n\\nprint (ansmin , len(dic))\", \"from itertools import*\\n_,x=open(0)\\nx=sorted(map(int,x.split()))\\ni,*y=sorted(set(x))\\ns={i+1}\\nfor i in y:\\n  if not(i-1in s or i in s):\\n    s.add(i+1)\\nprint(len(s),end=' ')\\ns=set()\\nfor i,t in groupby(x):\\n  t=len(list(t))\\n  if not i-1in s and t:\\n    s.add(i-1)\\n    t-=1\\n  if not i in s and t:\\n    s.add(i)\\n    t-=1\\n  if not i+1in s and t:\\n    s.add(i+1)\\nprint(len(s))\", \"import sys\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef solve():\\n\\tn = mint()\\n\\tx = list(mints())\\n\\tx.sort()\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tc = [0]*(n+2)\\n\\tfor i in x:\\n\\t\\tc[i] += 1\\n\\t\\tif w[i-1] == 0:\\n\\t\\t\\tw[i-1] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i] == 0:\\n\\t\\t\\tw[i] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i+1] == 0:\\n\\t\\t\\tw[i+1] += 1\\n\\t\\t\\tr += 1\\n\\n\\trm = r\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tfor i in range(1,n+1):\\n\\t\\tv = c[i]\\n\\t\\tif v != 0:\\n\\t\\t\\tif w[i+1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i-1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telse:\\n\\t\\t\\t\\tw[i+1] += v\\n\\t\\t\\t\\tr += 1\\n\\tprint(r,rm)\\n\\n#for i in range(mint()):\\nsolve()\\n\", \"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\\n# M = 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)))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split(' ')]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n').split(' ')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\nn = val()\\nl = li()\\nl1 = l[:]\\nl2 = l[:]\\n\\ni = 0\\nl1 = sorted(list(set(l1)))\\ndoit = tot1 = 0\\ncn = Counter(l1)\\nl = l1[:]\\nwhile i < len(l1):\\n    if cn[l[i] - 1] > 0:\\n        cn[l[i]] -= 1\\n        cn[l[i] - 1] += 1\\n        l[i] -= 1\\n        i += 1\\n    else:\\n        cn[l[i]] -= 1\\n        cn[l[i] + 1] += 1\\n        l[i] += 1\\n        if i<len(l1) - 1 and l[i + 1] == l[i]:i += 2\\n        else:i += 1\\n# print(cn)\\ntot1 = sum(1 for i in cn if cn[i])\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n# print(l1)\\n\\n\\n\\ni = 0\\n\\ncnt = Counter(l2)\\nl2 = sorted(l2)\\n\\nl = l2[:]\\n\\n\\n\\nfor i in range(n):\\n    if cnt[l[i] - 1] == 0:\\n        cnt[l[i] - 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] -= 1\\n    elif cnt[l[i]] > 1:\\n        cnt[l[i] + 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] += 1\\n\\n\\ntot2 = sum(1 for i in cnt if cnt[i])\\n\\n\\n\\n\\n\\nprint(tot1,tot2)\"]",
        "difficulty": "introductory",
        "input": "2\n1 1\n",
        "output": "1 2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1283/E"
    },
    {
        "id": 2417,
        "task_id": 4281,
        "test_case_id": 7,
        "question": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coordinate $x_i-1$, $x_i+1$ or stay at $x_i$. Each friend is allowed to move no more than once.\n\nFor all friends $1 \\le x_i \\le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$, respectively).\n\nFor example, let the initial positions be $x = [1, 2, 4, 4]$. The final ones then can be $[1, 3, 3, 4]$, $[0, 2, 3, 3]$, $[2, 2, 5, 5]$, $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.\n\nSo all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of friends.\n\nThe second line contains $n$ integers $x_1, x_2, \\dots, x_n$ ($1 \\le x_i \\le n$) — the coordinates of the houses of the friends.\n\n\n-----Output-----\n\nPrint two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.\n\n\n-----Examples-----\nInput\n4\n1 2 4 4\n\nOutput\n2 4\n\nInput\n9\n1 1 8 8 8 4 4 4 4\n\nOutput\n3 8\n\nInput\n7\n4 3 7 1 4 3 3\n\nOutput\n3 6\n\n\n\n-----Note-----\n\nIn the first example friends can go to $[2, 2, 3, 3]$. So friend $1$ goes to $x_1+1$, friend $2$ stays at his house $x_2$, friend $3$ goes to $x_3-1$ and friend $4$ goes to $x_4-1$. $[1, 1, 3, 3]$, $[2, 2, 3, 3]$ or $[2, 2, 4, 4]$ are also all valid options to obtain $2$ occupied houses.\n\nFor the maximum number of occupied houses friends can go to $[1, 2, 3, 4]$ or to $[0, 2, 4, 5]$, for example.",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nprev=-2\\nc=0\\nfor i in a:\\n    dif=i-prev\\n    if dif > 1:\\n        prev=i+1\\n        c+=1\\nac=0\\nlc=-2\\nfor i in a:\\n    if lc < i-1:\\n        lc=i-1\\n        ac+=1\\n    elif lc == i-1:\\n        lc=i\\n        ac+=1\\n    elif lc == i:\\n        lc=i+1\\n        ac+=1\\nprint(c,ac)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmx=[0]*(n+2)\\nmn=[0]*(n+2)\\nl.sort()\\nfor i in l:\\n\\tif mx[i-1]==0:\\n\\t\\tmx[i-1]=1\\n\\telif mx[i]==0:\\n\\t\\tmx[i]=1\\n\\telse:\\n\\t\\tmx[i+1]=1\\n\\tif mn[i]==mn[i-1] and mn[i-1]==mn[i+1] and mn[i+1]==0:\\n\\t\\tmn[i+1]=1\\nprint(sum(mn),sum(mx))\\n\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nminh = set()\\nmaxh = set()\\n\\nfor e in ls:\\n    if e-1 not in maxh:\\n        maxh.add(e-1)\\n    elif e not in maxh:\\n        maxh.add(e)\\n    else:\\n        maxh.add(e+1)\\n\\n    if e-1 not in minh and e not in minh and e+1 not in minh:\\n        minh.add(e+1)\\n\\nprint(len(minh), len(maxh))\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\nA.sort()\\n\\nB={A[0]-1}\\nC={A[0]+1}\\n\\nfor i in range(1,n):\\n    if A[i]-1 in B and A[i] in B:\\n        B.add(A[i]+1)\\n    elif A[i]-1 in B:\\n        B.add(A[i])\\n    else:\\n        B.add(A[i]-1)\\n\\n    if A[i]-1 in C or A[i] in C:\\n        continue\\n    else:\\n        C.add(A[i]+1)\\n\\nprint(len(C),len(B))\\n        \\n\", \"n = int(input())\\nv = list(map(int, input().split()))\\nvaz = [0 for x in range(n+10)]\\nvaz1 = [0 for x in range(n+10)]\\nfor x in v:\\n    vaz[x] += 1\\nans1 = 0\\npz = 1\\nwhile pz<=n:\\n    if vaz[pz]==0:\\n        pz +=1\\n        continue\\n    ans1 +=1\\n    pz+=3\\nfor i in range(1,n+1):\\n    if vaz[i] == 0:\\n        continue\\n    a = vaz[i]\\n    if vaz1[i-1]==0 and a>0:\\n        a-=1\\n        vaz1[i-1]=1\\n    if vaz1[i]==0 and a>0:\\n        a-=1\\n        vaz1[i]=1\\n    if vaz1[i+1]==0 and a>0:\\n        a-=1\\n        vaz1[i+1]=1\\nans2 = 0\\nfor i in range(0,n+2):\\n    if vaz1[i]==1:\\n        ans2+=1\\nprint(str(ans1)+\\\" \\\"+str(ans2))\\n\", \"import sys\\nfrom operator import itemgetter\\nfrom collections import deque\\n\\ndef input():\\n    return sys.stdin.readline().strip()\\n\\ndef getmin(houses):\\n    i = 0\\n    ans = 0\\n    while len(houses)>0:\\n        x = houses.popleft()\\n        while len(houses)>0 and houses[0]<=x+2:\\n            houses.popleft()\\n        ans+=1\\n    return ans\\n\\ndef getmax(houses):\\n    vis = set()\\n    for x in houses:\\n        if x-1 not in vis:\\n            vis.add(x-1)\\n        elif x not in vis:\\n            vis.add(x)\\n        else:\\n            vis.add(x+1)\\n    return len(vis)\\n                \\n\\n\\nn = int(input())\\n\\nhouses = list(map(int, input().split()))\\nhouses.sort()\\nprint(getmin(deque(houses)), getmax(houses))\", \"n=int(input())\\nar=list(map(int,input().split()))\\nused1=[0]*(n+3)\\nused2=[0]*(n+3)\\nar.sort()\\nkol=0\\nfor i in range(n):\\n\\tif used1[ar[i]-1]==0:\\n\\t\\tif used1[ar[i]]==0:\\n\\t\\t\\tif used1[ar[i]+1]==0:\\n\\t\\t\\t\\tkol+=1\\n\\t\\t\\t\\tused1[ar[i]]=1\\n\\t\\t\\t\\tused1[ar[i]+1]=1\\n\\t\\t\\t\\tused1[ar[i]-1]=1\\nprint(kol,end=' ')\\nkol1=0\\nfor i in ar:\\n\\tif used2[i-1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i-1]=1\\n\\telif used2[i]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i]=1\\n\\telif used2[i+1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i+1]=1\\nprint(kol1)\\n\\n\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\n#print(l)\\nll = l.copy()\\nup = 1\\nleft = l[0]\\nfor i in range(n):\\n\\tif l[i] > left + 2:\\n\\t\\tleft = l[i]\\n\\t\\tup += 1\\n#print(up)\\n#print(ll)\\nll[0] -= 1\\n#print(ll)\\nfor i in range(1,n-1):\\n\\tif ll[i-1] == ll[i]:\\n\\t\\tif ll[i] != ll[i+1]:\\n\\t\\t\\tll[i] += 1\\n\\telif ll[i-1] == ll[i]-1:\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tll[i] -= 1\\n\\t#print(ll)\\nll[n-1] += 1\\n#print(ll)\\nd = {}\\nfor i in ll:\\n\\td[i] = 0\\nnajw = len(d)\\nprint(up, najw)\\n\", \"\\nn = int(input())\\n\\nx = list(map(int,input().split()))\\n\\nx.sort()\\n\\n\\ny = [] #to min\\n\\nfor i in range(n):\\n    if i == 0 or x[i-1] != x[i]:\\n        y.append(x[i])\\n\\nyend = [True] * len(y)\\nansmin = len(y)\\n\\nfor i in range(len(y)):\\n\\n    if i == 0 or ( not yend[i] ):\\n        continue\\n\\n    if y[i-1] + 1 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        ansmin -= 1\\n        yend[i] = False\\n\\n        if i+1 < len(y) and y[i+1] - 1 == y[i]:\\n            yend[i+1] = False\\n            ansmin -= 1\\n\\n    elif y[i-1] + 2 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        yend[i] = False\\n        ansmin -= 1\\n \\n#print (yend)\\n\\n\\ndic = {}\\n\\nfor i in range(n):\\n\\n    if x[i] - 1 not in dic:\\n        dic[x[i] - 1] = 1\\n    elif x[i] not in dic:\\n        dic[x[i]] = 1\\n    else:\\n        dic[x[i] + 1] = 1\\n\\nprint (ansmin , len(dic))\", \"from itertools import*\\n_,x=open(0)\\nx=sorted(map(int,x.split()))\\ni,*y=sorted(set(x))\\ns={i+1}\\nfor i in y:\\n  if not(i-1in s or i in s):\\n    s.add(i+1)\\nprint(len(s),end=' ')\\ns=set()\\nfor i,t in groupby(x):\\n  t=len(list(t))\\n  if not i-1in s and t:\\n    s.add(i-1)\\n    t-=1\\n  if not i in s and t:\\n    s.add(i)\\n    t-=1\\n  if not i+1in s and t:\\n    s.add(i+1)\\nprint(len(s))\", \"import sys\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef solve():\\n\\tn = mint()\\n\\tx = list(mints())\\n\\tx.sort()\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tc = [0]*(n+2)\\n\\tfor i in x:\\n\\t\\tc[i] += 1\\n\\t\\tif w[i-1] == 0:\\n\\t\\t\\tw[i-1] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i] == 0:\\n\\t\\t\\tw[i] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i+1] == 0:\\n\\t\\t\\tw[i+1] += 1\\n\\t\\t\\tr += 1\\n\\n\\trm = r\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tfor i in range(1,n+1):\\n\\t\\tv = c[i]\\n\\t\\tif v != 0:\\n\\t\\t\\tif w[i+1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i-1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telse:\\n\\t\\t\\t\\tw[i+1] += v\\n\\t\\t\\t\\tr += 1\\n\\tprint(r,rm)\\n\\n#for i in range(mint()):\\nsolve()\\n\", \"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\\n# M = 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)))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split(' ')]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n').split(' ')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\nn = val()\\nl = li()\\nl1 = l[:]\\nl2 = l[:]\\n\\ni = 0\\nl1 = sorted(list(set(l1)))\\ndoit = tot1 = 0\\ncn = Counter(l1)\\nl = l1[:]\\nwhile i < len(l1):\\n    if cn[l[i] - 1] > 0:\\n        cn[l[i]] -= 1\\n        cn[l[i] - 1] += 1\\n        l[i] -= 1\\n        i += 1\\n    else:\\n        cn[l[i]] -= 1\\n        cn[l[i] + 1] += 1\\n        l[i] += 1\\n        if i<len(l1) - 1 and l[i + 1] == l[i]:i += 2\\n        else:i += 1\\n# print(cn)\\ntot1 = sum(1 for i in cn if cn[i])\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n# print(l1)\\n\\n\\n\\ni = 0\\n\\ncnt = Counter(l2)\\nl2 = sorted(l2)\\n\\nl = l2[:]\\n\\n\\n\\nfor i in range(n):\\n    if cnt[l[i] - 1] == 0:\\n        cnt[l[i] - 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] -= 1\\n    elif cnt[l[i]] > 1:\\n        cnt[l[i] + 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] += 1\\n\\n\\ntot2 = sum(1 for i in cnt if cnt[i])\\n\\n\\n\\n\\n\\nprint(tot1,tot2)\"]",
        "difficulty": "introductory",
        "input": "9\n9 5 7 9 6 4 6 4 8\n",
        "output": "2 8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1283/E"
    },
    {
        "id": 2418,
        "task_id": 4281,
        "test_case_id": 9,
        "question": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coordinate $x_i-1$, $x_i+1$ or stay at $x_i$. Each friend is allowed to move no more than once.\n\nFor all friends $1 \\le x_i \\le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$, respectively).\n\nFor example, let the initial positions be $x = [1, 2, 4, 4]$. The final ones then can be $[1, 3, 3, 4]$, $[0, 2, 3, 3]$, $[2, 2, 5, 5]$, $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.\n\nSo all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of friends.\n\nThe second line contains $n$ integers $x_1, x_2, \\dots, x_n$ ($1 \\le x_i \\le n$) — the coordinates of the houses of the friends.\n\n\n-----Output-----\n\nPrint two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.\n\n\n-----Examples-----\nInput\n4\n1 2 4 4\n\nOutput\n2 4\n\nInput\n9\n1 1 8 8 8 4 4 4 4\n\nOutput\n3 8\n\nInput\n7\n4 3 7 1 4 3 3\n\nOutput\n3 6\n\n\n\n-----Note-----\n\nIn the first example friends can go to $[2, 2, 3, 3]$. So friend $1$ goes to $x_1+1$, friend $2$ stays at his house $x_2$, friend $3$ goes to $x_3-1$ and friend $4$ goes to $x_4-1$. $[1, 1, 3, 3]$, $[2, 2, 3, 3]$ or $[2, 2, 4, 4]$ are also all valid options to obtain $2$ occupied houses.\n\nFor the maximum number of occupied houses friends can go to $[1, 2, 3, 4]$ or to $[0, 2, 4, 5]$, for example.",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nprev=-2\\nc=0\\nfor i in a:\\n    dif=i-prev\\n    if dif > 1:\\n        prev=i+1\\n        c+=1\\nac=0\\nlc=-2\\nfor i in a:\\n    if lc < i-1:\\n        lc=i-1\\n        ac+=1\\n    elif lc == i-1:\\n        lc=i\\n        ac+=1\\n    elif lc == i:\\n        lc=i+1\\n        ac+=1\\nprint(c,ac)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmx=[0]*(n+2)\\nmn=[0]*(n+2)\\nl.sort()\\nfor i in l:\\n\\tif mx[i-1]==0:\\n\\t\\tmx[i-1]=1\\n\\telif mx[i]==0:\\n\\t\\tmx[i]=1\\n\\telse:\\n\\t\\tmx[i+1]=1\\n\\tif mn[i]==mn[i-1] and mn[i-1]==mn[i+1] and mn[i+1]==0:\\n\\t\\tmn[i+1]=1\\nprint(sum(mn),sum(mx))\\n\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nminh = set()\\nmaxh = set()\\n\\nfor e in ls:\\n    if e-1 not in maxh:\\n        maxh.add(e-1)\\n    elif e not in maxh:\\n        maxh.add(e)\\n    else:\\n        maxh.add(e+1)\\n\\n    if e-1 not in minh and e not in minh and e+1 not in minh:\\n        minh.add(e+1)\\n\\nprint(len(minh), len(maxh))\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\nA.sort()\\n\\nB={A[0]-1}\\nC={A[0]+1}\\n\\nfor i in range(1,n):\\n    if A[i]-1 in B and A[i] in B:\\n        B.add(A[i]+1)\\n    elif A[i]-1 in B:\\n        B.add(A[i])\\n    else:\\n        B.add(A[i]-1)\\n\\n    if A[i]-1 in C or A[i] in C:\\n        continue\\n    else:\\n        C.add(A[i]+1)\\n\\nprint(len(C),len(B))\\n        \\n\", \"n = int(input())\\nv = list(map(int, input().split()))\\nvaz = [0 for x in range(n+10)]\\nvaz1 = [0 for x in range(n+10)]\\nfor x in v:\\n    vaz[x] += 1\\nans1 = 0\\npz = 1\\nwhile pz<=n:\\n    if vaz[pz]==0:\\n        pz +=1\\n        continue\\n    ans1 +=1\\n    pz+=3\\nfor i in range(1,n+1):\\n    if vaz[i] == 0:\\n        continue\\n    a = vaz[i]\\n    if vaz1[i-1]==0 and a>0:\\n        a-=1\\n        vaz1[i-1]=1\\n    if vaz1[i]==0 and a>0:\\n        a-=1\\n        vaz1[i]=1\\n    if vaz1[i+1]==0 and a>0:\\n        a-=1\\n        vaz1[i+1]=1\\nans2 = 0\\nfor i in range(0,n+2):\\n    if vaz1[i]==1:\\n        ans2+=1\\nprint(str(ans1)+\\\" \\\"+str(ans2))\\n\", \"import sys\\nfrom operator import itemgetter\\nfrom collections import deque\\n\\ndef input():\\n    return sys.stdin.readline().strip()\\n\\ndef getmin(houses):\\n    i = 0\\n    ans = 0\\n    while len(houses)>0:\\n        x = houses.popleft()\\n        while len(houses)>0 and houses[0]<=x+2:\\n            houses.popleft()\\n        ans+=1\\n    return ans\\n\\ndef getmax(houses):\\n    vis = set()\\n    for x in houses:\\n        if x-1 not in vis:\\n            vis.add(x-1)\\n        elif x not in vis:\\n            vis.add(x)\\n        else:\\n            vis.add(x+1)\\n    return len(vis)\\n                \\n\\n\\nn = int(input())\\n\\nhouses = list(map(int, input().split()))\\nhouses.sort()\\nprint(getmin(deque(houses)), getmax(houses))\", \"n=int(input())\\nar=list(map(int,input().split()))\\nused1=[0]*(n+3)\\nused2=[0]*(n+3)\\nar.sort()\\nkol=0\\nfor i in range(n):\\n\\tif used1[ar[i]-1]==0:\\n\\t\\tif used1[ar[i]]==0:\\n\\t\\t\\tif used1[ar[i]+1]==0:\\n\\t\\t\\t\\tkol+=1\\n\\t\\t\\t\\tused1[ar[i]]=1\\n\\t\\t\\t\\tused1[ar[i]+1]=1\\n\\t\\t\\t\\tused1[ar[i]-1]=1\\nprint(kol,end=' ')\\nkol1=0\\nfor i in ar:\\n\\tif used2[i-1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i-1]=1\\n\\telif used2[i]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i]=1\\n\\telif used2[i+1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i+1]=1\\nprint(kol1)\\n\\n\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\n#print(l)\\nll = l.copy()\\nup = 1\\nleft = l[0]\\nfor i in range(n):\\n\\tif l[i] > left + 2:\\n\\t\\tleft = l[i]\\n\\t\\tup += 1\\n#print(up)\\n#print(ll)\\nll[0] -= 1\\n#print(ll)\\nfor i in range(1,n-1):\\n\\tif ll[i-1] == ll[i]:\\n\\t\\tif ll[i] != ll[i+1]:\\n\\t\\t\\tll[i] += 1\\n\\telif ll[i-1] == ll[i]-1:\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tll[i] -= 1\\n\\t#print(ll)\\nll[n-1] += 1\\n#print(ll)\\nd = {}\\nfor i in ll:\\n\\td[i] = 0\\nnajw = len(d)\\nprint(up, najw)\\n\", \"\\nn = int(input())\\n\\nx = list(map(int,input().split()))\\n\\nx.sort()\\n\\n\\ny = [] #to min\\n\\nfor i in range(n):\\n    if i == 0 or x[i-1] != x[i]:\\n        y.append(x[i])\\n\\nyend = [True] * len(y)\\nansmin = len(y)\\n\\nfor i in range(len(y)):\\n\\n    if i == 0 or ( not yend[i] ):\\n        continue\\n\\n    if y[i-1] + 1 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        ansmin -= 1\\n        yend[i] = False\\n\\n        if i+1 < len(y) and y[i+1] - 1 == y[i]:\\n            yend[i+1] = False\\n            ansmin -= 1\\n\\n    elif y[i-1] + 2 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        yend[i] = False\\n        ansmin -= 1\\n \\n#print (yend)\\n\\n\\ndic = {}\\n\\nfor i in range(n):\\n\\n    if x[i] - 1 not in dic:\\n        dic[x[i] - 1] = 1\\n    elif x[i] not in dic:\\n        dic[x[i]] = 1\\n    else:\\n        dic[x[i] + 1] = 1\\n\\nprint (ansmin , len(dic))\", \"from itertools import*\\n_,x=open(0)\\nx=sorted(map(int,x.split()))\\ni,*y=sorted(set(x))\\ns={i+1}\\nfor i in y:\\n  if not(i-1in s or i in s):\\n    s.add(i+1)\\nprint(len(s),end=' ')\\ns=set()\\nfor i,t in groupby(x):\\n  t=len(list(t))\\n  if not i-1in s and t:\\n    s.add(i-1)\\n    t-=1\\n  if not i in s and t:\\n    s.add(i)\\n    t-=1\\n  if not i+1in s and t:\\n    s.add(i+1)\\nprint(len(s))\", \"import sys\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef solve():\\n\\tn = mint()\\n\\tx = list(mints())\\n\\tx.sort()\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tc = [0]*(n+2)\\n\\tfor i in x:\\n\\t\\tc[i] += 1\\n\\t\\tif w[i-1] == 0:\\n\\t\\t\\tw[i-1] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i] == 0:\\n\\t\\t\\tw[i] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i+1] == 0:\\n\\t\\t\\tw[i+1] += 1\\n\\t\\t\\tr += 1\\n\\n\\trm = r\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tfor i in range(1,n+1):\\n\\t\\tv = c[i]\\n\\t\\tif v != 0:\\n\\t\\t\\tif w[i+1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i-1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telse:\\n\\t\\t\\t\\tw[i+1] += v\\n\\t\\t\\t\\tr += 1\\n\\tprint(r,rm)\\n\\n#for i in range(mint()):\\nsolve()\\n\", \"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\\n# M = 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)))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split(' ')]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n').split(' ')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\nn = val()\\nl = li()\\nl1 = l[:]\\nl2 = l[:]\\n\\ni = 0\\nl1 = sorted(list(set(l1)))\\ndoit = tot1 = 0\\ncn = Counter(l1)\\nl = l1[:]\\nwhile i < len(l1):\\n    if cn[l[i] - 1] > 0:\\n        cn[l[i]] -= 1\\n        cn[l[i] - 1] += 1\\n        l[i] -= 1\\n        i += 1\\n    else:\\n        cn[l[i]] -= 1\\n        cn[l[i] + 1] += 1\\n        l[i] += 1\\n        if i<len(l1) - 1 and l[i + 1] == l[i]:i += 2\\n        else:i += 1\\n# print(cn)\\ntot1 = sum(1 for i in cn if cn[i])\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n# print(l1)\\n\\n\\n\\ni = 0\\n\\ncnt = Counter(l2)\\nl2 = sorted(l2)\\n\\nl = l2[:]\\n\\n\\n\\nfor i in range(n):\\n    if cnt[l[i] - 1] == 0:\\n        cnt[l[i] - 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] -= 1\\n    elif cnt[l[i]] > 1:\\n        cnt[l[i] + 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] += 1\\n\\n\\ntot2 = sum(1 for i in cnt if cnt[i])\\n\\n\\n\\n\\n\\nprint(tot1,tot2)\"]",
        "difficulty": "introductory",
        "input": "10\n6 6 6 6 6 6 6 6 6 6\n",
        "output": "1 3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1283/E"
    },
    {
        "id": 2419,
        "task_id": 4281,
        "test_case_id": 10,
        "question": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coordinate $x_i-1$, $x_i+1$ or stay at $x_i$. Each friend is allowed to move no more than once.\n\nFor all friends $1 \\le x_i \\le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$, respectively).\n\nFor example, let the initial positions be $x = [1, 2, 4, 4]$. The final ones then can be $[1, 3, 3, 4]$, $[0, 2, 3, 3]$, $[2, 2, 5, 5]$, $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.\n\nSo all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of friends.\n\nThe second line contains $n$ integers $x_1, x_2, \\dots, x_n$ ($1 \\le x_i \\le n$) — the coordinates of the houses of the friends.\n\n\n-----Output-----\n\nPrint two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.\n\n\n-----Examples-----\nInput\n4\n1 2 4 4\n\nOutput\n2 4\n\nInput\n9\n1 1 8 8 8 4 4 4 4\n\nOutput\n3 8\n\nInput\n7\n4 3 7 1 4 3 3\n\nOutput\n3 6\n\n\n\n-----Note-----\n\nIn the first example friends can go to $[2, 2, 3, 3]$. So friend $1$ goes to $x_1+1$, friend $2$ stays at his house $x_2$, friend $3$ goes to $x_3-1$ and friend $4$ goes to $x_4-1$. $[1, 1, 3, 3]$, $[2, 2, 3, 3]$ or $[2, 2, 4, 4]$ are also all valid options to obtain $2$ occupied houses.\n\nFor the maximum number of occupied houses friends can go to $[1, 2, 3, 4]$ or to $[0, 2, 4, 5]$, for example.",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nprev=-2\\nc=0\\nfor i in a:\\n    dif=i-prev\\n    if dif > 1:\\n        prev=i+1\\n        c+=1\\nac=0\\nlc=-2\\nfor i in a:\\n    if lc < i-1:\\n        lc=i-1\\n        ac+=1\\n    elif lc == i-1:\\n        lc=i\\n        ac+=1\\n    elif lc == i:\\n        lc=i+1\\n        ac+=1\\nprint(c,ac)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmx=[0]*(n+2)\\nmn=[0]*(n+2)\\nl.sort()\\nfor i in l:\\n\\tif mx[i-1]==0:\\n\\t\\tmx[i-1]=1\\n\\telif mx[i]==0:\\n\\t\\tmx[i]=1\\n\\telse:\\n\\t\\tmx[i+1]=1\\n\\tif mn[i]==mn[i-1] and mn[i-1]==mn[i+1] and mn[i+1]==0:\\n\\t\\tmn[i+1]=1\\nprint(sum(mn),sum(mx))\\n\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nminh = set()\\nmaxh = set()\\n\\nfor e in ls:\\n    if e-1 not in maxh:\\n        maxh.add(e-1)\\n    elif e not in maxh:\\n        maxh.add(e)\\n    else:\\n        maxh.add(e+1)\\n\\n    if e-1 not in minh and e not in minh and e+1 not in minh:\\n        minh.add(e+1)\\n\\nprint(len(minh), len(maxh))\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\nA.sort()\\n\\nB={A[0]-1}\\nC={A[0]+1}\\n\\nfor i in range(1,n):\\n    if A[i]-1 in B and A[i] in B:\\n        B.add(A[i]+1)\\n    elif A[i]-1 in B:\\n        B.add(A[i])\\n    else:\\n        B.add(A[i]-1)\\n\\n    if A[i]-1 in C or A[i] in C:\\n        continue\\n    else:\\n        C.add(A[i]+1)\\n\\nprint(len(C),len(B))\\n        \\n\", \"n = int(input())\\nv = list(map(int, input().split()))\\nvaz = [0 for x in range(n+10)]\\nvaz1 = [0 for x in range(n+10)]\\nfor x in v:\\n    vaz[x] += 1\\nans1 = 0\\npz = 1\\nwhile pz<=n:\\n    if vaz[pz]==0:\\n        pz +=1\\n        continue\\n    ans1 +=1\\n    pz+=3\\nfor i in range(1,n+1):\\n    if vaz[i] == 0:\\n        continue\\n    a = vaz[i]\\n    if vaz1[i-1]==0 and a>0:\\n        a-=1\\n        vaz1[i-1]=1\\n    if vaz1[i]==0 and a>0:\\n        a-=1\\n        vaz1[i]=1\\n    if vaz1[i+1]==0 and a>0:\\n        a-=1\\n        vaz1[i+1]=1\\nans2 = 0\\nfor i in range(0,n+2):\\n    if vaz1[i]==1:\\n        ans2+=1\\nprint(str(ans1)+\\\" \\\"+str(ans2))\\n\", \"import sys\\nfrom operator import itemgetter\\nfrom collections import deque\\n\\ndef input():\\n    return sys.stdin.readline().strip()\\n\\ndef getmin(houses):\\n    i = 0\\n    ans = 0\\n    while len(houses)>0:\\n        x = houses.popleft()\\n        while len(houses)>0 and houses[0]<=x+2:\\n            houses.popleft()\\n        ans+=1\\n    return ans\\n\\ndef getmax(houses):\\n    vis = set()\\n    for x in houses:\\n        if x-1 not in vis:\\n            vis.add(x-1)\\n        elif x not in vis:\\n            vis.add(x)\\n        else:\\n            vis.add(x+1)\\n    return len(vis)\\n                \\n\\n\\nn = int(input())\\n\\nhouses = list(map(int, input().split()))\\nhouses.sort()\\nprint(getmin(deque(houses)), getmax(houses))\", \"n=int(input())\\nar=list(map(int,input().split()))\\nused1=[0]*(n+3)\\nused2=[0]*(n+3)\\nar.sort()\\nkol=0\\nfor i in range(n):\\n\\tif used1[ar[i]-1]==0:\\n\\t\\tif used1[ar[i]]==0:\\n\\t\\t\\tif used1[ar[i]+1]==0:\\n\\t\\t\\t\\tkol+=1\\n\\t\\t\\t\\tused1[ar[i]]=1\\n\\t\\t\\t\\tused1[ar[i]+1]=1\\n\\t\\t\\t\\tused1[ar[i]-1]=1\\nprint(kol,end=' ')\\nkol1=0\\nfor i in ar:\\n\\tif used2[i-1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i-1]=1\\n\\telif used2[i]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i]=1\\n\\telif used2[i+1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i+1]=1\\nprint(kol1)\\n\\n\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\n#print(l)\\nll = l.copy()\\nup = 1\\nleft = l[0]\\nfor i in range(n):\\n\\tif l[i] > left + 2:\\n\\t\\tleft = l[i]\\n\\t\\tup += 1\\n#print(up)\\n#print(ll)\\nll[0] -= 1\\n#print(ll)\\nfor i in range(1,n-1):\\n\\tif ll[i-1] == ll[i]:\\n\\t\\tif ll[i] != ll[i+1]:\\n\\t\\t\\tll[i] += 1\\n\\telif ll[i-1] == ll[i]-1:\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tll[i] -= 1\\n\\t#print(ll)\\nll[n-1] += 1\\n#print(ll)\\nd = {}\\nfor i in ll:\\n\\td[i] = 0\\nnajw = len(d)\\nprint(up, najw)\\n\", \"\\nn = int(input())\\n\\nx = list(map(int,input().split()))\\n\\nx.sort()\\n\\n\\ny = [] #to min\\n\\nfor i in range(n):\\n    if i == 0 or x[i-1] != x[i]:\\n        y.append(x[i])\\n\\nyend = [True] * len(y)\\nansmin = len(y)\\n\\nfor i in range(len(y)):\\n\\n    if i == 0 or ( not yend[i] ):\\n        continue\\n\\n    if y[i-1] + 1 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        ansmin -= 1\\n        yend[i] = False\\n\\n        if i+1 < len(y) and y[i+1] - 1 == y[i]:\\n            yend[i+1] = False\\n            ansmin -= 1\\n\\n    elif y[i-1] + 2 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        yend[i] = False\\n        ansmin -= 1\\n \\n#print (yend)\\n\\n\\ndic = {}\\n\\nfor i in range(n):\\n\\n    if x[i] - 1 not in dic:\\n        dic[x[i] - 1] = 1\\n    elif x[i] not in dic:\\n        dic[x[i]] = 1\\n    else:\\n        dic[x[i] + 1] = 1\\n\\nprint (ansmin , len(dic))\", \"from itertools import*\\n_,x=open(0)\\nx=sorted(map(int,x.split()))\\ni,*y=sorted(set(x))\\ns={i+1}\\nfor i in y:\\n  if not(i-1in s or i in s):\\n    s.add(i+1)\\nprint(len(s),end=' ')\\ns=set()\\nfor i,t in groupby(x):\\n  t=len(list(t))\\n  if not i-1in s and t:\\n    s.add(i-1)\\n    t-=1\\n  if not i in s and t:\\n    s.add(i)\\n    t-=1\\n  if not i+1in s and t:\\n    s.add(i+1)\\nprint(len(s))\", \"import sys\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef solve():\\n\\tn = mint()\\n\\tx = list(mints())\\n\\tx.sort()\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tc = [0]*(n+2)\\n\\tfor i in x:\\n\\t\\tc[i] += 1\\n\\t\\tif w[i-1] == 0:\\n\\t\\t\\tw[i-1] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i] == 0:\\n\\t\\t\\tw[i] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i+1] == 0:\\n\\t\\t\\tw[i+1] += 1\\n\\t\\t\\tr += 1\\n\\n\\trm = r\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tfor i in range(1,n+1):\\n\\t\\tv = c[i]\\n\\t\\tif v != 0:\\n\\t\\t\\tif w[i+1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i-1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telse:\\n\\t\\t\\t\\tw[i+1] += v\\n\\t\\t\\t\\tr += 1\\n\\tprint(r,rm)\\n\\n#for i in range(mint()):\\nsolve()\\n\", \"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\\n# M = 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)))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split(' ')]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n').split(' ')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\nn = val()\\nl = li()\\nl1 = l[:]\\nl2 = l[:]\\n\\ni = 0\\nl1 = sorted(list(set(l1)))\\ndoit = tot1 = 0\\ncn = Counter(l1)\\nl = l1[:]\\nwhile i < len(l1):\\n    if cn[l[i] - 1] > 0:\\n        cn[l[i]] -= 1\\n        cn[l[i] - 1] += 1\\n        l[i] -= 1\\n        i += 1\\n    else:\\n        cn[l[i]] -= 1\\n        cn[l[i] + 1] += 1\\n        l[i] += 1\\n        if i<len(l1) - 1 and l[i + 1] == l[i]:i += 2\\n        else:i += 1\\n# print(cn)\\ntot1 = sum(1 for i in cn if cn[i])\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n# print(l1)\\n\\n\\n\\ni = 0\\n\\ncnt = Counter(l2)\\nl2 = sorted(l2)\\n\\nl = l2[:]\\n\\n\\n\\nfor i in range(n):\\n    if cnt[l[i] - 1] == 0:\\n        cnt[l[i] - 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] -= 1\\n    elif cnt[l[i]] > 1:\\n        cnt[l[i] + 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] += 1\\n\\n\\ntot2 = sum(1 for i in cnt if cnt[i])\\n\\n\\n\\n\\n\\nprint(tot1,tot2)\"]",
        "difficulty": "introductory",
        "input": "10\n10 7 10 10 7 10 7 7 10 10\n",
        "output": "2 6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1283/E"
    },
    {
        "id": 2420,
        "task_id": 4281,
        "test_case_id": 11,
        "question": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coordinate $x_i-1$, $x_i+1$ or stay at $x_i$. Each friend is allowed to move no more than once.\n\nFor all friends $1 \\le x_i \\le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$, respectively).\n\nFor example, let the initial positions be $x = [1, 2, 4, 4]$. The final ones then can be $[1, 3, 3, 4]$, $[0, 2, 3, 3]$, $[2, 2, 5, 5]$, $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.\n\nSo all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of friends.\n\nThe second line contains $n$ integers $x_1, x_2, \\dots, x_n$ ($1 \\le x_i \\le n$) — the coordinates of the houses of the friends.\n\n\n-----Output-----\n\nPrint two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.\n\n\n-----Examples-----\nInput\n4\n1 2 4 4\n\nOutput\n2 4\n\nInput\n9\n1 1 8 8 8 4 4 4 4\n\nOutput\n3 8\n\nInput\n7\n4 3 7 1 4 3 3\n\nOutput\n3 6\n\n\n\n-----Note-----\n\nIn the first example friends can go to $[2, 2, 3, 3]$. So friend $1$ goes to $x_1+1$, friend $2$ stays at his house $x_2$, friend $3$ goes to $x_3-1$ and friend $4$ goes to $x_4-1$. $[1, 1, 3, 3]$, $[2, 2, 3, 3]$ or $[2, 2, 4, 4]$ are also all valid options to obtain $2$ occupied houses.\n\nFor the maximum number of occupied houses friends can go to $[1, 2, 3, 4]$ or to $[0, 2, 4, 5]$, for example.",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nprev=-2\\nc=0\\nfor i in a:\\n    dif=i-prev\\n    if dif > 1:\\n        prev=i+1\\n        c+=1\\nac=0\\nlc=-2\\nfor i in a:\\n    if lc < i-1:\\n        lc=i-1\\n        ac+=1\\n    elif lc == i-1:\\n        lc=i\\n        ac+=1\\n    elif lc == i:\\n        lc=i+1\\n        ac+=1\\nprint(c,ac)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmx=[0]*(n+2)\\nmn=[0]*(n+2)\\nl.sort()\\nfor i in l:\\n\\tif mx[i-1]==0:\\n\\t\\tmx[i-1]=1\\n\\telif mx[i]==0:\\n\\t\\tmx[i]=1\\n\\telse:\\n\\t\\tmx[i+1]=1\\n\\tif mn[i]==mn[i-1] and mn[i-1]==mn[i+1] and mn[i+1]==0:\\n\\t\\tmn[i+1]=1\\nprint(sum(mn),sum(mx))\\n\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nminh = set()\\nmaxh = set()\\n\\nfor e in ls:\\n    if e-1 not in maxh:\\n        maxh.add(e-1)\\n    elif e not in maxh:\\n        maxh.add(e)\\n    else:\\n        maxh.add(e+1)\\n\\n    if e-1 not in minh and e not in minh and e+1 not in minh:\\n        minh.add(e+1)\\n\\nprint(len(minh), len(maxh))\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\nA.sort()\\n\\nB={A[0]-1}\\nC={A[0]+1}\\n\\nfor i in range(1,n):\\n    if A[i]-1 in B and A[i] in B:\\n        B.add(A[i]+1)\\n    elif A[i]-1 in B:\\n        B.add(A[i])\\n    else:\\n        B.add(A[i]-1)\\n\\n    if A[i]-1 in C or A[i] in C:\\n        continue\\n    else:\\n        C.add(A[i]+1)\\n\\nprint(len(C),len(B))\\n        \\n\", \"n = int(input())\\nv = list(map(int, input().split()))\\nvaz = [0 for x in range(n+10)]\\nvaz1 = [0 for x in range(n+10)]\\nfor x in v:\\n    vaz[x] += 1\\nans1 = 0\\npz = 1\\nwhile pz<=n:\\n    if vaz[pz]==0:\\n        pz +=1\\n        continue\\n    ans1 +=1\\n    pz+=3\\nfor i in range(1,n+1):\\n    if vaz[i] == 0:\\n        continue\\n    a = vaz[i]\\n    if vaz1[i-1]==0 and a>0:\\n        a-=1\\n        vaz1[i-1]=1\\n    if vaz1[i]==0 and a>0:\\n        a-=1\\n        vaz1[i]=1\\n    if vaz1[i+1]==0 and a>0:\\n        a-=1\\n        vaz1[i+1]=1\\nans2 = 0\\nfor i in range(0,n+2):\\n    if vaz1[i]==1:\\n        ans2+=1\\nprint(str(ans1)+\\\" \\\"+str(ans2))\\n\", \"import sys\\nfrom operator import itemgetter\\nfrom collections import deque\\n\\ndef input():\\n    return sys.stdin.readline().strip()\\n\\ndef getmin(houses):\\n    i = 0\\n    ans = 0\\n    while len(houses)>0:\\n        x = houses.popleft()\\n        while len(houses)>0 and houses[0]<=x+2:\\n            houses.popleft()\\n        ans+=1\\n    return ans\\n\\ndef getmax(houses):\\n    vis = set()\\n    for x in houses:\\n        if x-1 not in vis:\\n            vis.add(x-1)\\n        elif x not in vis:\\n            vis.add(x)\\n        else:\\n            vis.add(x+1)\\n    return len(vis)\\n                \\n\\n\\nn = int(input())\\n\\nhouses = list(map(int, input().split()))\\nhouses.sort()\\nprint(getmin(deque(houses)), getmax(houses))\", \"n=int(input())\\nar=list(map(int,input().split()))\\nused1=[0]*(n+3)\\nused2=[0]*(n+3)\\nar.sort()\\nkol=0\\nfor i in range(n):\\n\\tif used1[ar[i]-1]==0:\\n\\t\\tif used1[ar[i]]==0:\\n\\t\\t\\tif used1[ar[i]+1]==0:\\n\\t\\t\\t\\tkol+=1\\n\\t\\t\\t\\tused1[ar[i]]=1\\n\\t\\t\\t\\tused1[ar[i]+1]=1\\n\\t\\t\\t\\tused1[ar[i]-1]=1\\nprint(kol,end=' ')\\nkol1=0\\nfor i in ar:\\n\\tif used2[i-1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i-1]=1\\n\\telif used2[i]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i]=1\\n\\telif used2[i+1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i+1]=1\\nprint(kol1)\\n\\n\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\n#print(l)\\nll = l.copy()\\nup = 1\\nleft = l[0]\\nfor i in range(n):\\n\\tif l[i] > left + 2:\\n\\t\\tleft = l[i]\\n\\t\\tup += 1\\n#print(up)\\n#print(ll)\\nll[0] -= 1\\n#print(ll)\\nfor i in range(1,n-1):\\n\\tif ll[i-1] == ll[i]:\\n\\t\\tif ll[i] != ll[i+1]:\\n\\t\\t\\tll[i] += 1\\n\\telif ll[i-1] == ll[i]-1:\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tll[i] -= 1\\n\\t#print(ll)\\nll[n-1] += 1\\n#print(ll)\\nd = {}\\nfor i in ll:\\n\\td[i] = 0\\nnajw = len(d)\\nprint(up, najw)\\n\", \"\\nn = int(input())\\n\\nx = list(map(int,input().split()))\\n\\nx.sort()\\n\\n\\ny = [] #to min\\n\\nfor i in range(n):\\n    if i == 0 or x[i-1] != x[i]:\\n        y.append(x[i])\\n\\nyend = [True] * len(y)\\nansmin = len(y)\\n\\nfor i in range(len(y)):\\n\\n    if i == 0 or ( not yend[i] ):\\n        continue\\n\\n    if y[i-1] + 1 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        ansmin -= 1\\n        yend[i] = False\\n\\n        if i+1 < len(y) and y[i+1] - 1 == y[i]:\\n            yend[i+1] = False\\n            ansmin -= 1\\n\\n    elif y[i-1] + 2 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        yend[i] = False\\n        ansmin -= 1\\n \\n#print (yend)\\n\\n\\ndic = {}\\n\\nfor i in range(n):\\n\\n    if x[i] - 1 not in dic:\\n        dic[x[i] - 1] = 1\\n    elif x[i] not in dic:\\n        dic[x[i]] = 1\\n    else:\\n        dic[x[i] + 1] = 1\\n\\nprint (ansmin , len(dic))\", \"from itertools import*\\n_,x=open(0)\\nx=sorted(map(int,x.split()))\\ni,*y=sorted(set(x))\\ns={i+1}\\nfor i in y:\\n  if not(i-1in s or i in s):\\n    s.add(i+1)\\nprint(len(s),end=' ')\\ns=set()\\nfor i,t in groupby(x):\\n  t=len(list(t))\\n  if not i-1in s and t:\\n    s.add(i-1)\\n    t-=1\\n  if not i in s and t:\\n    s.add(i)\\n    t-=1\\n  if not i+1in s and t:\\n    s.add(i+1)\\nprint(len(s))\", \"import sys\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef solve():\\n\\tn = mint()\\n\\tx = list(mints())\\n\\tx.sort()\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tc = [0]*(n+2)\\n\\tfor i in x:\\n\\t\\tc[i] += 1\\n\\t\\tif w[i-1] == 0:\\n\\t\\t\\tw[i-1] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i] == 0:\\n\\t\\t\\tw[i] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i+1] == 0:\\n\\t\\t\\tw[i+1] += 1\\n\\t\\t\\tr += 1\\n\\n\\trm = r\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tfor i in range(1,n+1):\\n\\t\\tv = c[i]\\n\\t\\tif v != 0:\\n\\t\\t\\tif w[i+1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i-1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telse:\\n\\t\\t\\t\\tw[i+1] += v\\n\\t\\t\\t\\tr += 1\\n\\tprint(r,rm)\\n\\n#for i in range(mint()):\\nsolve()\\n\", \"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\\n# M = 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)))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split(' ')]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n').split(' ')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\nn = val()\\nl = li()\\nl1 = l[:]\\nl2 = l[:]\\n\\ni = 0\\nl1 = sorted(list(set(l1)))\\ndoit = tot1 = 0\\ncn = Counter(l1)\\nl = l1[:]\\nwhile i < len(l1):\\n    if cn[l[i] - 1] > 0:\\n        cn[l[i]] -= 1\\n        cn[l[i] - 1] += 1\\n        l[i] -= 1\\n        i += 1\\n    else:\\n        cn[l[i]] -= 1\\n        cn[l[i] + 1] += 1\\n        l[i] += 1\\n        if i<len(l1) - 1 and l[i + 1] == l[i]:i += 2\\n        else:i += 1\\n# print(cn)\\ntot1 = sum(1 for i in cn if cn[i])\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n# print(l1)\\n\\n\\n\\ni = 0\\n\\ncnt = Counter(l2)\\nl2 = sorted(l2)\\n\\nl = l2[:]\\n\\n\\n\\nfor i in range(n):\\n    if cnt[l[i] - 1] == 0:\\n        cnt[l[i] - 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] -= 1\\n    elif cnt[l[i]] > 1:\\n        cnt[l[i] + 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] += 1\\n\\n\\ntot2 = sum(1 for i in cnt if cnt[i])\\n\\n\\n\\n\\n\\nprint(tot1,tot2)\"]",
        "difficulty": "introductory",
        "input": "10\n6 8 9 6 5 9 4 8 8 6\n",
        "output": "2 8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1283/E"
    },
    {
        "id": 2421,
        "task_id": 4281,
        "test_case_id": 12,
        "question": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coordinate $x_i-1$, $x_i+1$ or stay at $x_i$. Each friend is allowed to move no more than once.\n\nFor all friends $1 \\le x_i \\le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$, respectively).\n\nFor example, let the initial positions be $x = [1, 2, 4, 4]$. The final ones then can be $[1, 3, 3, 4]$, $[0, 2, 3, 3]$, $[2, 2, 5, 5]$, $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.\n\nSo all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of friends.\n\nThe second line contains $n$ integers $x_1, x_2, \\dots, x_n$ ($1 \\le x_i \\le n$) — the coordinates of the houses of the friends.\n\n\n-----Output-----\n\nPrint two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.\n\n\n-----Examples-----\nInput\n4\n1 2 4 4\n\nOutput\n2 4\n\nInput\n9\n1 1 8 8 8 4 4 4 4\n\nOutput\n3 8\n\nInput\n7\n4 3 7 1 4 3 3\n\nOutput\n3 6\n\n\n\n-----Note-----\n\nIn the first example friends can go to $[2, 2, 3, 3]$. So friend $1$ goes to $x_1+1$, friend $2$ stays at his house $x_2$, friend $3$ goes to $x_3-1$ and friend $4$ goes to $x_4-1$. $[1, 1, 3, 3]$, $[2, 2, 3, 3]$ or $[2, 2, 4, 4]$ are also all valid options to obtain $2$ occupied houses.\n\nFor the maximum number of occupied houses friends can go to $[1, 2, 3, 4]$ or to $[0, 2, 4, 5]$, for example.",
        "solutions": "[\"n=int(input())\\na=list(map(int,input().split()))\\na.sort()\\nprev=-2\\nc=0\\nfor i in a:\\n    dif=i-prev\\n    if dif > 1:\\n        prev=i+1\\n        c+=1\\nac=0\\nlc=-2\\nfor i in a:\\n    if lc < i-1:\\n        lc=i-1\\n        ac+=1\\n    elif lc == i-1:\\n        lc=i\\n        ac+=1\\n    elif lc == i:\\n        lc=i+1\\n        ac+=1\\nprint(c,ac)\\n\", \"n=int(input())\\nl=list(map(int,input().split()))\\nmx=[0]*(n+2)\\nmn=[0]*(n+2)\\nl.sort()\\nfor i in l:\\n\\tif mx[i-1]==0:\\n\\t\\tmx[i-1]=1\\n\\telif mx[i]==0:\\n\\t\\tmx[i]=1\\n\\telse:\\n\\t\\tmx[i+1]=1\\n\\tif mn[i]==mn[i-1] and mn[i-1]==mn[i+1] and mn[i+1]==0:\\n\\t\\tmn[i+1]=1\\nprint(sum(mn),sum(mx))\\n\\n\", \"n = int(input())\\nls = list(map(int, input().split()))\\n\\nls.sort()\\nminh = set()\\nmaxh = set()\\n\\nfor e in ls:\\n    if e-1 not in maxh:\\n        maxh.add(e-1)\\n    elif e not in maxh:\\n        maxh.add(e)\\n    else:\\n        maxh.add(e+1)\\n\\n    if e-1 not in minh and e not in minh and e+1 not in minh:\\n        minh.add(e+1)\\n\\nprint(len(minh), len(maxh))\\n\", \"import sys\\ninput = sys.stdin.readline\\n\\nn=int(input())\\nA=list(map(int,input().split()))\\nA.sort()\\n\\nB={A[0]-1}\\nC={A[0]+1}\\n\\nfor i in range(1,n):\\n    if A[i]-1 in B and A[i] in B:\\n        B.add(A[i]+1)\\n    elif A[i]-1 in B:\\n        B.add(A[i])\\n    else:\\n        B.add(A[i]-1)\\n\\n    if A[i]-1 in C or A[i] in C:\\n        continue\\n    else:\\n        C.add(A[i]+1)\\n\\nprint(len(C),len(B))\\n        \\n\", \"n = int(input())\\nv = list(map(int, input().split()))\\nvaz = [0 for x in range(n+10)]\\nvaz1 = [0 for x in range(n+10)]\\nfor x in v:\\n    vaz[x] += 1\\nans1 = 0\\npz = 1\\nwhile pz<=n:\\n    if vaz[pz]==0:\\n        pz +=1\\n        continue\\n    ans1 +=1\\n    pz+=3\\nfor i in range(1,n+1):\\n    if vaz[i] == 0:\\n        continue\\n    a = vaz[i]\\n    if vaz1[i-1]==0 and a>0:\\n        a-=1\\n        vaz1[i-1]=1\\n    if vaz1[i]==0 and a>0:\\n        a-=1\\n        vaz1[i]=1\\n    if vaz1[i+1]==0 and a>0:\\n        a-=1\\n        vaz1[i+1]=1\\nans2 = 0\\nfor i in range(0,n+2):\\n    if vaz1[i]==1:\\n        ans2+=1\\nprint(str(ans1)+\\\" \\\"+str(ans2))\\n\", \"import sys\\nfrom operator import itemgetter\\nfrom collections import deque\\n\\ndef input():\\n    return sys.stdin.readline().strip()\\n\\ndef getmin(houses):\\n    i = 0\\n    ans = 0\\n    while len(houses)>0:\\n        x = houses.popleft()\\n        while len(houses)>0 and houses[0]<=x+2:\\n            houses.popleft()\\n        ans+=1\\n    return ans\\n\\ndef getmax(houses):\\n    vis = set()\\n    for x in houses:\\n        if x-1 not in vis:\\n            vis.add(x-1)\\n        elif x not in vis:\\n            vis.add(x)\\n        else:\\n            vis.add(x+1)\\n    return len(vis)\\n                \\n\\n\\nn = int(input())\\n\\nhouses = list(map(int, input().split()))\\nhouses.sort()\\nprint(getmin(deque(houses)), getmax(houses))\", \"n=int(input())\\nar=list(map(int,input().split()))\\nused1=[0]*(n+3)\\nused2=[0]*(n+3)\\nar.sort()\\nkol=0\\nfor i in range(n):\\n\\tif used1[ar[i]-1]==0:\\n\\t\\tif used1[ar[i]]==0:\\n\\t\\t\\tif used1[ar[i]+1]==0:\\n\\t\\t\\t\\tkol+=1\\n\\t\\t\\t\\tused1[ar[i]]=1\\n\\t\\t\\t\\tused1[ar[i]+1]=1\\n\\t\\t\\t\\tused1[ar[i]-1]=1\\nprint(kol,end=' ')\\nkol1=0\\nfor i in ar:\\n\\tif used2[i-1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i-1]=1\\n\\telif used2[i]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i]=1\\n\\telif used2[i+1]==0:\\n\\t\\tkol1+=1\\n\\t\\tused2[i+1]=1\\nprint(kol1)\\n\\n\\n\", \"n = int(input())\\nl = list(map(int,input().split()))\\nl.sort()\\n#print(l)\\nll = l.copy()\\nup = 1\\nleft = l[0]\\nfor i in range(n):\\n\\tif l[i] > left + 2:\\n\\t\\tleft = l[i]\\n\\t\\tup += 1\\n#print(up)\\n#print(ll)\\nll[0] -= 1\\n#print(ll)\\nfor i in range(1,n-1):\\n\\tif ll[i-1] == ll[i]:\\n\\t\\tif ll[i] != ll[i+1]:\\n\\t\\t\\tll[i] += 1\\n\\telif ll[i-1] == ll[i]-1:\\n\\t\\tcontinue\\n\\telse:\\n\\t\\tll[i] -= 1\\n\\t#print(ll)\\nll[n-1] += 1\\n#print(ll)\\nd = {}\\nfor i in ll:\\n\\td[i] = 0\\nnajw = len(d)\\nprint(up, najw)\\n\", \"\\nn = int(input())\\n\\nx = list(map(int,input().split()))\\n\\nx.sort()\\n\\n\\ny = [] #to min\\n\\nfor i in range(n):\\n    if i == 0 or x[i-1] != x[i]:\\n        y.append(x[i])\\n\\nyend = [True] * len(y)\\nansmin = len(y)\\n\\nfor i in range(len(y)):\\n\\n    if i == 0 or ( not yend[i] ):\\n        continue\\n\\n    if y[i-1] + 1 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        ansmin -= 1\\n        yend[i] = False\\n\\n        if i+1 < len(y) and y[i+1] - 1 == y[i]:\\n            yend[i+1] = False\\n            ansmin -= 1\\n\\n    elif y[i-1] + 2 == y[i] and yend[i-1]:\\n        yend[i-1] = False\\n        yend[i] = False\\n        ansmin -= 1\\n \\n#print (yend)\\n\\n\\ndic = {}\\n\\nfor i in range(n):\\n\\n    if x[i] - 1 not in dic:\\n        dic[x[i] - 1] = 1\\n    elif x[i] not in dic:\\n        dic[x[i]] = 1\\n    else:\\n        dic[x[i] + 1] = 1\\n\\nprint (ansmin , len(dic))\", \"from itertools import*\\n_,x=open(0)\\nx=sorted(map(int,x.split()))\\ni,*y=sorted(set(x))\\ns={i+1}\\nfor i in y:\\n  if not(i-1in s or i in s):\\n    s.add(i+1)\\nprint(len(s),end=' ')\\ns=set()\\nfor i,t in groupby(x):\\n  t=len(list(t))\\n  if not i-1in s and t:\\n    s.add(i-1)\\n    t-=1\\n  if not i in s and t:\\n    s.add(i)\\n    t-=1\\n  if not i+1in s and t:\\n    s.add(i+1)\\nprint(len(s))\", \"import sys\\n\\ndef minp():\\n\\treturn sys.stdin.readline().strip()\\n\\ndef mint():\\n\\treturn int(minp())\\n\\ndef mints():\\n\\treturn list(map(int, minp().split()))\\n\\ndef solve():\\n\\tn = mint()\\n\\tx = list(mints())\\n\\tx.sort()\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tc = [0]*(n+2)\\n\\tfor i in x:\\n\\t\\tc[i] += 1\\n\\t\\tif w[i-1] == 0:\\n\\t\\t\\tw[i-1] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i] == 0:\\n\\t\\t\\tw[i] += 1\\n\\t\\t\\tr += 1\\n\\t\\telif w[i+1] == 0:\\n\\t\\t\\tw[i+1] += 1\\n\\t\\t\\tr += 1\\n\\n\\trm = r\\n\\tr = 0\\n\\tw = [0]*(n+2)\\n\\tfor i in range(1,n+1):\\n\\t\\tv = c[i]\\n\\t\\tif v != 0:\\n\\t\\t\\tif w[i+1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telif w[i-1] > 0:\\n\\t\\t\\t\\tpass\\n\\t\\t\\telse:\\n\\t\\t\\t\\tw[i+1] += v\\n\\t\\t\\t\\tr += 1\\n\\tprint(r,rm)\\n\\n#for i in range(mint()):\\nsolve()\\n\", \"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\\n# M = 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)))))\\ndef inv_mod(n):return pow(n, mod - 2, mod)\\n \\ndef li():return [int(i) for i in input().rstrip('\\\\n').split(' ')]\\ndef st():return input().rstrip('\\\\n')\\ndef val():return int(input().rstrip('\\\\n'))\\ndef li2():return [i for i in input().rstrip('\\\\n').split(' ')]\\ndef li3():return [int(i) for i in input().rstrip('\\\\n')]\\n\\n\\nn = val()\\nl = li()\\nl1 = l[:]\\nl2 = l[:]\\n\\ni = 0\\nl1 = sorted(list(set(l1)))\\ndoit = tot1 = 0\\ncn = Counter(l1)\\nl = l1[:]\\nwhile i < len(l1):\\n    if cn[l[i] - 1] > 0:\\n        cn[l[i]] -= 1\\n        cn[l[i] - 1] += 1\\n        l[i] -= 1\\n        i += 1\\n    else:\\n        cn[l[i]] -= 1\\n        cn[l[i] + 1] += 1\\n        l[i] += 1\\n        if i<len(l1) - 1 and l[i + 1] == l[i]:i += 2\\n        else:i += 1\\n# print(cn)\\ntot1 = sum(1 for i in cn if cn[i])\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n# print(l1)\\n\\n\\n\\ni = 0\\n\\ncnt = Counter(l2)\\nl2 = sorted(l2)\\n\\nl = l2[:]\\n\\n\\n\\nfor i in range(n):\\n    if cnt[l[i] - 1] == 0:\\n        cnt[l[i] - 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] -= 1\\n    elif cnt[l[i]] > 1:\\n        cnt[l[i] + 1] += 1\\n        cnt[l[i]] -= 1\\n        l[i] += 1\\n\\n\\ntot2 = sum(1 for i in cnt if cnt[i])\\n\\n\\n\\n\\n\\nprint(tot1,tot2)\"]",
        "difficulty": "introductory",
        "input": "10\n8 8 1 1 1 2 7 7 8 4\n",
        "output": "3 9\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1283/E"
    },
    {
        "id": 2422,
        "task_id": 4379,
        "test_case_id": 2,
        "question": "You are given an integer array of length $n$.\n\nYou have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to $[x, x + 1, \\dots, x + k - 1]$ for some value $x$ and length $k$.\n\nSubsequence of an array can be obtained by erasing some (possibly zero) elements from the array. You can erase any elements, not necessarily going successively. The remaining elements preserve their order. For example, for the array $[5, 3, 1, 2, 4]$ the following arrays are subsequences: $[3]$, $[5, 3, 1, 2, 4]$, $[5, 1, 4]$, but the array $[1, 3]$ is not.\n\n\n-----Input-----\n\nThe first line of the input containing integer number $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the length of the array. The second line of the input containing $n$ integer numbers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 10^9$) — the array itself.\n\n\n-----Output-----\n\nOn the first line print $k$ — the maximum length of the subsequence of the given array that forms an increasing sequence of consecutive integers.\n\nOn the second line print the sequence of the indices of the any maximum length subsequence of the given array that forms an increasing sequence of consecutive integers.\n\n\n-----Examples-----\nInput\n7\n3 3 4 7 5 6 8\n\nOutput\n4\n2 3 5 6 \n\nInput\n6\n1 3 5 2 4 6\n\nOutput\n2\n1 4 \n\nInput\n4\n10 9 8 7\n\nOutput\n1\n1 \n\nInput\n9\n6 7 8 3 4 5 9 10 11\n\nOutput\n6\n1 2 3 7 8 9 \n\n\n\n-----Note-----\n\nAll valid answers for the first example (as sequences of indices):   $[1, 3, 5, 6]$  $[2, 3, 5, 6]$ \n\nAll valid answers for the second example:   $[1, 4]$  $[2, 5]$  $[3, 6]$ \n\nAll valid answers for the third example:   $[1]$  $[2]$  $[3]$  $[4]$ \n\nAll valid answers for the fourth example:   $[1, 2, 3, 7, 8, 9]$",
        "solutions": "[\"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(list(m.keys()), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\\n\", \"n= int(input());\\na= list(map(int, input().split()));\\n#\\u0421\\u043b\\u043e\\u0432\\u0430\\u0440\\u044c: \\u043f\\u0430\\u0440\\u0430 \\u0447\\u0438\\u0441\\u043b\\u043e - \\u043c\\u0430\\u043a\\u0441\\u0438\\u043c\\u0430\\u043b\\u044c\\u043d\\u0430\\u044f \\u0434\\u043b\\u0438\\u043d\\u0430 \\u043f\\u043e\\u0441\\u043b\\u0435\\u0434\\u043e\\u0432\\u0430\\u0442\\u0435\\u043b\\u044c\\u043d\\u043e\\u0441\\u0442\\u0438, \\u043e\\u043a\\u0430\\u043d\\u0447\\u0438\\u0432\\u0430\\u044e\\u0449\\u0430\\u044f\\u0441\\u044f \\u0438\\u043c.\\nd= dict();\\nfor x in a:\\n    d[x]=d.get(x-1, 0)+1;\\nstart=0;\\nfinish=0;\\nresult=0;\\nfor key in d.keys():\\n    if d[key]>result:\\n        result=d[key];\\n        finish=key;\\n        start=key-d[key]+1;\\nprint(result);\\ncurr=start;\\nfor i, x in enumerate(a):\\n    if curr==x:\\n        print(i+1, end=' ');\\n        curr+=1;\\n    \\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nh={}\\nfor i in a:\\n    h[i-1]=0\\n\\ntb=0\\nend=-1\\nfor i in a:\\n    h[i]=h[i-1]+1\\n    if tb<h[i]:\\n        tb=h[i]\\n        end=i\\narr=[]\\nstart=end-tb+1\\nfor i in range(n):\\n    if a[i]==start:\\n        arr.append(i+1)\\n        start+=1\\n\\nprint(tb)\\nprint(*arr)\\n\", \"n = int(input())\\ns = list(map(int,input().split()))\\nrl = {}\\nbest_range = range(0)\\nfor x in s:\\n    run = rl[x] = rl.get(x-1, 0) + 1\\n    r = range(x-run+1, x+1)\\n    if len(r) > len(best_range):\\n        best_range = r\\nres = list(best_range)\\nsize = len(res)\\noutput = []\\npointer = 0\\nfor i,c in enumerate(s):\\n    if res[pointer] == c:\\n        output.append(str(i+1))\\n        pointer += 1\\n    \\n    if pointer >= size:break\\nprint (size)\\nprint (' '.join(output))\", \"n = int(input())\\na = input().split()\\nfor i, x in enumerate(a):\\n    a[i] = int(x)\\n\\nd = [float('inf')]*(n + 1)\\nd[0] = 0\\nlength = 0\\nvalue = 0\\ns = dict()\\nfor i in range(0, n):\\n    if a[i] - 1 in s:\\n        if a[i] is s:\\n            s[a[i]] = max(s[a[i]], s[a[i - 1]] + 1)\\n        else:\\n            s[a[i]] = s[a[i] - 1] + 1\\n    else:\\n        s[a[i]] = 1\\n    if s[a[i]] > length:\\n         length = s[a[i]]\\n         value = a[i]  \\nans = []\\nvalue0 = value - length + 1\\nfor i, x in enumerate(a):\\n    if x == value0:\\n        ans.append(i + 1)\\n        value0 = value0 + 1\\n        if value0 > value:\\n            break \\n        \\nprint(length)\\nprint(' '.join(str(i) for i in ans))\\n\\n    \\n\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nA = list(map(int, input().split()))\\nlast = defaultdict(int)\\nD = {0: (0, 0)}\\nbest = (0, 0)\\nfor i, a in enumerate(A, start=1):\\n    last[a] = i\\n    last_a1 = last[a - 1]\\n    best_a1, _ = D[last_a1]\\n    D[i] = (1 + best_a1, last_a1)\\n    best = max(best, (1 + best_a1, i))\\n\\nprint(best[0])\\nrsseq = []\\ni = best[1]\\nwhile i != 0:\\n    rsseq.append(i)\\n    i = D[i][1]\\nprint(' '.join(map(str, reversed(rsseq))))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nd = dict()\\nopt = []\\nm = -1\\nfor i in range(n):\\n    t = a[i]\\n    p = t - 1\\n    if p in d:\\n        if (t not in d) or ((p - d[p]) >= (t - d[t])):\\n            d[t] = d[p]\\n            #d.pop(p)\\n            k = t - d[t]\\n            if k > m:\\n                m = k\\n                opt = d[t]\\n    else:\\n        if t not in d:\\n            d[t] = t\\n            if m == -1:\\n                opt = t\\n                m = 0\\nprint(m+1)\\nr = []\\nfor i in range(n):\\n    if a[i] == opt:\\n        r += [i+1]\\n        opt += 1\\nprint(*r)\", \"N = int(input())\\nD = {}\\nL = list(map(int,input().split()))[::-1]\\nfor i in L:\\n\\tD[i] = max(D.get(i,0),D.get(i+1,0)+1)\\nM = max([(i[1],-i[0]) for i in D.items()])\\nL.reverse()\\nprint(M[0])\\nM = -M[1]\\nfor i in range(N):\\n\\tif L[i]==M:\\n\\t\\tprint(i+1,end=' ')\\n\\t\\tM += 1\", \"n = int(input())\\na = [int(s) for s in input().split()]\\nlens = {}\\nmaxlen = 1\\nmaxlast = a[0]\\nfor i in range(n):\\n    lens[a[i]] = lens.get(a[i]-1, 0) + 1\\n    if lens[a[i]] > maxlen:\\n        maxlen = lens[a[i]]\\n        maxlast = a[i]\\n# print(lens)\\n# print(maxlast, maxlen)\\nprint(maxlen)\\nsubs = []\\nsi = maxlast - maxlen + 1\\nfor i in range(n):\\n    if a[i] == si:\\n        subs.append(i+1)\\n        si += 1\\nprint(*subs, sep=' ')\", \"n=int(input())\\nd=dict()\\nm=0\\nval=0\\na=list(map(int,input().split()))\\ns=set()\\naps=s.add\\nfor i in a:\\n    d[i]=d.get(i-1,0)+1\\n    if d[i]>m:\\n        m=d[i]\\n        val=int(i)\\n\\nans=[]\\nap=ans.append\\nfor i in range(n-1,-1,-1):\\n    if a[i]==val:\\n        val-=1\\n        ap(i+1)\\nprint(m)\\nprint(*ans[::-1])\", \"n= int(input());\\na= list(map(int, input().split()));\\nd= dict();\\nfor x in a:\\n    d[x]=d.get(x-1, 0)+1;\\nstart=0;\\nfinish=0;\\nresult=0;\\nfor key in d.keys():\\n    if d[key]>result:\\n        result=d[key];\\n        finish=key;\\n        start=key-d[key]+1;\\nprint(result);\\ncurr=start;\\nfor i, x in enumerate(a):\\n    if curr==x:\\n        print(i+1, end=' ');\\n        curr+=1;\", \"n=int(input())\\narr=list(map(int,input().split()))\\narr.reverse()\\nd={}\\nfor i in range(len(arr)):\\n    if arr[i]+1 in d.keys():\\n        d[arr[i]]=d[arr[i]+1]+1 \\n    else:\\n        d[arr[i]]=1 \\nmaxx=0\\nnumber=0\\nfor i in d.keys():\\n    if d[i]>maxx:\\n        maxx=d[i]\\n        number=i \\narr.reverse()\\ncurr=number\\nprint(maxx)\\nfor i in range(n):\\n    if arr[i]==curr:\\n        print(i+1,end=\\\" \\\")\\n        curr+=1\\n\", \"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(m.keys(), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nd = {}\\n\\nfor ai in a:\\n  d[ai] = d.get(ai - 1, 0) + 1\\n\\nmaxRange = 0\\nendVal = 0\\nfor key in d.keys():\\n  if (d[key] > maxRange):\\n    maxRange = d[key]\\n    endVal = key\\n\\nstartVal = endVal - maxRange + 1\\nprint(maxRange)\\nfor i, val in enumerate(a):\\n  if (val == startVal):\\n    print(i+1, end= ' ')\\n    startVal += 1\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\narr.reverse()\\ndic = {}\\n\\nfor i in range(n):\\n\\tdic[arr[i]] = dic[arr[i] + 1] + 1 if arr[i] + 1 in dic.keys() else 1\\nmx = 0\\nnum = 0\\n\\nfor i in dic.keys():\\n\\tif dic[i] > mx:\\n\\t\\tmx = dic[i]\\n\\t\\tnum = i \\nprint(mx)\\narr.reverse()\\nfor i in range(n):\\n\\tif arr[i] == num:\\n\\t\\tprint(i+1,end= ' ')\\n\\t\\tnum += 1\", \"n=int(input())\\na=list(map(int ,input().split() ) )\\nd={}\\nmaxn=0\\nmax_ind=0\\n\\nfor ai in a:\\n\\td[ai]=d.get(ai-1,0)+1\\n\\nfor key in d.keys():\\n\\tif(d[key] >maxn):\\n\\t  maxn=d[key]\\n\\t  max_ind=key\\n\\nstart= max_ind-maxn+1\\nprint(maxn)\\ni=0\\nfor ai in a:\\n\\ti+=1\\n\\tif(ai==start):\\n                 print(i,end=' ')\\n                 start+=1\\n                 \\n\\t\", \"n = int(input())\\nT = input().split(' ')\\nfor i in range(n):\\n    T[i] = int(T[i])\\nD = {}\\nfor i in range(n):\\n    D[T[i]] = 0\\nfor i in range(n):\\n    if T[i]-1 not in D:\\n        D[T[i]] = 1\\n    else:\\n        D[T[i]] = D[T[i]-1] + 1\\nm = -1\\nj = -1\\nfor i in D:\\n    if D[i] > m:\\n        m = D[i]\\n        j = i\\nL = []\\nfor i in range(n-1, -1, -1):\\n    if T[i] == j:\\n        L.append(i)\\n        j -= 1\\nprint(m)\\nfor i in range(m-1):\\n    print(L[m-1-i]+1, end=' ')\\nprint(L[0]+1)\\n\", \"n = int(input())\\nG = list(map(int,input().split()))\\nD = {}\\nM = 0\\nfor i in G:\\n    if i-1 in D:\\n        D[i] = D[i-1] + 1\\n    else:\\n        D[i] = 1\\n    if D[i]>M:\\n        M = D[i]\\n        Mi = i\\n#print(M,Mi)\\nR = []\\nA = Mi\\nfor i in range(len(G)-1,-1,-1):\\n    if G[i] == A:\\n        R.append(i+1)\\n        A-=1\\nprint(M)\\nprint(*R[::-1])\", \"input()\\na = list(map(int, input().split()))\\n\\nb = {i: 0 for i in set(a)}\\n\\nans = 0\\nans_ind = 0\\nfor i in range(len(a)):\\n    if a[i] - 1 in b.keys():\\n        b[a[i]] = b[a[i] - 1] + 1\\n    else:\\n        b[a[i]] = 1\\n    if (b[a[i]] > ans):\\n        ans = b[a[i]]\\n        ans_ind = i\\nprint(ans)\\ns = \\\"\\\"\\naans = []\\naans.append(ans_ind + 1)\\nx = a[ans_ind]\\nfor i in range(ans - 1):\\n    while (a[ans_ind] != x - 1):\\n        ans_ind -= 1\\n    x = a[ans_ind]\\n    aans.append(ans_ind + 1)\\nfor i in aans[::-1]:\\n    print(i, end=' ')\", \"from collections import Counter\\n\\n\\ndef read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef main():\\n    n, = read_nums()\\n    nums = read_nums()\\n    dp = Counter()\\n    for i in range(n):\\n        dp[nums[i]] = dp[nums[i] - 1] + 1\\n\\n    indexes = {}\\n    for i in range(n):\\n        indexes[nums[i]] = i\\n\\n    last_num = max(list(dp.items()), key=lambda x: x[1])[0]\\n\\n    result = []\\n    for i in range(n - 1, -1, -1):\\n        if nums[i] == last_num:\\n            result.append(i)\\n            last_num -= 1\\n\\n    result.reverse()\\n    print(len(result))\\n    print(' '.join([str(x + 1) for x in result]))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nG = list(map(int,input().split()))\\nD = {}\\nM = 0\\nfor i in G:\\n    if i-1 in D:\\n        D[i] = D[i-1] + 1\\n    else:\\n        D[i] = 1\\n    if D[i]>M:\\n        M = D[i]\\n        Mi = i\\n#print(M,Mi)\\nR = []\\nA = Mi\\nfor i in range(len(G)-1,-1,-1):\\n    if G[i] == A:\\n        R.append(i+1)\\n        A-=1\\nprint(M)\\nprint(*R[::-1])\", \"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(list(m.keys()), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = [-1 for _ in range(n)]\\n\\ndp = {}\\nbest = -1\\nbest2 = -1\\n\\nfor i, x in enumerate(a):\\n    p, q = dp.get(x, (1, i))\\n    r, t = dp.get(x - 1, (0, 0))\\n\\n    if r + 1 > p:\\n        p, q = r + 1, i\\n    else:\\n        t = i\\n\\n    dp[x] = (p, q)\\n    b[i] = t\\n\\n    if best < 0 or dp[best][0] < p:\\n        best = x\\n        best2 = i\\n\\nans = []\\nm = dp[best][0]\\n\\nfor _ in range(m):\\n    ans.append(best2)\\n    best2 = b[best2]\\n\\nans.reverse()\\n\\nprint(len(ans))\\nprint(' '.join([str(x + 1) for x in ans]))\\n\"]",
        "difficulty": "introductory",
        "input": "6\n1 3 5 2 4 6\n",
        "output": "2\n1 4 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/977/F"
    },
    {
        "id": 2423,
        "task_id": 4379,
        "test_case_id": 4,
        "question": "You are given an integer array of length $n$.\n\nYou have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to $[x, x + 1, \\dots, x + k - 1]$ for some value $x$ and length $k$.\n\nSubsequence of an array can be obtained by erasing some (possibly zero) elements from the array. You can erase any elements, not necessarily going successively. The remaining elements preserve their order. For example, for the array $[5, 3, 1, 2, 4]$ the following arrays are subsequences: $[3]$, $[5, 3, 1, 2, 4]$, $[5, 1, 4]$, but the array $[1, 3]$ is not.\n\n\n-----Input-----\n\nThe first line of the input containing integer number $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the length of the array. The second line of the input containing $n$ integer numbers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 10^9$) — the array itself.\n\n\n-----Output-----\n\nOn the first line print $k$ — the maximum length of the subsequence of the given array that forms an increasing sequence of consecutive integers.\n\nOn the second line print the sequence of the indices of the any maximum length subsequence of the given array that forms an increasing sequence of consecutive integers.\n\n\n-----Examples-----\nInput\n7\n3 3 4 7 5 6 8\n\nOutput\n4\n2 3 5 6 \n\nInput\n6\n1 3 5 2 4 6\n\nOutput\n2\n1 4 \n\nInput\n4\n10 9 8 7\n\nOutput\n1\n1 \n\nInput\n9\n6 7 8 3 4 5 9 10 11\n\nOutput\n6\n1 2 3 7 8 9 \n\n\n\n-----Note-----\n\nAll valid answers for the first example (as sequences of indices):   $[1, 3, 5, 6]$  $[2, 3, 5, 6]$ \n\nAll valid answers for the second example:   $[1, 4]$  $[2, 5]$  $[3, 6]$ \n\nAll valid answers for the third example:   $[1]$  $[2]$  $[3]$  $[4]$ \n\nAll valid answers for the fourth example:   $[1, 2, 3, 7, 8, 9]$",
        "solutions": "[\"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(list(m.keys()), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\\n\", \"n= int(input());\\na= list(map(int, input().split()));\\n#\\u0421\\u043b\\u043e\\u0432\\u0430\\u0440\\u044c: \\u043f\\u0430\\u0440\\u0430 \\u0447\\u0438\\u0441\\u043b\\u043e - \\u043c\\u0430\\u043a\\u0441\\u0438\\u043c\\u0430\\u043b\\u044c\\u043d\\u0430\\u044f \\u0434\\u043b\\u0438\\u043d\\u0430 \\u043f\\u043e\\u0441\\u043b\\u0435\\u0434\\u043e\\u0432\\u0430\\u0442\\u0435\\u043b\\u044c\\u043d\\u043e\\u0441\\u0442\\u0438, \\u043e\\u043a\\u0430\\u043d\\u0447\\u0438\\u0432\\u0430\\u044e\\u0449\\u0430\\u044f\\u0441\\u044f \\u0438\\u043c.\\nd= dict();\\nfor x in a:\\n    d[x]=d.get(x-1, 0)+1;\\nstart=0;\\nfinish=0;\\nresult=0;\\nfor key in d.keys():\\n    if d[key]>result:\\n        result=d[key];\\n        finish=key;\\n        start=key-d[key]+1;\\nprint(result);\\ncurr=start;\\nfor i, x in enumerate(a):\\n    if curr==x:\\n        print(i+1, end=' ');\\n        curr+=1;\\n    \\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nh={}\\nfor i in a:\\n    h[i-1]=0\\n\\ntb=0\\nend=-1\\nfor i in a:\\n    h[i]=h[i-1]+1\\n    if tb<h[i]:\\n        tb=h[i]\\n        end=i\\narr=[]\\nstart=end-tb+1\\nfor i in range(n):\\n    if a[i]==start:\\n        arr.append(i+1)\\n        start+=1\\n\\nprint(tb)\\nprint(*arr)\\n\", \"n = int(input())\\ns = list(map(int,input().split()))\\nrl = {}\\nbest_range = range(0)\\nfor x in s:\\n    run = rl[x] = rl.get(x-1, 0) + 1\\n    r = range(x-run+1, x+1)\\n    if len(r) > len(best_range):\\n        best_range = r\\nres = list(best_range)\\nsize = len(res)\\noutput = []\\npointer = 0\\nfor i,c in enumerate(s):\\n    if res[pointer] == c:\\n        output.append(str(i+1))\\n        pointer += 1\\n    \\n    if pointer >= size:break\\nprint (size)\\nprint (' '.join(output))\", \"n = int(input())\\na = input().split()\\nfor i, x in enumerate(a):\\n    a[i] = int(x)\\n\\nd = [float('inf')]*(n + 1)\\nd[0] = 0\\nlength = 0\\nvalue = 0\\ns = dict()\\nfor i in range(0, n):\\n    if a[i] - 1 in s:\\n        if a[i] is s:\\n            s[a[i]] = max(s[a[i]], s[a[i - 1]] + 1)\\n        else:\\n            s[a[i]] = s[a[i] - 1] + 1\\n    else:\\n        s[a[i]] = 1\\n    if s[a[i]] > length:\\n         length = s[a[i]]\\n         value = a[i]  \\nans = []\\nvalue0 = value - length + 1\\nfor i, x in enumerate(a):\\n    if x == value0:\\n        ans.append(i + 1)\\n        value0 = value0 + 1\\n        if value0 > value:\\n            break \\n        \\nprint(length)\\nprint(' '.join(str(i) for i in ans))\\n\\n    \\n\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nA = list(map(int, input().split()))\\nlast = defaultdict(int)\\nD = {0: (0, 0)}\\nbest = (0, 0)\\nfor i, a in enumerate(A, start=1):\\n    last[a] = i\\n    last_a1 = last[a - 1]\\n    best_a1, _ = D[last_a1]\\n    D[i] = (1 + best_a1, last_a1)\\n    best = max(best, (1 + best_a1, i))\\n\\nprint(best[0])\\nrsseq = []\\ni = best[1]\\nwhile i != 0:\\n    rsseq.append(i)\\n    i = D[i][1]\\nprint(' '.join(map(str, reversed(rsseq))))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nd = dict()\\nopt = []\\nm = -1\\nfor i in range(n):\\n    t = a[i]\\n    p = t - 1\\n    if p in d:\\n        if (t not in d) or ((p - d[p]) >= (t - d[t])):\\n            d[t] = d[p]\\n            #d.pop(p)\\n            k = t - d[t]\\n            if k > m:\\n                m = k\\n                opt = d[t]\\n    else:\\n        if t not in d:\\n            d[t] = t\\n            if m == -1:\\n                opt = t\\n                m = 0\\nprint(m+1)\\nr = []\\nfor i in range(n):\\n    if a[i] == opt:\\n        r += [i+1]\\n        opt += 1\\nprint(*r)\", \"N = int(input())\\nD = {}\\nL = list(map(int,input().split()))[::-1]\\nfor i in L:\\n\\tD[i] = max(D.get(i,0),D.get(i+1,0)+1)\\nM = max([(i[1],-i[0]) for i in D.items()])\\nL.reverse()\\nprint(M[0])\\nM = -M[1]\\nfor i in range(N):\\n\\tif L[i]==M:\\n\\t\\tprint(i+1,end=' ')\\n\\t\\tM += 1\", \"n = int(input())\\na = [int(s) for s in input().split()]\\nlens = {}\\nmaxlen = 1\\nmaxlast = a[0]\\nfor i in range(n):\\n    lens[a[i]] = lens.get(a[i]-1, 0) + 1\\n    if lens[a[i]] > maxlen:\\n        maxlen = lens[a[i]]\\n        maxlast = a[i]\\n# print(lens)\\n# print(maxlast, maxlen)\\nprint(maxlen)\\nsubs = []\\nsi = maxlast - maxlen + 1\\nfor i in range(n):\\n    if a[i] == si:\\n        subs.append(i+1)\\n        si += 1\\nprint(*subs, sep=' ')\", \"n=int(input())\\nd=dict()\\nm=0\\nval=0\\na=list(map(int,input().split()))\\ns=set()\\naps=s.add\\nfor i in a:\\n    d[i]=d.get(i-1,0)+1\\n    if d[i]>m:\\n        m=d[i]\\n        val=int(i)\\n\\nans=[]\\nap=ans.append\\nfor i in range(n-1,-1,-1):\\n    if a[i]==val:\\n        val-=1\\n        ap(i+1)\\nprint(m)\\nprint(*ans[::-1])\", \"n= int(input());\\na= list(map(int, input().split()));\\nd= dict();\\nfor x in a:\\n    d[x]=d.get(x-1, 0)+1;\\nstart=0;\\nfinish=0;\\nresult=0;\\nfor key in d.keys():\\n    if d[key]>result:\\n        result=d[key];\\n        finish=key;\\n        start=key-d[key]+1;\\nprint(result);\\ncurr=start;\\nfor i, x in enumerate(a):\\n    if curr==x:\\n        print(i+1, end=' ');\\n        curr+=1;\", \"n=int(input())\\narr=list(map(int,input().split()))\\narr.reverse()\\nd={}\\nfor i in range(len(arr)):\\n    if arr[i]+1 in d.keys():\\n        d[arr[i]]=d[arr[i]+1]+1 \\n    else:\\n        d[arr[i]]=1 \\nmaxx=0\\nnumber=0\\nfor i in d.keys():\\n    if d[i]>maxx:\\n        maxx=d[i]\\n        number=i \\narr.reverse()\\ncurr=number\\nprint(maxx)\\nfor i in range(n):\\n    if arr[i]==curr:\\n        print(i+1,end=\\\" \\\")\\n        curr+=1\\n\", \"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(m.keys(), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nd = {}\\n\\nfor ai in a:\\n  d[ai] = d.get(ai - 1, 0) + 1\\n\\nmaxRange = 0\\nendVal = 0\\nfor key in d.keys():\\n  if (d[key] > maxRange):\\n    maxRange = d[key]\\n    endVal = key\\n\\nstartVal = endVal - maxRange + 1\\nprint(maxRange)\\nfor i, val in enumerate(a):\\n  if (val == startVal):\\n    print(i+1, end= ' ')\\n    startVal += 1\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\narr.reverse()\\ndic = {}\\n\\nfor i in range(n):\\n\\tdic[arr[i]] = dic[arr[i] + 1] + 1 if arr[i] + 1 in dic.keys() else 1\\nmx = 0\\nnum = 0\\n\\nfor i in dic.keys():\\n\\tif dic[i] > mx:\\n\\t\\tmx = dic[i]\\n\\t\\tnum = i \\nprint(mx)\\narr.reverse()\\nfor i in range(n):\\n\\tif arr[i] == num:\\n\\t\\tprint(i+1,end= ' ')\\n\\t\\tnum += 1\", \"n=int(input())\\na=list(map(int ,input().split() ) )\\nd={}\\nmaxn=0\\nmax_ind=0\\n\\nfor ai in a:\\n\\td[ai]=d.get(ai-1,0)+1\\n\\nfor key in d.keys():\\n\\tif(d[key] >maxn):\\n\\t  maxn=d[key]\\n\\t  max_ind=key\\n\\nstart= max_ind-maxn+1\\nprint(maxn)\\ni=0\\nfor ai in a:\\n\\ti+=1\\n\\tif(ai==start):\\n                 print(i,end=' ')\\n                 start+=1\\n                 \\n\\t\", \"n = int(input())\\nT = input().split(' ')\\nfor i in range(n):\\n    T[i] = int(T[i])\\nD = {}\\nfor i in range(n):\\n    D[T[i]] = 0\\nfor i in range(n):\\n    if T[i]-1 not in D:\\n        D[T[i]] = 1\\n    else:\\n        D[T[i]] = D[T[i]-1] + 1\\nm = -1\\nj = -1\\nfor i in D:\\n    if D[i] > m:\\n        m = D[i]\\n        j = i\\nL = []\\nfor i in range(n-1, -1, -1):\\n    if T[i] == j:\\n        L.append(i)\\n        j -= 1\\nprint(m)\\nfor i in range(m-1):\\n    print(L[m-1-i]+1, end=' ')\\nprint(L[0]+1)\\n\", \"n = int(input())\\nG = list(map(int,input().split()))\\nD = {}\\nM = 0\\nfor i in G:\\n    if i-1 in D:\\n        D[i] = D[i-1] + 1\\n    else:\\n        D[i] = 1\\n    if D[i]>M:\\n        M = D[i]\\n        Mi = i\\n#print(M,Mi)\\nR = []\\nA = Mi\\nfor i in range(len(G)-1,-1,-1):\\n    if G[i] == A:\\n        R.append(i+1)\\n        A-=1\\nprint(M)\\nprint(*R[::-1])\", \"input()\\na = list(map(int, input().split()))\\n\\nb = {i: 0 for i in set(a)}\\n\\nans = 0\\nans_ind = 0\\nfor i in range(len(a)):\\n    if a[i] - 1 in b.keys():\\n        b[a[i]] = b[a[i] - 1] + 1\\n    else:\\n        b[a[i]] = 1\\n    if (b[a[i]] > ans):\\n        ans = b[a[i]]\\n        ans_ind = i\\nprint(ans)\\ns = \\\"\\\"\\naans = []\\naans.append(ans_ind + 1)\\nx = a[ans_ind]\\nfor i in range(ans - 1):\\n    while (a[ans_ind] != x - 1):\\n        ans_ind -= 1\\n    x = a[ans_ind]\\n    aans.append(ans_ind + 1)\\nfor i in aans[::-1]:\\n    print(i, end=' ')\", \"from collections import Counter\\n\\n\\ndef read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef main():\\n    n, = read_nums()\\n    nums = read_nums()\\n    dp = Counter()\\n    for i in range(n):\\n        dp[nums[i]] = dp[nums[i] - 1] + 1\\n\\n    indexes = {}\\n    for i in range(n):\\n        indexes[nums[i]] = i\\n\\n    last_num = max(list(dp.items()), key=lambda x: x[1])[0]\\n\\n    result = []\\n    for i in range(n - 1, -1, -1):\\n        if nums[i] == last_num:\\n            result.append(i)\\n            last_num -= 1\\n\\n    result.reverse()\\n    print(len(result))\\n    print(' '.join([str(x + 1) for x in result]))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nG = list(map(int,input().split()))\\nD = {}\\nM = 0\\nfor i in G:\\n    if i-1 in D:\\n        D[i] = D[i-1] + 1\\n    else:\\n        D[i] = 1\\n    if D[i]>M:\\n        M = D[i]\\n        Mi = i\\n#print(M,Mi)\\nR = []\\nA = Mi\\nfor i in range(len(G)-1,-1,-1):\\n    if G[i] == A:\\n        R.append(i+1)\\n        A-=1\\nprint(M)\\nprint(*R[::-1])\", \"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(list(m.keys()), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = [-1 for _ in range(n)]\\n\\ndp = {}\\nbest = -1\\nbest2 = -1\\n\\nfor i, x in enumerate(a):\\n    p, q = dp.get(x, (1, i))\\n    r, t = dp.get(x - 1, (0, 0))\\n\\n    if r + 1 > p:\\n        p, q = r + 1, i\\n    else:\\n        t = i\\n\\n    dp[x] = (p, q)\\n    b[i] = t\\n\\n    if best < 0 or dp[best][0] < p:\\n        best = x\\n        best2 = i\\n\\nans = []\\nm = dp[best][0]\\n\\nfor _ in range(m):\\n    ans.append(best2)\\n    best2 = b[best2]\\n\\nans.reverse()\\n\\nprint(len(ans))\\nprint(' '.join([str(x + 1) for x in ans]))\\n\"]",
        "difficulty": "introductory",
        "input": "9\n6 7 8 3 4 5 9 10 11\n",
        "output": "6\n1 2 3 7 8 9 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/977/F"
    },
    {
        "id": 2424,
        "task_id": 4379,
        "test_case_id": 7,
        "question": "You are given an integer array of length $n$.\n\nYou have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to $[x, x + 1, \\dots, x + k - 1]$ for some value $x$ and length $k$.\n\nSubsequence of an array can be obtained by erasing some (possibly zero) elements from the array. You can erase any elements, not necessarily going successively. The remaining elements preserve their order. For example, for the array $[5, 3, 1, 2, 4]$ the following arrays are subsequences: $[3]$, $[5, 3, 1, 2, 4]$, $[5, 1, 4]$, but the array $[1, 3]$ is not.\n\n\n-----Input-----\n\nThe first line of the input containing integer number $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the length of the array. The second line of the input containing $n$ integer numbers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 10^9$) — the array itself.\n\n\n-----Output-----\n\nOn the first line print $k$ — the maximum length of the subsequence of the given array that forms an increasing sequence of consecutive integers.\n\nOn the second line print the sequence of the indices of the any maximum length subsequence of the given array that forms an increasing sequence of consecutive integers.\n\n\n-----Examples-----\nInput\n7\n3 3 4 7 5 6 8\n\nOutput\n4\n2 3 5 6 \n\nInput\n6\n1 3 5 2 4 6\n\nOutput\n2\n1 4 \n\nInput\n4\n10 9 8 7\n\nOutput\n1\n1 \n\nInput\n9\n6 7 8 3 4 5 9 10 11\n\nOutput\n6\n1 2 3 7 8 9 \n\n\n\n-----Note-----\n\nAll valid answers for the first example (as sequences of indices):   $[1, 3, 5, 6]$  $[2, 3, 5, 6]$ \n\nAll valid answers for the second example:   $[1, 4]$  $[2, 5]$  $[3, 6]$ \n\nAll valid answers for the third example:   $[1]$  $[2]$  $[3]$  $[4]$ \n\nAll valid answers for the fourth example:   $[1, 2, 3, 7, 8, 9]$",
        "solutions": "[\"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(list(m.keys()), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\\n\", \"n= int(input());\\na= list(map(int, input().split()));\\n#\\u0421\\u043b\\u043e\\u0432\\u0430\\u0440\\u044c: \\u043f\\u0430\\u0440\\u0430 \\u0447\\u0438\\u0441\\u043b\\u043e - \\u043c\\u0430\\u043a\\u0441\\u0438\\u043c\\u0430\\u043b\\u044c\\u043d\\u0430\\u044f \\u0434\\u043b\\u0438\\u043d\\u0430 \\u043f\\u043e\\u0441\\u043b\\u0435\\u0434\\u043e\\u0432\\u0430\\u0442\\u0435\\u043b\\u044c\\u043d\\u043e\\u0441\\u0442\\u0438, \\u043e\\u043a\\u0430\\u043d\\u0447\\u0438\\u0432\\u0430\\u044e\\u0449\\u0430\\u044f\\u0441\\u044f \\u0438\\u043c.\\nd= dict();\\nfor x in a:\\n    d[x]=d.get(x-1, 0)+1;\\nstart=0;\\nfinish=0;\\nresult=0;\\nfor key in d.keys():\\n    if d[key]>result:\\n        result=d[key];\\n        finish=key;\\n        start=key-d[key]+1;\\nprint(result);\\ncurr=start;\\nfor i, x in enumerate(a):\\n    if curr==x:\\n        print(i+1, end=' ');\\n        curr+=1;\\n    \\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nh={}\\nfor i in a:\\n    h[i-1]=0\\n\\ntb=0\\nend=-1\\nfor i in a:\\n    h[i]=h[i-1]+1\\n    if tb<h[i]:\\n        tb=h[i]\\n        end=i\\narr=[]\\nstart=end-tb+1\\nfor i in range(n):\\n    if a[i]==start:\\n        arr.append(i+1)\\n        start+=1\\n\\nprint(tb)\\nprint(*arr)\\n\", \"n = int(input())\\ns = list(map(int,input().split()))\\nrl = {}\\nbest_range = range(0)\\nfor x in s:\\n    run = rl[x] = rl.get(x-1, 0) + 1\\n    r = range(x-run+1, x+1)\\n    if len(r) > len(best_range):\\n        best_range = r\\nres = list(best_range)\\nsize = len(res)\\noutput = []\\npointer = 0\\nfor i,c in enumerate(s):\\n    if res[pointer] == c:\\n        output.append(str(i+1))\\n        pointer += 1\\n    \\n    if pointer >= size:break\\nprint (size)\\nprint (' '.join(output))\", \"n = int(input())\\na = input().split()\\nfor i, x in enumerate(a):\\n    a[i] = int(x)\\n\\nd = [float('inf')]*(n + 1)\\nd[0] = 0\\nlength = 0\\nvalue = 0\\ns = dict()\\nfor i in range(0, n):\\n    if a[i] - 1 in s:\\n        if a[i] is s:\\n            s[a[i]] = max(s[a[i]], s[a[i - 1]] + 1)\\n        else:\\n            s[a[i]] = s[a[i] - 1] + 1\\n    else:\\n        s[a[i]] = 1\\n    if s[a[i]] > length:\\n         length = s[a[i]]\\n         value = a[i]  \\nans = []\\nvalue0 = value - length + 1\\nfor i, x in enumerate(a):\\n    if x == value0:\\n        ans.append(i + 1)\\n        value0 = value0 + 1\\n        if value0 > value:\\n            break \\n        \\nprint(length)\\nprint(' '.join(str(i) for i in ans))\\n\\n    \\n\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nA = list(map(int, input().split()))\\nlast = defaultdict(int)\\nD = {0: (0, 0)}\\nbest = (0, 0)\\nfor i, a in enumerate(A, start=1):\\n    last[a] = i\\n    last_a1 = last[a - 1]\\n    best_a1, _ = D[last_a1]\\n    D[i] = (1 + best_a1, last_a1)\\n    best = max(best, (1 + best_a1, i))\\n\\nprint(best[0])\\nrsseq = []\\ni = best[1]\\nwhile i != 0:\\n    rsseq.append(i)\\n    i = D[i][1]\\nprint(' '.join(map(str, reversed(rsseq))))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nd = dict()\\nopt = []\\nm = -1\\nfor i in range(n):\\n    t = a[i]\\n    p = t - 1\\n    if p in d:\\n        if (t not in d) or ((p - d[p]) >= (t - d[t])):\\n            d[t] = d[p]\\n            #d.pop(p)\\n            k = t - d[t]\\n            if k > m:\\n                m = k\\n                opt = d[t]\\n    else:\\n        if t not in d:\\n            d[t] = t\\n            if m == -1:\\n                opt = t\\n                m = 0\\nprint(m+1)\\nr = []\\nfor i in range(n):\\n    if a[i] == opt:\\n        r += [i+1]\\n        opt += 1\\nprint(*r)\", \"N = int(input())\\nD = {}\\nL = list(map(int,input().split()))[::-1]\\nfor i in L:\\n\\tD[i] = max(D.get(i,0),D.get(i+1,0)+1)\\nM = max([(i[1],-i[0]) for i in D.items()])\\nL.reverse()\\nprint(M[0])\\nM = -M[1]\\nfor i in range(N):\\n\\tif L[i]==M:\\n\\t\\tprint(i+1,end=' ')\\n\\t\\tM += 1\", \"n = int(input())\\na = [int(s) for s in input().split()]\\nlens = {}\\nmaxlen = 1\\nmaxlast = a[0]\\nfor i in range(n):\\n    lens[a[i]] = lens.get(a[i]-1, 0) + 1\\n    if lens[a[i]] > maxlen:\\n        maxlen = lens[a[i]]\\n        maxlast = a[i]\\n# print(lens)\\n# print(maxlast, maxlen)\\nprint(maxlen)\\nsubs = []\\nsi = maxlast - maxlen + 1\\nfor i in range(n):\\n    if a[i] == si:\\n        subs.append(i+1)\\n        si += 1\\nprint(*subs, sep=' ')\", \"n=int(input())\\nd=dict()\\nm=0\\nval=0\\na=list(map(int,input().split()))\\ns=set()\\naps=s.add\\nfor i in a:\\n    d[i]=d.get(i-1,0)+1\\n    if d[i]>m:\\n        m=d[i]\\n        val=int(i)\\n\\nans=[]\\nap=ans.append\\nfor i in range(n-1,-1,-1):\\n    if a[i]==val:\\n        val-=1\\n        ap(i+1)\\nprint(m)\\nprint(*ans[::-1])\", \"n= int(input());\\na= list(map(int, input().split()));\\nd= dict();\\nfor x in a:\\n    d[x]=d.get(x-1, 0)+1;\\nstart=0;\\nfinish=0;\\nresult=0;\\nfor key in d.keys():\\n    if d[key]>result:\\n        result=d[key];\\n        finish=key;\\n        start=key-d[key]+1;\\nprint(result);\\ncurr=start;\\nfor i, x in enumerate(a):\\n    if curr==x:\\n        print(i+1, end=' ');\\n        curr+=1;\", \"n=int(input())\\narr=list(map(int,input().split()))\\narr.reverse()\\nd={}\\nfor i in range(len(arr)):\\n    if arr[i]+1 in d.keys():\\n        d[arr[i]]=d[arr[i]+1]+1 \\n    else:\\n        d[arr[i]]=1 \\nmaxx=0\\nnumber=0\\nfor i in d.keys():\\n    if d[i]>maxx:\\n        maxx=d[i]\\n        number=i \\narr.reverse()\\ncurr=number\\nprint(maxx)\\nfor i in range(n):\\n    if arr[i]==curr:\\n        print(i+1,end=\\\" \\\")\\n        curr+=1\\n\", \"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(m.keys(), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nd = {}\\n\\nfor ai in a:\\n  d[ai] = d.get(ai - 1, 0) + 1\\n\\nmaxRange = 0\\nendVal = 0\\nfor key in d.keys():\\n  if (d[key] > maxRange):\\n    maxRange = d[key]\\n    endVal = key\\n\\nstartVal = endVal - maxRange + 1\\nprint(maxRange)\\nfor i, val in enumerate(a):\\n  if (val == startVal):\\n    print(i+1, end= ' ')\\n    startVal += 1\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\narr.reverse()\\ndic = {}\\n\\nfor i in range(n):\\n\\tdic[arr[i]] = dic[arr[i] + 1] + 1 if arr[i] + 1 in dic.keys() else 1\\nmx = 0\\nnum = 0\\n\\nfor i in dic.keys():\\n\\tif dic[i] > mx:\\n\\t\\tmx = dic[i]\\n\\t\\tnum = i \\nprint(mx)\\narr.reverse()\\nfor i in range(n):\\n\\tif arr[i] == num:\\n\\t\\tprint(i+1,end= ' ')\\n\\t\\tnum += 1\", \"n=int(input())\\na=list(map(int ,input().split() ) )\\nd={}\\nmaxn=0\\nmax_ind=0\\n\\nfor ai in a:\\n\\td[ai]=d.get(ai-1,0)+1\\n\\nfor key in d.keys():\\n\\tif(d[key] >maxn):\\n\\t  maxn=d[key]\\n\\t  max_ind=key\\n\\nstart= max_ind-maxn+1\\nprint(maxn)\\ni=0\\nfor ai in a:\\n\\ti+=1\\n\\tif(ai==start):\\n                 print(i,end=' ')\\n                 start+=1\\n                 \\n\\t\", \"n = int(input())\\nT = input().split(' ')\\nfor i in range(n):\\n    T[i] = int(T[i])\\nD = {}\\nfor i in range(n):\\n    D[T[i]] = 0\\nfor i in range(n):\\n    if T[i]-1 not in D:\\n        D[T[i]] = 1\\n    else:\\n        D[T[i]] = D[T[i]-1] + 1\\nm = -1\\nj = -1\\nfor i in D:\\n    if D[i] > m:\\n        m = D[i]\\n        j = i\\nL = []\\nfor i in range(n-1, -1, -1):\\n    if T[i] == j:\\n        L.append(i)\\n        j -= 1\\nprint(m)\\nfor i in range(m-1):\\n    print(L[m-1-i]+1, end=' ')\\nprint(L[0]+1)\\n\", \"n = int(input())\\nG = list(map(int,input().split()))\\nD = {}\\nM = 0\\nfor i in G:\\n    if i-1 in D:\\n        D[i] = D[i-1] + 1\\n    else:\\n        D[i] = 1\\n    if D[i]>M:\\n        M = D[i]\\n        Mi = i\\n#print(M,Mi)\\nR = []\\nA = Mi\\nfor i in range(len(G)-1,-1,-1):\\n    if G[i] == A:\\n        R.append(i+1)\\n        A-=1\\nprint(M)\\nprint(*R[::-1])\", \"input()\\na = list(map(int, input().split()))\\n\\nb = {i: 0 for i in set(a)}\\n\\nans = 0\\nans_ind = 0\\nfor i in range(len(a)):\\n    if a[i] - 1 in b.keys():\\n        b[a[i]] = b[a[i] - 1] + 1\\n    else:\\n        b[a[i]] = 1\\n    if (b[a[i]] > ans):\\n        ans = b[a[i]]\\n        ans_ind = i\\nprint(ans)\\ns = \\\"\\\"\\naans = []\\naans.append(ans_ind + 1)\\nx = a[ans_ind]\\nfor i in range(ans - 1):\\n    while (a[ans_ind] != x - 1):\\n        ans_ind -= 1\\n    x = a[ans_ind]\\n    aans.append(ans_ind + 1)\\nfor i in aans[::-1]:\\n    print(i, end=' ')\", \"from collections import Counter\\n\\n\\ndef read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef main():\\n    n, = read_nums()\\n    nums = read_nums()\\n    dp = Counter()\\n    for i in range(n):\\n        dp[nums[i]] = dp[nums[i] - 1] + 1\\n\\n    indexes = {}\\n    for i in range(n):\\n        indexes[nums[i]] = i\\n\\n    last_num = max(list(dp.items()), key=lambda x: x[1])[0]\\n\\n    result = []\\n    for i in range(n - 1, -1, -1):\\n        if nums[i] == last_num:\\n            result.append(i)\\n            last_num -= 1\\n\\n    result.reverse()\\n    print(len(result))\\n    print(' '.join([str(x + 1) for x in result]))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nG = list(map(int,input().split()))\\nD = {}\\nM = 0\\nfor i in G:\\n    if i-1 in D:\\n        D[i] = D[i-1] + 1\\n    else:\\n        D[i] = 1\\n    if D[i]>M:\\n        M = D[i]\\n        Mi = i\\n#print(M,Mi)\\nR = []\\nA = Mi\\nfor i in range(len(G)-1,-1,-1):\\n    if G[i] == A:\\n        R.append(i+1)\\n        A-=1\\nprint(M)\\nprint(*R[::-1])\", \"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(list(m.keys()), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = [-1 for _ in range(n)]\\n\\ndp = {}\\nbest = -1\\nbest2 = -1\\n\\nfor i, x in enumerate(a):\\n    p, q = dp.get(x, (1, i))\\n    r, t = dp.get(x - 1, (0, 0))\\n\\n    if r + 1 > p:\\n        p, q = r + 1, i\\n    else:\\n        t = i\\n\\n    dp[x] = (p, q)\\n    b[i] = t\\n\\n    if best < 0 or dp[best][0] < p:\\n        best = x\\n        best2 = i\\n\\nans = []\\nm = dp[best][0]\\n\\nfor _ in range(m):\\n    ans.append(best2)\\n    best2 = b[best2]\\n\\nans.reverse()\\n\\nprint(len(ans))\\nprint(' '.join([str(x + 1) for x in ans]))\\n\"]",
        "difficulty": "introductory",
        "input": "7\n100 3 4 7 5 6 8\n",
        "output": "4\n2 3 5 6 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/977/F"
    },
    {
        "id": 2425,
        "task_id": 4379,
        "test_case_id": 9,
        "question": "You are given an integer array of length $n$.\n\nYou have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to $[x, x + 1, \\dots, x + k - 1]$ for some value $x$ and length $k$.\n\nSubsequence of an array can be obtained by erasing some (possibly zero) elements from the array. You can erase any elements, not necessarily going successively. The remaining elements preserve their order. For example, for the array $[5, 3, 1, 2, 4]$ the following arrays are subsequences: $[3]$, $[5, 3, 1, 2, 4]$, $[5, 1, 4]$, but the array $[1, 3]$ is not.\n\n\n-----Input-----\n\nThe first line of the input containing integer number $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the length of the array. The second line of the input containing $n$ integer numbers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 10^9$) — the array itself.\n\n\n-----Output-----\n\nOn the first line print $k$ — the maximum length of the subsequence of the given array that forms an increasing sequence of consecutive integers.\n\nOn the second line print the sequence of the indices of the any maximum length subsequence of the given array that forms an increasing sequence of consecutive integers.\n\n\n-----Examples-----\nInput\n7\n3 3 4 7 5 6 8\n\nOutput\n4\n2 3 5 6 \n\nInput\n6\n1 3 5 2 4 6\n\nOutput\n2\n1 4 \n\nInput\n4\n10 9 8 7\n\nOutput\n1\n1 \n\nInput\n9\n6 7 8 3 4 5 9 10 11\n\nOutput\n6\n1 2 3 7 8 9 \n\n\n\n-----Note-----\n\nAll valid answers for the first example (as sequences of indices):   $[1, 3, 5, 6]$  $[2, 3, 5, 6]$ \n\nAll valid answers for the second example:   $[1, 4]$  $[2, 5]$  $[3, 6]$ \n\nAll valid answers for the third example:   $[1]$  $[2]$  $[3]$  $[4]$ \n\nAll valid answers for the fourth example:   $[1, 2, 3, 7, 8, 9]$",
        "solutions": "[\"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(list(m.keys()), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\\n\", \"n= int(input());\\na= list(map(int, input().split()));\\n#\\u0421\\u043b\\u043e\\u0432\\u0430\\u0440\\u044c: \\u043f\\u0430\\u0440\\u0430 \\u0447\\u0438\\u0441\\u043b\\u043e - \\u043c\\u0430\\u043a\\u0441\\u0438\\u043c\\u0430\\u043b\\u044c\\u043d\\u0430\\u044f \\u0434\\u043b\\u0438\\u043d\\u0430 \\u043f\\u043e\\u0441\\u043b\\u0435\\u0434\\u043e\\u0432\\u0430\\u0442\\u0435\\u043b\\u044c\\u043d\\u043e\\u0441\\u0442\\u0438, \\u043e\\u043a\\u0430\\u043d\\u0447\\u0438\\u0432\\u0430\\u044e\\u0449\\u0430\\u044f\\u0441\\u044f \\u0438\\u043c.\\nd= dict();\\nfor x in a:\\n    d[x]=d.get(x-1, 0)+1;\\nstart=0;\\nfinish=0;\\nresult=0;\\nfor key in d.keys():\\n    if d[key]>result:\\n        result=d[key];\\n        finish=key;\\n        start=key-d[key]+1;\\nprint(result);\\ncurr=start;\\nfor i, x in enumerate(a):\\n    if curr==x:\\n        print(i+1, end=' ');\\n        curr+=1;\\n    \\n\", \"n=int(input())\\na=list(map(int,input().split()))\\nh={}\\nfor i in a:\\n    h[i-1]=0\\n\\ntb=0\\nend=-1\\nfor i in a:\\n    h[i]=h[i-1]+1\\n    if tb<h[i]:\\n        tb=h[i]\\n        end=i\\narr=[]\\nstart=end-tb+1\\nfor i in range(n):\\n    if a[i]==start:\\n        arr.append(i+1)\\n        start+=1\\n\\nprint(tb)\\nprint(*arr)\\n\", \"n = int(input())\\ns = list(map(int,input().split()))\\nrl = {}\\nbest_range = range(0)\\nfor x in s:\\n    run = rl[x] = rl.get(x-1, 0) + 1\\n    r = range(x-run+1, x+1)\\n    if len(r) > len(best_range):\\n        best_range = r\\nres = list(best_range)\\nsize = len(res)\\noutput = []\\npointer = 0\\nfor i,c in enumerate(s):\\n    if res[pointer] == c:\\n        output.append(str(i+1))\\n        pointer += 1\\n    \\n    if pointer >= size:break\\nprint (size)\\nprint (' '.join(output))\", \"n = int(input())\\na = input().split()\\nfor i, x in enumerate(a):\\n    a[i] = int(x)\\n\\nd = [float('inf')]*(n + 1)\\nd[0] = 0\\nlength = 0\\nvalue = 0\\ns = dict()\\nfor i in range(0, n):\\n    if a[i] - 1 in s:\\n        if a[i] is s:\\n            s[a[i]] = max(s[a[i]], s[a[i - 1]] + 1)\\n        else:\\n            s[a[i]] = s[a[i] - 1] + 1\\n    else:\\n        s[a[i]] = 1\\n    if s[a[i]] > length:\\n         length = s[a[i]]\\n         value = a[i]  \\nans = []\\nvalue0 = value - length + 1\\nfor i, x in enumerate(a):\\n    if x == value0:\\n        ans.append(i + 1)\\n        value0 = value0 + 1\\n        if value0 > value:\\n            break \\n        \\nprint(length)\\nprint(' '.join(str(i) for i in ans))\\n\\n    \\n\\n\", \"from collections import defaultdict\\n\\nn = int(input())\\nA = list(map(int, input().split()))\\nlast = defaultdict(int)\\nD = {0: (0, 0)}\\nbest = (0, 0)\\nfor i, a in enumerate(A, start=1):\\n    last[a] = i\\n    last_a1 = last[a - 1]\\n    best_a1, _ = D[last_a1]\\n    D[i] = (1 + best_a1, last_a1)\\n    best = max(best, (1 + best_a1, i))\\n\\nprint(best[0])\\nrsseq = []\\ni = best[1]\\nwhile i != 0:\\n    rsseq.append(i)\\n    i = D[i][1]\\nprint(' '.join(map(str, reversed(rsseq))))\\n\", \"n = int(input())\\na = list(map(int, input().split()))\\nd = dict()\\nopt = []\\nm = -1\\nfor i in range(n):\\n    t = a[i]\\n    p = t - 1\\n    if p in d:\\n        if (t not in d) or ((p - d[p]) >= (t - d[t])):\\n            d[t] = d[p]\\n            #d.pop(p)\\n            k = t - d[t]\\n            if k > m:\\n                m = k\\n                opt = d[t]\\n    else:\\n        if t not in d:\\n            d[t] = t\\n            if m == -1:\\n                opt = t\\n                m = 0\\nprint(m+1)\\nr = []\\nfor i in range(n):\\n    if a[i] == opt:\\n        r += [i+1]\\n        opt += 1\\nprint(*r)\", \"N = int(input())\\nD = {}\\nL = list(map(int,input().split()))[::-1]\\nfor i in L:\\n\\tD[i] = max(D.get(i,0),D.get(i+1,0)+1)\\nM = max([(i[1],-i[0]) for i in D.items()])\\nL.reverse()\\nprint(M[0])\\nM = -M[1]\\nfor i in range(N):\\n\\tif L[i]==M:\\n\\t\\tprint(i+1,end=' ')\\n\\t\\tM += 1\", \"n = int(input())\\na = [int(s) for s in input().split()]\\nlens = {}\\nmaxlen = 1\\nmaxlast = a[0]\\nfor i in range(n):\\n    lens[a[i]] = lens.get(a[i]-1, 0) + 1\\n    if lens[a[i]] > maxlen:\\n        maxlen = lens[a[i]]\\n        maxlast = a[i]\\n# print(lens)\\n# print(maxlast, maxlen)\\nprint(maxlen)\\nsubs = []\\nsi = maxlast - maxlen + 1\\nfor i in range(n):\\n    if a[i] == si:\\n        subs.append(i+1)\\n        si += 1\\nprint(*subs, sep=' ')\", \"n=int(input())\\nd=dict()\\nm=0\\nval=0\\na=list(map(int,input().split()))\\ns=set()\\naps=s.add\\nfor i in a:\\n    d[i]=d.get(i-1,0)+1\\n    if d[i]>m:\\n        m=d[i]\\n        val=int(i)\\n\\nans=[]\\nap=ans.append\\nfor i in range(n-1,-1,-1):\\n    if a[i]==val:\\n        val-=1\\n        ap(i+1)\\nprint(m)\\nprint(*ans[::-1])\", \"n= int(input());\\na= list(map(int, input().split()));\\nd= dict();\\nfor x in a:\\n    d[x]=d.get(x-1, 0)+1;\\nstart=0;\\nfinish=0;\\nresult=0;\\nfor key in d.keys():\\n    if d[key]>result:\\n        result=d[key];\\n        finish=key;\\n        start=key-d[key]+1;\\nprint(result);\\ncurr=start;\\nfor i, x in enumerate(a):\\n    if curr==x:\\n        print(i+1, end=' ');\\n        curr+=1;\", \"n=int(input())\\narr=list(map(int,input().split()))\\narr.reverse()\\nd={}\\nfor i in range(len(arr)):\\n    if arr[i]+1 in d.keys():\\n        d[arr[i]]=d[arr[i]+1]+1 \\n    else:\\n        d[arr[i]]=1 \\nmaxx=0\\nnumber=0\\nfor i in d.keys():\\n    if d[i]>maxx:\\n        maxx=d[i]\\n        number=i \\narr.reverse()\\ncurr=number\\nprint(maxx)\\nfor i in range(n):\\n    if arr[i]==curr:\\n        print(i+1,end=\\\" \\\")\\n        curr+=1\\n\", \"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(m.keys(), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\", \"n = int(input())\\na = list(map(int, input().split()))\\n\\nd = {}\\n\\nfor ai in a:\\n  d[ai] = d.get(ai - 1, 0) + 1\\n\\nmaxRange = 0\\nendVal = 0\\nfor key in d.keys():\\n  if (d[key] > maxRange):\\n    maxRange = d[key]\\n    endVal = key\\n\\nstartVal = endVal - maxRange + 1\\nprint(maxRange)\\nfor i, val in enumerate(a):\\n  if (val == startVal):\\n    print(i+1, end= ' ')\\n    startVal += 1\\n\", \"n = int(input())\\narr = list(map(int, input().split()))\\narr.reverse()\\ndic = {}\\n\\nfor i in range(n):\\n\\tdic[arr[i]] = dic[arr[i] + 1] + 1 if arr[i] + 1 in dic.keys() else 1\\nmx = 0\\nnum = 0\\n\\nfor i in dic.keys():\\n\\tif dic[i] > mx:\\n\\t\\tmx = dic[i]\\n\\t\\tnum = i \\nprint(mx)\\narr.reverse()\\nfor i in range(n):\\n\\tif arr[i] == num:\\n\\t\\tprint(i+1,end= ' ')\\n\\t\\tnum += 1\", \"n=int(input())\\na=list(map(int ,input().split() ) )\\nd={}\\nmaxn=0\\nmax_ind=0\\n\\nfor ai in a:\\n\\td[ai]=d.get(ai-1,0)+1\\n\\nfor key in d.keys():\\n\\tif(d[key] >maxn):\\n\\t  maxn=d[key]\\n\\t  max_ind=key\\n\\nstart= max_ind-maxn+1\\nprint(maxn)\\ni=0\\nfor ai in a:\\n\\ti+=1\\n\\tif(ai==start):\\n                 print(i,end=' ')\\n                 start+=1\\n                 \\n\\t\", \"n = int(input())\\nT = input().split(' ')\\nfor i in range(n):\\n    T[i] = int(T[i])\\nD = {}\\nfor i in range(n):\\n    D[T[i]] = 0\\nfor i in range(n):\\n    if T[i]-1 not in D:\\n        D[T[i]] = 1\\n    else:\\n        D[T[i]] = D[T[i]-1] + 1\\nm = -1\\nj = -1\\nfor i in D:\\n    if D[i] > m:\\n        m = D[i]\\n        j = i\\nL = []\\nfor i in range(n-1, -1, -1):\\n    if T[i] == j:\\n        L.append(i)\\n        j -= 1\\nprint(m)\\nfor i in range(m-1):\\n    print(L[m-1-i]+1, end=' ')\\nprint(L[0]+1)\\n\", \"n = int(input())\\nG = list(map(int,input().split()))\\nD = {}\\nM = 0\\nfor i in G:\\n    if i-1 in D:\\n        D[i] = D[i-1] + 1\\n    else:\\n        D[i] = 1\\n    if D[i]>M:\\n        M = D[i]\\n        Mi = i\\n#print(M,Mi)\\nR = []\\nA = Mi\\nfor i in range(len(G)-1,-1,-1):\\n    if G[i] == A:\\n        R.append(i+1)\\n        A-=1\\nprint(M)\\nprint(*R[::-1])\", \"input()\\na = list(map(int, input().split()))\\n\\nb = {i: 0 for i in set(a)}\\n\\nans = 0\\nans_ind = 0\\nfor i in range(len(a)):\\n    if a[i] - 1 in b.keys():\\n        b[a[i]] = b[a[i] - 1] + 1\\n    else:\\n        b[a[i]] = 1\\n    if (b[a[i]] > ans):\\n        ans = b[a[i]]\\n        ans_ind = i\\nprint(ans)\\ns = \\\"\\\"\\naans = []\\naans.append(ans_ind + 1)\\nx = a[ans_ind]\\nfor i in range(ans - 1):\\n    while (a[ans_ind] != x - 1):\\n        ans_ind -= 1\\n    x = a[ans_ind]\\n    aans.append(ans_ind + 1)\\nfor i in aans[::-1]:\\n    print(i, end=' ')\", \"from collections import Counter\\n\\n\\ndef read_nums():\\n    return [int(x) for x in input().split()]\\n\\n\\ndef main():\\n    n, = read_nums()\\n    nums = read_nums()\\n    dp = Counter()\\n    for i in range(n):\\n        dp[nums[i]] = dp[nums[i] - 1] + 1\\n\\n    indexes = {}\\n    for i in range(n):\\n        indexes[nums[i]] = i\\n\\n    last_num = max(list(dp.items()), key=lambda x: x[1])[0]\\n\\n    result = []\\n    for i in range(n - 1, -1, -1):\\n        if nums[i] == last_num:\\n            result.append(i)\\n            last_num -= 1\\n\\n    result.reverse()\\n    print(len(result))\\n    print(' '.join([str(x + 1) for x in result]))\\n\\n\\ndef __starting_point():\\n    main()\\n\\n__starting_point()\", \"n = int(input())\\nG = list(map(int,input().split()))\\nD = {}\\nM = 0\\nfor i in G:\\n    if i-1 in D:\\n        D[i] = D[i-1] + 1\\n    else:\\n        D[i] = 1\\n    if D[i]>M:\\n        M = D[i]\\n        Mi = i\\n#print(M,Mi)\\nR = []\\nA = Mi\\nfor i in range(len(G)-1,-1,-1):\\n    if G[i] == A:\\n        R.append(i+1)\\n        A-=1\\nprint(M)\\nprint(*R[::-1])\", \"from collections import *\\ninput()\\na = list(map(int, input().split()))\\nm = defaultdict(int)\\nfor x in reversed(a): m[x] = m[x + 1] + 1\\nv = max(list(m.keys()), key=m.get)\\nseq = []\\nfor i, x in enumerate(a):\\n    if v == x:\\n        seq.append(i + 1)\\n        v += 1\\nprint(len(seq))\\nprint(*seq)\\n\", \"n = int(input())\\na = [int(x) for x in input().split()]\\nb = [-1 for _ in range(n)]\\n\\ndp = {}\\nbest = -1\\nbest2 = -1\\n\\nfor i, x in enumerate(a):\\n    p, q = dp.get(x, (1, i))\\n    r, t = dp.get(x - 1, (0, 0))\\n\\n    if r + 1 > p:\\n        p, q = r + 1, i\\n    else:\\n        t = i\\n\\n    dp[x] = (p, q)\\n    b[i] = t\\n\\n    if best < 0 or dp[best][0] < p:\\n        best = x\\n        best2 = i\\n\\nans = []\\nm = dp[best][0]\\n\\nfor _ in range(m):\\n    ans.append(best2)\\n    best2 = b[best2]\\n\\nans.reverse()\\n\\nprint(len(ans))\\nprint(' '.join([str(x + 1) for x in ans]))\\n\"]",
        "difficulty": "introductory",
        "input": "12\n1 2 3 4 5 6 7 8 9 10 11 12\n",
        "output": "12\n1 2 3 4 5 6 7 8 9 10 11 12 \n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/977/F"
    },
    {
        "id": 2426,
        "task_id": 4421,
        "test_case_id": 1,
        "question": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by $k$. In other words, two boxes $i$ and $j$ ($i \\ne j$) can be combined as a gift if $d_i + d_j$ is divisible by $k$.\n\nHow many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes \"partially\" or redistribute candies between them. \n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le n \\le 2 \\cdot 10^5, 1 \\le k \\le 100$) — the number the boxes and the number the girls.\n\nThe second line of the input contains $n$ integers $d_1, d_2, \\dots, d_n$ ($1 \\le d_i \\le 10^9$), where $d_i$ is the number of candies in the $i$-th box.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of the boxes Polycarp can give as gifts.\n\n\n-----Examples-----\nInput\n7 2\n1 2 2 3 2 4 10\n\nOutput\n6\n\nInput\n8 2\n1 2 2 3 2 4 6 10\n\nOutput\n8\n\nInput\n7 3\n1 2 2 3 2 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(2, 3)$;  $(5, 6)$;  $(1, 4)$. \n\nSo the answer is $6$.\n\nIn the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(6, 8)$;  $(2, 3)$;  $(1, 4)$;  $(5, 7)$. \n\nSo the answer is $8$.\n\nIn the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(1, 2)$;  $(6, 7)$. \n\nSo the answer is $4$.",
        "solutions": "[\"n, k = map(int, input().split())\\nD = list(map(int, input().split()))\\nz = {i: 0 for i in range(k)}\\nfor i in range(n):\\n    z[D[i] % k] += 1\\ncnt = z[0] // 2\\nfor q in range(1, k // 2 + k % 2):\\n    cnt += min(z[q], z[k - q])\\nif k % 2 == 0:\\n    cnt += z[k // 2] // 2\\nprint(cnt * 2)\", \"n, k = map(int, input().split())\\nd = list(map(int, input().split()))\\n\\ncount = [0] * k\\nfor x in d:\\n    count[x%k] += 1\\n\\nresult = count[0]//2\\nfor i in range(1, k):\\n    if i*2 >= k:\\n        break\\n    result += min(count[i], count[k-i])\\n\\nif k%2==0:\\n    result += count[k//2]//2\\nprint(result*2)\", \"n, k = list(map(int, input().split()))\\ncounts = [0] * k\\nfor i in map(int, input().split()):\\n    counts[i % k] += 1\\n\\nc = counts[0] // 2\\nfor i in range(1, k):\\n    if 2 * i >= k:\\n        break\\n    c += min(counts[i], counts[k - i])\\nif k % 2 == 0:\\n    c += counts[k // 2] // 2\\n\\nprint(2 * c)\\n\", \"def main():\\n    n, k = list(map(int, input().split()))\\n    cnt = [0] * k\\n    ans = 0\\n    arr = list(map(int, input().split()))\\n    for el in arr:\\n        t = el % k\\n        if (cnt[(k - t) % k] > 0):\\n            cnt[(k - t) % k] -= 1\\n            ans += 2\\n        else:\\n            cnt[t] += 1\\n    print(ans)\\n \\n \\nmain()\\n\", \"n, k = list(map(int, input().split()))\\n\\nans = [0] * k\\n\\na = list(map(int, input().split()))\\n\\nfor c in a:\\n\\tans[c % k] += 1\\nkol = ans[0] - ans[0] % 2\\nfor i in range(1, int(k / 2 + 0.5)):\\n\\tkol += min(ans[i], ans[k - i]) * 2\\n\\t#print(ans[i], ans[k - i], i)\\n\\nif k % 2 == 0:\\n\\tkol += ans[k // 2] - ans[k // 2] % 2\\n#print(ans)\\nprint(kol)\\n\", \"n, k = list(map(int,input().split()))\\ndi = list(map(int,input().split()))\\nai  = [0] * k\\nfor i in di:\\n    ai[i % k] += 1\\nans = ai[0] // 2\\nai[0] = 0\\nfor i in range(1,k):\\n    num = i\\n    num2 = k - i\\n    if num != num2:\\n        ans += min(ai[num], ai[num2])\\n    else:\\n        ans += ai[num] // 2\\n    ai[num] = 0\\n    ai[num2] = 0\\nprint(ans * 2)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\ndi = dict()\\nfor i in range(n):\\n    if d[i] % k in di:\\n        di[d[i] % k] += 1\\n    else:\\n        di[d[i] % k] = 1\\nans = 0\\nif 0 in di:\\n    ans = di[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i in di and k - i in di:\\n        if i == k - i:\\n            ans += di[i] // 2\\n        else:\\n            ans += min(di[i], di[k - i])\\nprint(ans * 2)\\n\", \"n,k = [int(x) for x in input().split()]\\n\\nL = [int(x) for x in input().split()]\\n\\nD = [0]*k\\n\\nfor i in L:\\n    D[i%k] += 1\\n    \\ns = 0    \\nfor i in range((k+2)//2):\\n    if i == 0:\\n        s += 2*(D[0]//2)\\n    elif (k%2 == 0) and (i == k//2):\\n        s += 2*(D[i]//2)\\n    else:\\n        s += 2*min(D[i],D[k-i])\\n    \\nprint(s)\", \"n,k=map(int,input().split())\\nd=[*map(int,input().split())]\\ncnt=[0]*k\\nfor i in d:\\n    cnt[i%k]+=1\\nans=cnt[0]//2\\nfor i in range(1,k):\\n    req=k-i\\n    if i<req:\\n        ans+=min(cnt[i],cnt[req])\\n    elif i==req:\\n        ans+=cnt[i]//2\\nprint(ans*2)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nd = [0] * k\\nfor i in range(n):\\n    d[a[i] % k] += 1\\n\\nnum = 0\\nfor i in range(k):\\n    if k - i < i:\\n        break\\n    if i == 0:\\n        num += d[i] // 2\\n    elif i == k - i:\\n        num += d[i] // 2\\n    else:\\n        num += min(d[i], d[k - i])\\n\\nprint(num * 2)\\n\", \"from collections import Counter as C\\nn, k = map(int, input().split())\\nl = [int(x) % k for x in input().split()]\\nc = C(l)\\nres = 0\\nfor i in range(k):\\n    j = -i % k\\n    vi, vj = c.get(i, 0), c.get(j, 0)\\n    if i == j:\\n        res += vi // 2\\n    else:\\n        res += min(vi, vj)\\n    c[i] = 0\\nprint(res * 2)\", \"n, K = map(int, input().split())\\narr = map(int, input().split())\\nfreq = [0 for _ in range(K)]\\nfor x in arr:\\n    freq[x%K] += 1\\nans = 2*(freq[0]//2)\\nfor i in range(1, K):\\n    if i < K-i:\\n        ans += 2*(min(freq[i], freq[K-i]))\\n    elif i == K-i:\\n        ans += 2*(freq[i]//2)\\nprint(ans)\", \"n,k = list(map(int,input().split()))\\nl   = list(map(int,input().split()))\\n\\nd = {}\\n\\nfor i in range(k):\\n    d[i] = 0\\n\\nfor i in range(len(l)):\\n    l[i] = l[i]%k\\n    d[l[i]] += 1 \\n\\ns = 0\\n\\ns += d[0]//2\\n\\nfor i in range(1,k//2):\\n    s += min(d[i],d[k-i])\\n\\nif k % 2 == 0:\\n    s += d[k//2] // 2\\nelse:\\n    if k != 1:\\n        s += min(d[k//2],d[k-k//2])\\n        \\nprint(s*2)\\n\", \"n,k=list(map(int,input().split()))\\nD=list(map(int,input().split()))\\n\\nD2=[d%k for d in D]\\n\\nfrom collections import Counter\\nc=Counter(D2)\\n\\nANS=c[0]//2*2\\nif k%2==0:\\n    ANS+=c[k//2]//2*2\\nfor i in range(1,-(-k//2)):\\n    ANS+=min(c[i],c[k-i])*2\\n\\nprint(ANS)\\n    \\n\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/3/7 23:13\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B. Preparation for International Women's Day.py\\n\\nfrom collections import Counter\\n\\n\\ndef main():\\n    n, k = map(int, input().split())\\n    d = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    for x in d:\\n        counter[x % k] += 1\\n\\n    ret = counter[0] // 2 * 2\\n    for i in range(1, k):\\n        if i != k - i:\\n            ret += min(counter[i], counter[k - i])\\n        else:\\n            ret += counter[i] // 2 * 2\\n    print(ret)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\ndivs = {}\\nhandled = [False, ] * k\\n\\nfor x in a:\\n    divs[x % k] = divs.get(x % k, 0) + 1\\n\\nresult = divs.get(0, 0) - divs.get(0, 0) % 2\\n\\nfor i in range(1, k):\\n    if not handled[i] and not handled[k - i]:\\n        if i != k - i:\\n            result += 2 * min(divs.get(i, 0), divs.get(k - i, 0))\\n        else:\\n            result += divs.get(i, 0) - divs.get(i, 0) % 2\\n        handled[i] = handled[k - i] = True\\n\\nprint(result)\\n\", \"#map(int,input().split())\\n#int(input())\\nn,k=map(int,input().split())\\na=list(map(int,input().split()))\\nd = dict()\\nfor i in range(n):\\n    m=a[i]%k\\n    if m not in d:\\n       d[m]=1\\n    else:\\n        d[m]+=1\\nans=0\\nif 0 in d:\\n   ans = d[0]//2\\nh=k//2\\nif k%2==0 and h in d:\\n    ans  += d[h]//2\\nfor i in range(1,(k+1)//2):\\n    if i in d and k-i in d:\\n       ans += min(d[i],d[k-i])\\nprint(ans*2)\", \"from math import floor\\nfrom collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = defaultdict(int)\\nfor i in input().split():\\n    i = int(i) % k\\n    a[i] += 1\\nr = 0\\nfor i in range(floor(k / 2) + 1):\\n    if i == 0 or i == k - i:\\n        r += a[i] // 2\\n    else:\\n        r += min(a[i], a[k - i])\\nprint(r * 2)\", \"n,k=tuple(map(int,input().strip().split(\\\" \\\")))\\nnumbers=tuple(map(int,input().strip().split(\\\" \\\")))\\nl=[]\\nfor i in range(k):\\n    l.append(0)\\nfor i in numbers:\\n    l[i%k]+=1\\ns=(l[0]//2)*2\\nimport math\\nfor g in range(1,math.ceil(k/2)):\\n    s=s+(min(l[g],l[k-g])*2)\\nif(k%2==0):\\n    s=s+((l[k//2]//2)*2)\\nprint(s)\", \"def main():\\n    n,k = list(map(int,input().split()))\\n    candy = list(map(int,input().split()))\\n    candies = []\\n    zeroes = 0\\n    for i in candy:\\n        mod = i%k\\n        if mod == 0:\\n            zeroes += 1\\n        else:\\n            candies.append(mod)\\n\\n    candies.sort()\\n\\n    boxes = zeroes//2\\n\\n    candy_dict = {}\\n\\n    for i in candies:\\n        if i not in list(candy_dict.keys()):\\n            candy_dict[i] = 1\\n        else:\\n            candy_dict[i] += 1\\n\\n    #print (candy_dict)\\n    for i in candy_dict:\\n        if candy_dict[i] > 0:\\n            if (k-i) in list(candy_dict.keys()):\\n                if candy_dict[k-i] > 0:\\n                    if i == (k-i):\\n                        box = candy_dict[i]//2\\n                        candy_dict[i] = candy_dict[i]%2\\n                    else:\\n                        box = min(candy_dict[i],candy_dict[k-i])\\n                        candy_dict[i] -= box\\n                        candy_dict[k-i] -= box\\n                    boxes += box\\n\\n    print(2*boxes)\\n    \\n\\nmain()\\n\", \"n,k=list(map(int,input().split()))\\na=[int(x)%k for x in input().split()]\\nf={}\\nan=0\\nfor i in a:\\n    if -i in f and f[-i]>0:\\n        an+=2\\n        f[-i]-=1\\n    elif k-i in f and f[k-i]>0:\\n        an+=2\\n        f[k-i]-=1\\n    else:\\n        if i not in f:f[i]=0\\n        f[i]+=1\\nprint(an)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\nost = [0] * k\\nfor i in range(n):\\n    ost[d[i] % k] += 1\\nans = ost[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i != k - i:\\n        ans += min(ost[i], ost[k - i])\\n    else:\\n        ans += ost[i] // 2\\nprint(ans * 2)\\n\", \"n, k = map(int, input().split())\\ncandies = list(map(int, input().split()))\\n\\ndiv = [0 for i in range(k)]\\n\\nfor i in candies:\\n    div[i % k] += 1\\n\\n\\nres = (div[0] // 2)*2\\nif k % 2 == 1:\\n    c = k//2 +1\\nelse:\\n    c = k//2 + 1\\nfor i in range(1, c):\\n    res += 2 * min(div[i], div[k - i]) if i != k - i else (div[i] // 2)*2\\nprint(res)\", \"n,k = list(map(int,input().split()))\\nnum = list(map(int,input().split()))\\ngay = []\\nfor i in num:\\n\\tgay.append(i%k)\\nnumber = [0] * 101\\nfor i in gay:\\n\\tnumber[i] += 1\\n#print(number)\\ni = 0\\nchuj = 1\\nwynik = 0\\nwhile i<k:\\n\\tif i == (k-i)%k:\\n\\t\\tif number[i] > 1:\\n\\t\\t\\tnumber[i] -= 2\\n\\t\\t\\twynik += 1\\n\\t\\telse:\\n\\t\\t\\tnumber[i] = 0\\n\\t\\t\\ti += 1\\n\\telse:\\n\\t\\tif number[i] > 0:\\n\\t\\t\\tif number[(k-i)%k]>0:\\n\\t\\t\\t\\tnumber[i] -= 1\\n\\t\\t\\t\\tnumber[(k-i)%k] -= 1\\n\\t\\t\\t\\twynik += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tnumber[i] = 0\\n\\t\\tif number[i] == 0:\\n\\t\\t\\ti += 1\\nprint(2*wynik)\"]",
        "difficulty": "introductory",
        "input": "7 2\n1 2 2 3 2 4 10\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1133/B"
    },
    {
        "id": 2427,
        "task_id": 4421,
        "test_case_id": 2,
        "question": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by $k$. In other words, two boxes $i$ and $j$ ($i \\ne j$) can be combined as a gift if $d_i + d_j$ is divisible by $k$.\n\nHow many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes \"partially\" or redistribute candies between them. \n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le n \\le 2 \\cdot 10^5, 1 \\le k \\le 100$) — the number the boxes and the number the girls.\n\nThe second line of the input contains $n$ integers $d_1, d_2, \\dots, d_n$ ($1 \\le d_i \\le 10^9$), where $d_i$ is the number of candies in the $i$-th box.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of the boxes Polycarp can give as gifts.\n\n\n-----Examples-----\nInput\n7 2\n1 2 2 3 2 4 10\n\nOutput\n6\n\nInput\n8 2\n1 2 2 3 2 4 6 10\n\nOutput\n8\n\nInput\n7 3\n1 2 2 3 2 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(2, 3)$;  $(5, 6)$;  $(1, 4)$. \n\nSo the answer is $6$.\n\nIn the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(6, 8)$;  $(2, 3)$;  $(1, 4)$;  $(5, 7)$. \n\nSo the answer is $8$.\n\nIn the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(1, 2)$;  $(6, 7)$. \n\nSo the answer is $4$.",
        "solutions": "[\"n, k = map(int, input().split())\\nD = list(map(int, input().split()))\\nz = {i: 0 for i in range(k)}\\nfor i in range(n):\\n    z[D[i] % k] += 1\\ncnt = z[0] // 2\\nfor q in range(1, k // 2 + k % 2):\\n    cnt += min(z[q], z[k - q])\\nif k % 2 == 0:\\n    cnt += z[k // 2] // 2\\nprint(cnt * 2)\", \"n, k = map(int, input().split())\\nd = list(map(int, input().split()))\\n\\ncount = [0] * k\\nfor x in d:\\n    count[x%k] += 1\\n\\nresult = count[0]//2\\nfor i in range(1, k):\\n    if i*2 >= k:\\n        break\\n    result += min(count[i], count[k-i])\\n\\nif k%2==0:\\n    result += count[k//2]//2\\nprint(result*2)\", \"n, k = list(map(int, input().split()))\\ncounts = [0] * k\\nfor i in map(int, input().split()):\\n    counts[i % k] += 1\\n\\nc = counts[0] // 2\\nfor i in range(1, k):\\n    if 2 * i >= k:\\n        break\\n    c += min(counts[i], counts[k - i])\\nif k % 2 == 0:\\n    c += counts[k // 2] // 2\\n\\nprint(2 * c)\\n\", \"def main():\\n    n, k = list(map(int, input().split()))\\n    cnt = [0] * k\\n    ans = 0\\n    arr = list(map(int, input().split()))\\n    for el in arr:\\n        t = el % k\\n        if (cnt[(k - t) % k] > 0):\\n            cnt[(k - t) % k] -= 1\\n            ans += 2\\n        else:\\n            cnt[t] += 1\\n    print(ans)\\n \\n \\nmain()\\n\", \"n, k = list(map(int, input().split()))\\n\\nans = [0] * k\\n\\na = list(map(int, input().split()))\\n\\nfor c in a:\\n\\tans[c % k] += 1\\nkol = ans[0] - ans[0] % 2\\nfor i in range(1, int(k / 2 + 0.5)):\\n\\tkol += min(ans[i], ans[k - i]) * 2\\n\\t#print(ans[i], ans[k - i], i)\\n\\nif k % 2 == 0:\\n\\tkol += ans[k // 2] - ans[k // 2] % 2\\n#print(ans)\\nprint(kol)\\n\", \"n, k = list(map(int,input().split()))\\ndi = list(map(int,input().split()))\\nai  = [0] * k\\nfor i in di:\\n    ai[i % k] += 1\\nans = ai[0] // 2\\nai[0] = 0\\nfor i in range(1,k):\\n    num = i\\n    num2 = k - i\\n    if num != num2:\\n        ans += min(ai[num], ai[num2])\\n    else:\\n        ans += ai[num] // 2\\n    ai[num] = 0\\n    ai[num2] = 0\\nprint(ans * 2)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\ndi = dict()\\nfor i in range(n):\\n    if d[i] % k in di:\\n        di[d[i] % k] += 1\\n    else:\\n        di[d[i] % k] = 1\\nans = 0\\nif 0 in di:\\n    ans = di[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i in di and k - i in di:\\n        if i == k - i:\\n            ans += di[i] // 2\\n        else:\\n            ans += min(di[i], di[k - i])\\nprint(ans * 2)\\n\", \"n,k = [int(x) for x in input().split()]\\n\\nL = [int(x) for x in input().split()]\\n\\nD = [0]*k\\n\\nfor i in L:\\n    D[i%k] += 1\\n    \\ns = 0    \\nfor i in range((k+2)//2):\\n    if i == 0:\\n        s += 2*(D[0]//2)\\n    elif (k%2 == 0) and (i == k//2):\\n        s += 2*(D[i]//2)\\n    else:\\n        s += 2*min(D[i],D[k-i])\\n    \\nprint(s)\", \"n,k=map(int,input().split())\\nd=[*map(int,input().split())]\\ncnt=[0]*k\\nfor i in d:\\n    cnt[i%k]+=1\\nans=cnt[0]//2\\nfor i in range(1,k):\\n    req=k-i\\n    if i<req:\\n        ans+=min(cnt[i],cnt[req])\\n    elif i==req:\\n        ans+=cnt[i]//2\\nprint(ans*2)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nd = [0] * k\\nfor i in range(n):\\n    d[a[i] % k] += 1\\n\\nnum = 0\\nfor i in range(k):\\n    if k - i < i:\\n        break\\n    if i == 0:\\n        num += d[i] // 2\\n    elif i == k - i:\\n        num += d[i] // 2\\n    else:\\n        num += min(d[i], d[k - i])\\n\\nprint(num * 2)\\n\", \"from collections import Counter as C\\nn, k = map(int, input().split())\\nl = [int(x) % k for x in input().split()]\\nc = C(l)\\nres = 0\\nfor i in range(k):\\n    j = -i % k\\n    vi, vj = c.get(i, 0), c.get(j, 0)\\n    if i == j:\\n        res += vi // 2\\n    else:\\n        res += min(vi, vj)\\n    c[i] = 0\\nprint(res * 2)\", \"n, K = map(int, input().split())\\narr = map(int, input().split())\\nfreq = [0 for _ in range(K)]\\nfor x in arr:\\n    freq[x%K] += 1\\nans = 2*(freq[0]//2)\\nfor i in range(1, K):\\n    if i < K-i:\\n        ans += 2*(min(freq[i], freq[K-i]))\\n    elif i == K-i:\\n        ans += 2*(freq[i]//2)\\nprint(ans)\", \"n,k = list(map(int,input().split()))\\nl   = list(map(int,input().split()))\\n\\nd = {}\\n\\nfor i in range(k):\\n    d[i] = 0\\n\\nfor i in range(len(l)):\\n    l[i] = l[i]%k\\n    d[l[i]] += 1 \\n\\ns = 0\\n\\ns += d[0]//2\\n\\nfor i in range(1,k//2):\\n    s += min(d[i],d[k-i])\\n\\nif k % 2 == 0:\\n    s += d[k//2] // 2\\nelse:\\n    if k != 1:\\n        s += min(d[k//2],d[k-k//2])\\n        \\nprint(s*2)\\n\", \"n,k=list(map(int,input().split()))\\nD=list(map(int,input().split()))\\n\\nD2=[d%k for d in D]\\n\\nfrom collections import Counter\\nc=Counter(D2)\\n\\nANS=c[0]//2*2\\nif k%2==0:\\n    ANS+=c[k//2]//2*2\\nfor i in range(1,-(-k//2)):\\n    ANS+=min(c[i],c[k-i])*2\\n\\nprint(ANS)\\n    \\n\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/3/7 23:13\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B. Preparation for International Women's Day.py\\n\\nfrom collections import Counter\\n\\n\\ndef main():\\n    n, k = map(int, input().split())\\n    d = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    for x in d:\\n        counter[x % k] += 1\\n\\n    ret = counter[0] // 2 * 2\\n    for i in range(1, k):\\n        if i != k - i:\\n            ret += min(counter[i], counter[k - i])\\n        else:\\n            ret += counter[i] // 2 * 2\\n    print(ret)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\ndivs = {}\\nhandled = [False, ] * k\\n\\nfor x in a:\\n    divs[x % k] = divs.get(x % k, 0) + 1\\n\\nresult = divs.get(0, 0) - divs.get(0, 0) % 2\\n\\nfor i in range(1, k):\\n    if not handled[i] and not handled[k - i]:\\n        if i != k - i:\\n            result += 2 * min(divs.get(i, 0), divs.get(k - i, 0))\\n        else:\\n            result += divs.get(i, 0) - divs.get(i, 0) % 2\\n        handled[i] = handled[k - i] = True\\n\\nprint(result)\\n\", \"#map(int,input().split())\\n#int(input())\\nn,k=map(int,input().split())\\na=list(map(int,input().split()))\\nd = dict()\\nfor i in range(n):\\n    m=a[i]%k\\n    if m not in d:\\n       d[m]=1\\n    else:\\n        d[m]+=1\\nans=0\\nif 0 in d:\\n   ans = d[0]//2\\nh=k//2\\nif k%2==0 and h in d:\\n    ans  += d[h]//2\\nfor i in range(1,(k+1)//2):\\n    if i in d and k-i in d:\\n       ans += min(d[i],d[k-i])\\nprint(ans*2)\", \"from math import floor\\nfrom collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = defaultdict(int)\\nfor i in input().split():\\n    i = int(i) % k\\n    a[i] += 1\\nr = 0\\nfor i in range(floor(k / 2) + 1):\\n    if i == 0 or i == k - i:\\n        r += a[i] // 2\\n    else:\\n        r += min(a[i], a[k - i])\\nprint(r * 2)\", \"n,k=tuple(map(int,input().strip().split(\\\" \\\")))\\nnumbers=tuple(map(int,input().strip().split(\\\" \\\")))\\nl=[]\\nfor i in range(k):\\n    l.append(0)\\nfor i in numbers:\\n    l[i%k]+=1\\ns=(l[0]//2)*2\\nimport math\\nfor g in range(1,math.ceil(k/2)):\\n    s=s+(min(l[g],l[k-g])*2)\\nif(k%2==0):\\n    s=s+((l[k//2]//2)*2)\\nprint(s)\", \"def main():\\n    n,k = list(map(int,input().split()))\\n    candy = list(map(int,input().split()))\\n    candies = []\\n    zeroes = 0\\n    for i in candy:\\n        mod = i%k\\n        if mod == 0:\\n            zeroes += 1\\n        else:\\n            candies.append(mod)\\n\\n    candies.sort()\\n\\n    boxes = zeroes//2\\n\\n    candy_dict = {}\\n\\n    for i in candies:\\n        if i not in list(candy_dict.keys()):\\n            candy_dict[i] = 1\\n        else:\\n            candy_dict[i] += 1\\n\\n    #print (candy_dict)\\n    for i in candy_dict:\\n        if candy_dict[i] > 0:\\n            if (k-i) in list(candy_dict.keys()):\\n                if candy_dict[k-i] > 0:\\n                    if i == (k-i):\\n                        box = candy_dict[i]//2\\n                        candy_dict[i] = candy_dict[i]%2\\n                    else:\\n                        box = min(candy_dict[i],candy_dict[k-i])\\n                        candy_dict[i] -= box\\n                        candy_dict[k-i] -= box\\n                    boxes += box\\n\\n    print(2*boxes)\\n    \\n\\nmain()\\n\", \"n,k=list(map(int,input().split()))\\na=[int(x)%k for x in input().split()]\\nf={}\\nan=0\\nfor i in a:\\n    if -i in f and f[-i]>0:\\n        an+=2\\n        f[-i]-=1\\n    elif k-i in f and f[k-i]>0:\\n        an+=2\\n        f[k-i]-=1\\n    else:\\n        if i not in f:f[i]=0\\n        f[i]+=1\\nprint(an)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\nost = [0] * k\\nfor i in range(n):\\n    ost[d[i] % k] += 1\\nans = ost[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i != k - i:\\n        ans += min(ost[i], ost[k - i])\\n    else:\\n        ans += ost[i] // 2\\nprint(ans * 2)\\n\", \"n, k = map(int, input().split())\\ncandies = list(map(int, input().split()))\\n\\ndiv = [0 for i in range(k)]\\n\\nfor i in candies:\\n    div[i % k] += 1\\n\\n\\nres = (div[0] // 2)*2\\nif k % 2 == 1:\\n    c = k//2 +1\\nelse:\\n    c = k//2 + 1\\nfor i in range(1, c):\\n    res += 2 * min(div[i], div[k - i]) if i != k - i else (div[i] // 2)*2\\nprint(res)\", \"n,k = list(map(int,input().split()))\\nnum = list(map(int,input().split()))\\ngay = []\\nfor i in num:\\n\\tgay.append(i%k)\\nnumber = [0] * 101\\nfor i in gay:\\n\\tnumber[i] += 1\\n#print(number)\\ni = 0\\nchuj = 1\\nwynik = 0\\nwhile i<k:\\n\\tif i == (k-i)%k:\\n\\t\\tif number[i] > 1:\\n\\t\\t\\tnumber[i] -= 2\\n\\t\\t\\twynik += 1\\n\\t\\telse:\\n\\t\\t\\tnumber[i] = 0\\n\\t\\t\\ti += 1\\n\\telse:\\n\\t\\tif number[i] > 0:\\n\\t\\t\\tif number[(k-i)%k]>0:\\n\\t\\t\\t\\tnumber[i] -= 1\\n\\t\\t\\t\\tnumber[(k-i)%k] -= 1\\n\\t\\t\\t\\twynik += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tnumber[i] = 0\\n\\t\\tif number[i] == 0:\\n\\t\\t\\ti += 1\\nprint(2*wynik)\"]",
        "difficulty": "introductory",
        "input": "8 2\n1 2 2 3 2 4 6 10\n",
        "output": "8\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1133/B"
    },
    {
        "id": 2428,
        "task_id": 4421,
        "test_case_id": 3,
        "question": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by $k$. In other words, two boxes $i$ and $j$ ($i \\ne j$) can be combined as a gift if $d_i + d_j$ is divisible by $k$.\n\nHow many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes \"partially\" or redistribute candies between them. \n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le n \\le 2 \\cdot 10^5, 1 \\le k \\le 100$) — the number the boxes and the number the girls.\n\nThe second line of the input contains $n$ integers $d_1, d_2, \\dots, d_n$ ($1 \\le d_i \\le 10^9$), where $d_i$ is the number of candies in the $i$-th box.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of the boxes Polycarp can give as gifts.\n\n\n-----Examples-----\nInput\n7 2\n1 2 2 3 2 4 10\n\nOutput\n6\n\nInput\n8 2\n1 2 2 3 2 4 6 10\n\nOutput\n8\n\nInput\n7 3\n1 2 2 3 2 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(2, 3)$;  $(5, 6)$;  $(1, 4)$. \n\nSo the answer is $6$.\n\nIn the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(6, 8)$;  $(2, 3)$;  $(1, 4)$;  $(5, 7)$. \n\nSo the answer is $8$.\n\nIn the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(1, 2)$;  $(6, 7)$. \n\nSo the answer is $4$.",
        "solutions": "[\"n, k = map(int, input().split())\\nD = list(map(int, input().split()))\\nz = {i: 0 for i in range(k)}\\nfor i in range(n):\\n    z[D[i] % k] += 1\\ncnt = z[0] // 2\\nfor q in range(1, k // 2 + k % 2):\\n    cnt += min(z[q], z[k - q])\\nif k % 2 == 0:\\n    cnt += z[k // 2] // 2\\nprint(cnt * 2)\", \"n, k = map(int, input().split())\\nd = list(map(int, input().split()))\\n\\ncount = [0] * k\\nfor x in d:\\n    count[x%k] += 1\\n\\nresult = count[0]//2\\nfor i in range(1, k):\\n    if i*2 >= k:\\n        break\\n    result += min(count[i], count[k-i])\\n\\nif k%2==0:\\n    result += count[k//2]//2\\nprint(result*2)\", \"n, k = list(map(int, input().split()))\\ncounts = [0] * k\\nfor i in map(int, input().split()):\\n    counts[i % k] += 1\\n\\nc = counts[0] // 2\\nfor i in range(1, k):\\n    if 2 * i >= k:\\n        break\\n    c += min(counts[i], counts[k - i])\\nif k % 2 == 0:\\n    c += counts[k // 2] // 2\\n\\nprint(2 * c)\\n\", \"def main():\\n    n, k = list(map(int, input().split()))\\n    cnt = [0] * k\\n    ans = 0\\n    arr = list(map(int, input().split()))\\n    for el in arr:\\n        t = el % k\\n        if (cnt[(k - t) % k] > 0):\\n            cnt[(k - t) % k] -= 1\\n            ans += 2\\n        else:\\n            cnt[t] += 1\\n    print(ans)\\n \\n \\nmain()\\n\", \"n, k = list(map(int, input().split()))\\n\\nans = [0] * k\\n\\na = list(map(int, input().split()))\\n\\nfor c in a:\\n\\tans[c % k] += 1\\nkol = ans[0] - ans[0] % 2\\nfor i in range(1, int(k / 2 + 0.5)):\\n\\tkol += min(ans[i], ans[k - i]) * 2\\n\\t#print(ans[i], ans[k - i], i)\\n\\nif k % 2 == 0:\\n\\tkol += ans[k // 2] - ans[k // 2] % 2\\n#print(ans)\\nprint(kol)\\n\", \"n, k = list(map(int,input().split()))\\ndi = list(map(int,input().split()))\\nai  = [0] * k\\nfor i in di:\\n    ai[i % k] += 1\\nans = ai[0] // 2\\nai[0] = 0\\nfor i in range(1,k):\\n    num = i\\n    num2 = k - i\\n    if num != num2:\\n        ans += min(ai[num], ai[num2])\\n    else:\\n        ans += ai[num] // 2\\n    ai[num] = 0\\n    ai[num2] = 0\\nprint(ans * 2)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\ndi = dict()\\nfor i in range(n):\\n    if d[i] % k in di:\\n        di[d[i] % k] += 1\\n    else:\\n        di[d[i] % k] = 1\\nans = 0\\nif 0 in di:\\n    ans = di[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i in di and k - i in di:\\n        if i == k - i:\\n            ans += di[i] // 2\\n        else:\\n            ans += min(di[i], di[k - i])\\nprint(ans * 2)\\n\", \"n,k = [int(x) for x in input().split()]\\n\\nL = [int(x) for x in input().split()]\\n\\nD = [0]*k\\n\\nfor i in L:\\n    D[i%k] += 1\\n    \\ns = 0    \\nfor i in range((k+2)//2):\\n    if i == 0:\\n        s += 2*(D[0]//2)\\n    elif (k%2 == 0) and (i == k//2):\\n        s += 2*(D[i]//2)\\n    else:\\n        s += 2*min(D[i],D[k-i])\\n    \\nprint(s)\", \"n,k=map(int,input().split())\\nd=[*map(int,input().split())]\\ncnt=[0]*k\\nfor i in d:\\n    cnt[i%k]+=1\\nans=cnt[0]//2\\nfor i in range(1,k):\\n    req=k-i\\n    if i<req:\\n        ans+=min(cnt[i],cnt[req])\\n    elif i==req:\\n        ans+=cnt[i]//2\\nprint(ans*2)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nd = [0] * k\\nfor i in range(n):\\n    d[a[i] % k] += 1\\n\\nnum = 0\\nfor i in range(k):\\n    if k - i < i:\\n        break\\n    if i == 0:\\n        num += d[i] // 2\\n    elif i == k - i:\\n        num += d[i] // 2\\n    else:\\n        num += min(d[i], d[k - i])\\n\\nprint(num * 2)\\n\", \"from collections import Counter as C\\nn, k = map(int, input().split())\\nl = [int(x) % k for x in input().split()]\\nc = C(l)\\nres = 0\\nfor i in range(k):\\n    j = -i % k\\n    vi, vj = c.get(i, 0), c.get(j, 0)\\n    if i == j:\\n        res += vi // 2\\n    else:\\n        res += min(vi, vj)\\n    c[i] = 0\\nprint(res * 2)\", \"n, K = map(int, input().split())\\narr = map(int, input().split())\\nfreq = [0 for _ in range(K)]\\nfor x in arr:\\n    freq[x%K] += 1\\nans = 2*(freq[0]//2)\\nfor i in range(1, K):\\n    if i < K-i:\\n        ans += 2*(min(freq[i], freq[K-i]))\\n    elif i == K-i:\\n        ans += 2*(freq[i]//2)\\nprint(ans)\", \"n,k = list(map(int,input().split()))\\nl   = list(map(int,input().split()))\\n\\nd = {}\\n\\nfor i in range(k):\\n    d[i] = 0\\n\\nfor i in range(len(l)):\\n    l[i] = l[i]%k\\n    d[l[i]] += 1 \\n\\ns = 0\\n\\ns += d[0]//2\\n\\nfor i in range(1,k//2):\\n    s += min(d[i],d[k-i])\\n\\nif k % 2 == 0:\\n    s += d[k//2] // 2\\nelse:\\n    if k != 1:\\n        s += min(d[k//2],d[k-k//2])\\n        \\nprint(s*2)\\n\", \"n,k=list(map(int,input().split()))\\nD=list(map(int,input().split()))\\n\\nD2=[d%k for d in D]\\n\\nfrom collections import Counter\\nc=Counter(D2)\\n\\nANS=c[0]//2*2\\nif k%2==0:\\n    ANS+=c[k//2]//2*2\\nfor i in range(1,-(-k//2)):\\n    ANS+=min(c[i],c[k-i])*2\\n\\nprint(ANS)\\n    \\n\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/3/7 23:13\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B. Preparation for International Women's Day.py\\n\\nfrom collections import Counter\\n\\n\\ndef main():\\n    n, k = map(int, input().split())\\n    d = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    for x in d:\\n        counter[x % k] += 1\\n\\n    ret = counter[0] // 2 * 2\\n    for i in range(1, k):\\n        if i != k - i:\\n            ret += min(counter[i], counter[k - i])\\n        else:\\n            ret += counter[i] // 2 * 2\\n    print(ret)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\ndivs = {}\\nhandled = [False, ] * k\\n\\nfor x in a:\\n    divs[x % k] = divs.get(x % k, 0) + 1\\n\\nresult = divs.get(0, 0) - divs.get(0, 0) % 2\\n\\nfor i in range(1, k):\\n    if not handled[i] and not handled[k - i]:\\n        if i != k - i:\\n            result += 2 * min(divs.get(i, 0), divs.get(k - i, 0))\\n        else:\\n            result += divs.get(i, 0) - divs.get(i, 0) % 2\\n        handled[i] = handled[k - i] = True\\n\\nprint(result)\\n\", \"#map(int,input().split())\\n#int(input())\\nn,k=map(int,input().split())\\na=list(map(int,input().split()))\\nd = dict()\\nfor i in range(n):\\n    m=a[i]%k\\n    if m not in d:\\n       d[m]=1\\n    else:\\n        d[m]+=1\\nans=0\\nif 0 in d:\\n   ans = d[0]//2\\nh=k//2\\nif k%2==0 and h in d:\\n    ans  += d[h]//2\\nfor i in range(1,(k+1)//2):\\n    if i in d and k-i in d:\\n       ans += min(d[i],d[k-i])\\nprint(ans*2)\", \"from math import floor\\nfrom collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = defaultdict(int)\\nfor i in input().split():\\n    i = int(i) % k\\n    a[i] += 1\\nr = 0\\nfor i in range(floor(k / 2) + 1):\\n    if i == 0 or i == k - i:\\n        r += a[i] // 2\\n    else:\\n        r += min(a[i], a[k - i])\\nprint(r * 2)\", \"n,k=tuple(map(int,input().strip().split(\\\" \\\")))\\nnumbers=tuple(map(int,input().strip().split(\\\" \\\")))\\nl=[]\\nfor i in range(k):\\n    l.append(0)\\nfor i in numbers:\\n    l[i%k]+=1\\ns=(l[0]//2)*2\\nimport math\\nfor g in range(1,math.ceil(k/2)):\\n    s=s+(min(l[g],l[k-g])*2)\\nif(k%2==0):\\n    s=s+((l[k//2]//2)*2)\\nprint(s)\", \"def main():\\n    n,k = list(map(int,input().split()))\\n    candy = list(map(int,input().split()))\\n    candies = []\\n    zeroes = 0\\n    for i in candy:\\n        mod = i%k\\n        if mod == 0:\\n            zeroes += 1\\n        else:\\n            candies.append(mod)\\n\\n    candies.sort()\\n\\n    boxes = zeroes//2\\n\\n    candy_dict = {}\\n\\n    for i in candies:\\n        if i not in list(candy_dict.keys()):\\n            candy_dict[i] = 1\\n        else:\\n            candy_dict[i] += 1\\n\\n    #print (candy_dict)\\n    for i in candy_dict:\\n        if candy_dict[i] > 0:\\n            if (k-i) in list(candy_dict.keys()):\\n                if candy_dict[k-i] > 0:\\n                    if i == (k-i):\\n                        box = candy_dict[i]//2\\n                        candy_dict[i] = candy_dict[i]%2\\n                    else:\\n                        box = min(candy_dict[i],candy_dict[k-i])\\n                        candy_dict[i] -= box\\n                        candy_dict[k-i] -= box\\n                    boxes += box\\n\\n    print(2*boxes)\\n    \\n\\nmain()\\n\", \"n,k=list(map(int,input().split()))\\na=[int(x)%k for x in input().split()]\\nf={}\\nan=0\\nfor i in a:\\n    if -i in f and f[-i]>0:\\n        an+=2\\n        f[-i]-=1\\n    elif k-i in f and f[k-i]>0:\\n        an+=2\\n        f[k-i]-=1\\n    else:\\n        if i not in f:f[i]=0\\n        f[i]+=1\\nprint(an)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\nost = [0] * k\\nfor i in range(n):\\n    ost[d[i] % k] += 1\\nans = ost[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i != k - i:\\n        ans += min(ost[i], ost[k - i])\\n    else:\\n        ans += ost[i] // 2\\nprint(ans * 2)\\n\", \"n, k = map(int, input().split())\\ncandies = list(map(int, input().split()))\\n\\ndiv = [0 for i in range(k)]\\n\\nfor i in candies:\\n    div[i % k] += 1\\n\\n\\nres = (div[0] // 2)*2\\nif k % 2 == 1:\\n    c = k//2 +1\\nelse:\\n    c = k//2 + 1\\nfor i in range(1, c):\\n    res += 2 * min(div[i], div[k - i]) if i != k - i else (div[i] // 2)*2\\nprint(res)\", \"n,k = list(map(int,input().split()))\\nnum = list(map(int,input().split()))\\ngay = []\\nfor i in num:\\n\\tgay.append(i%k)\\nnumber = [0] * 101\\nfor i in gay:\\n\\tnumber[i] += 1\\n#print(number)\\ni = 0\\nchuj = 1\\nwynik = 0\\nwhile i<k:\\n\\tif i == (k-i)%k:\\n\\t\\tif number[i] > 1:\\n\\t\\t\\tnumber[i] -= 2\\n\\t\\t\\twynik += 1\\n\\t\\telse:\\n\\t\\t\\tnumber[i] = 0\\n\\t\\t\\ti += 1\\n\\telse:\\n\\t\\tif number[i] > 0:\\n\\t\\t\\tif number[(k-i)%k]>0:\\n\\t\\t\\t\\tnumber[i] -= 1\\n\\t\\t\\t\\tnumber[(k-i)%k] -= 1\\n\\t\\t\\t\\twynik += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tnumber[i] = 0\\n\\t\\tif number[i] == 0:\\n\\t\\t\\ti += 1\\nprint(2*wynik)\"]",
        "difficulty": "introductory",
        "input": "7 3\n1 2 2 3 2 4 5\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1133/B"
    },
    {
        "id": 2429,
        "task_id": 4421,
        "test_case_id": 4,
        "question": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by $k$. In other words, two boxes $i$ and $j$ ($i \\ne j$) can be combined as a gift if $d_i + d_j$ is divisible by $k$.\n\nHow many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes \"partially\" or redistribute candies between them. \n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le n \\le 2 \\cdot 10^5, 1 \\le k \\le 100$) — the number the boxes and the number the girls.\n\nThe second line of the input contains $n$ integers $d_1, d_2, \\dots, d_n$ ($1 \\le d_i \\le 10^9$), where $d_i$ is the number of candies in the $i$-th box.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of the boxes Polycarp can give as gifts.\n\n\n-----Examples-----\nInput\n7 2\n1 2 2 3 2 4 10\n\nOutput\n6\n\nInput\n8 2\n1 2 2 3 2 4 6 10\n\nOutput\n8\n\nInput\n7 3\n1 2 2 3 2 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(2, 3)$;  $(5, 6)$;  $(1, 4)$. \n\nSo the answer is $6$.\n\nIn the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(6, 8)$;  $(2, 3)$;  $(1, 4)$;  $(5, 7)$. \n\nSo the answer is $8$.\n\nIn the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(1, 2)$;  $(6, 7)$. \n\nSo the answer is $4$.",
        "solutions": "[\"n, k = map(int, input().split())\\nD = list(map(int, input().split()))\\nz = {i: 0 for i in range(k)}\\nfor i in range(n):\\n    z[D[i] % k] += 1\\ncnt = z[0] // 2\\nfor q in range(1, k // 2 + k % 2):\\n    cnt += min(z[q], z[k - q])\\nif k % 2 == 0:\\n    cnt += z[k // 2] // 2\\nprint(cnt * 2)\", \"n, k = map(int, input().split())\\nd = list(map(int, input().split()))\\n\\ncount = [0] * k\\nfor x in d:\\n    count[x%k] += 1\\n\\nresult = count[0]//2\\nfor i in range(1, k):\\n    if i*2 >= k:\\n        break\\n    result += min(count[i], count[k-i])\\n\\nif k%2==0:\\n    result += count[k//2]//2\\nprint(result*2)\", \"n, k = list(map(int, input().split()))\\ncounts = [0] * k\\nfor i in map(int, input().split()):\\n    counts[i % k] += 1\\n\\nc = counts[0] // 2\\nfor i in range(1, k):\\n    if 2 * i >= k:\\n        break\\n    c += min(counts[i], counts[k - i])\\nif k % 2 == 0:\\n    c += counts[k // 2] // 2\\n\\nprint(2 * c)\\n\", \"def main():\\n    n, k = list(map(int, input().split()))\\n    cnt = [0] * k\\n    ans = 0\\n    arr = list(map(int, input().split()))\\n    for el in arr:\\n        t = el % k\\n        if (cnt[(k - t) % k] > 0):\\n            cnt[(k - t) % k] -= 1\\n            ans += 2\\n        else:\\n            cnt[t] += 1\\n    print(ans)\\n \\n \\nmain()\\n\", \"n, k = list(map(int, input().split()))\\n\\nans = [0] * k\\n\\na = list(map(int, input().split()))\\n\\nfor c in a:\\n\\tans[c % k] += 1\\nkol = ans[0] - ans[0] % 2\\nfor i in range(1, int(k / 2 + 0.5)):\\n\\tkol += min(ans[i], ans[k - i]) * 2\\n\\t#print(ans[i], ans[k - i], i)\\n\\nif k % 2 == 0:\\n\\tkol += ans[k // 2] - ans[k // 2] % 2\\n#print(ans)\\nprint(kol)\\n\", \"n, k = list(map(int,input().split()))\\ndi = list(map(int,input().split()))\\nai  = [0] * k\\nfor i in di:\\n    ai[i % k] += 1\\nans = ai[0] // 2\\nai[0] = 0\\nfor i in range(1,k):\\n    num = i\\n    num2 = k - i\\n    if num != num2:\\n        ans += min(ai[num], ai[num2])\\n    else:\\n        ans += ai[num] // 2\\n    ai[num] = 0\\n    ai[num2] = 0\\nprint(ans * 2)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\ndi = dict()\\nfor i in range(n):\\n    if d[i] % k in di:\\n        di[d[i] % k] += 1\\n    else:\\n        di[d[i] % k] = 1\\nans = 0\\nif 0 in di:\\n    ans = di[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i in di and k - i in di:\\n        if i == k - i:\\n            ans += di[i] // 2\\n        else:\\n            ans += min(di[i], di[k - i])\\nprint(ans * 2)\\n\", \"n,k = [int(x) for x in input().split()]\\n\\nL = [int(x) for x in input().split()]\\n\\nD = [0]*k\\n\\nfor i in L:\\n    D[i%k] += 1\\n    \\ns = 0    \\nfor i in range((k+2)//2):\\n    if i == 0:\\n        s += 2*(D[0]//2)\\n    elif (k%2 == 0) and (i == k//2):\\n        s += 2*(D[i]//2)\\n    else:\\n        s += 2*min(D[i],D[k-i])\\n    \\nprint(s)\", \"n,k=map(int,input().split())\\nd=[*map(int,input().split())]\\ncnt=[0]*k\\nfor i in d:\\n    cnt[i%k]+=1\\nans=cnt[0]//2\\nfor i in range(1,k):\\n    req=k-i\\n    if i<req:\\n        ans+=min(cnt[i],cnt[req])\\n    elif i==req:\\n        ans+=cnt[i]//2\\nprint(ans*2)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nd = [0] * k\\nfor i in range(n):\\n    d[a[i] % k] += 1\\n\\nnum = 0\\nfor i in range(k):\\n    if k - i < i:\\n        break\\n    if i == 0:\\n        num += d[i] // 2\\n    elif i == k - i:\\n        num += d[i] // 2\\n    else:\\n        num += min(d[i], d[k - i])\\n\\nprint(num * 2)\\n\", \"from collections import Counter as C\\nn, k = map(int, input().split())\\nl = [int(x) % k for x in input().split()]\\nc = C(l)\\nres = 0\\nfor i in range(k):\\n    j = -i % k\\n    vi, vj = c.get(i, 0), c.get(j, 0)\\n    if i == j:\\n        res += vi // 2\\n    else:\\n        res += min(vi, vj)\\n    c[i] = 0\\nprint(res * 2)\", \"n, K = map(int, input().split())\\narr = map(int, input().split())\\nfreq = [0 for _ in range(K)]\\nfor x in arr:\\n    freq[x%K] += 1\\nans = 2*(freq[0]//2)\\nfor i in range(1, K):\\n    if i < K-i:\\n        ans += 2*(min(freq[i], freq[K-i]))\\n    elif i == K-i:\\n        ans += 2*(freq[i]//2)\\nprint(ans)\", \"n,k = list(map(int,input().split()))\\nl   = list(map(int,input().split()))\\n\\nd = {}\\n\\nfor i in range(k):\\n    d[i] = 0\\n\\nfor i in range(len(l)):\\n    l[i] = l[i]%k\\n    d[l[i]] += 1 \\n\\ns = 0\\n\\ns += d[0]//2\\n\\nfor i in range(1,k//2):\\n    s += min(d[i],d[k-i])\\n\\nif k % 2 == 0:\\n    s += d[k//2] // 2\\nelse:\\n    if k != 1:\\n        s += min(d[k//2],d[k-k//2])\\n        \\nprint(s*2)\\n\", \"n,k=list(map(int,input().split()))\\nD=list(map(int,input().split()))\\n\\nD2=[d%k for d in D]\\n\\nfrom collections import Counter\\nc=Counter(D2)\\n\\nANS=c[0]//2*2\\nif k%2==0:\\n    ANS+=c[k//2]//2*2\\nfor i in range(1,-(-k//2)):\\n    ANS+=min(c[i],c[k-i])*2\\n\\nprint(ANS)\\n    \\n\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/3/7 23:13\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B. Preparation for International Women's Day.py\\n\\nfrom collections import Counter\\n\\n\\ndef main():\\n    n, k = map(int, input().split())\\n    d = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    for x in d:\\n        counter[x % k] += 1\\n\\n    ret = counter[0] // 2 * 2\\n    for i in range(1, k):\\n        if i != k - i:\\n            ret += min(counter[i], counter[k - i])\\n        else:\\n            ret += counter[i] // 2 * 2\\n    print(ret)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\ndivs = {}\\nhandled = [False, ] * k\\n\\nfor x in a:\\n    divs[x % k] = divs.get(x % k, 0) + 1\\n\\nresult = divs.get(0, 0) - divs.get(0, 0) % 2\\n\\nfor i in range(1, k):\\n    if not handled[i] and not handled[k - i]:\\n        if i != k - i:\\n            result += 2 * min(divs.get(i, 0), divs.get(k - i, 0))\\n        else:\\n            result += divs.get(i, 0) - divs.get(i, 0) % 2\\n        handled[i] = handled[k - i] = True\\n\\nprint(result)\\n\", \"#map(int,input().split())\\n#int(input())\\nn,k=map(int,input().split())\\na=list(map(int,input().split()))\\nd = dict()\\nfor i in range(n):\\n    m=a[i]%k\\n    if m not in d:\\n       d[m]=1\\n    else:\\n        d[m]+=1\\nans=0\\nif 0 in d:\\n   ans = d[0]//2\\nh=k//2\\nif k%2==0 and h in d:\\n    ans  += d[h]//2\\nfor i in range(1,(k+1)//2):\\n    if i in d and k-i in d:\\n       ans += min(d[i],d[k-i])\\nprint(ans*2)\", \"from math import floor\\nfrom collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = defaultdict(int)\\nfor i in input().split():\\n    i = int(i) % k\\n    a[i] += 1\\nr = 0\\nfor i in range(floor(k / 2) + 1):\\n    if i == 0 or i == k - i:\\n        r += a[i] // 2\\n    else:\\n        r += min(a[i], a[k - i])\\nprint(r * 2)\", \"n,k=tuple(map(int,input().strip().split(\\\" \\\")))\\nnumbers=tuple(map(int,input().strip().split(\\\" \\\")))\\nl=[]\\nfor i in range(k):\\n    l.append(0)\\nfor i in numbers:\\n    l[i%k]+=1\\ns=(l[0]//2)*2\\nimport math\\nfor g in range(1,math.ceil(k/2)):\\n    s=s+(min(l[g],l[k-g])*2)\\nif(k%2==0):\\n    s=s+((l[k//2]//2)*2)\\nprint(s)\", \"def main():\\n    n,k = list(map(int,input().split()))\\n    candy = list(map(int,input().split()))\\n    candies = []\\n    zeroes = 0\\n    for i in candy:\\n        mod = i%k\\n        if mod == 0:\\n            zeroes += 1\\n        else:\\n            candies.append(mod)\\n\\n    candies.sort()\\n\\n    boxes = zeroes//2\\n\\n    candy_dict = {}\\n\\n    for i in candies:\\n        if i not in list(candy_dict.keys()):\\n            candy_dict[i] = 1\\n        else:\\n            candy_dict[i] += 1\\n\\n    #print (candy_dict)\\n    for i in candy_dict:\\n        if candy_dict[i] > 0:\\n            if (k-i) in list(candy_dict.keys()):\\n                if candy_dict[k-i] > 0:\\n                    if i == (k-i):\\n                        box = candy_dict[i]//2\\n                        candy_dict[i] = candy_dict[i]%2\\n                    else:\\n                        box = min(candy_dict[i],candy_dict[k-i])\\n                        candy_dict[i] -= box\\n                        candy_dict[k-i] -= box\\n                    boxes += box\\n\\n    print(2*boxes)\\n    \\n\\nmain()\\n\", \"n,k=list(map(int,input().split()))\\na=[int(x)%k for x in input().split()]\\nf={}\\nan=0\\nfor i in a:\\n    if -i in f and f[-i]>0:\\n        an+=2\\n        f[-i]-=1\\n    elif k-i in f and f[k-i]>0:\\n        an+=2\\n        f[k-i]-=1\\n    else:\\n        if i not in f:f[i]=0\\n        f[i]+=1\\nprint(an)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\nost = [0] * k\\nfor i in range(n):\\n    ost[d[i] % k] += 1\\nans = ost[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i != k - i:\\n        ans += min(ost[i], ost[k - i])\\n    else:\\n        ans += ost[i] // 2\\nprint(ans * 2)\\n\", \"n, k = map(int, input().split())\\ncandies = list(map(int, input().split()))\\n\\ndiv = [0 for i in range(k)]\\n\\nfor i in candies:\\n    div[i % k] += 1\\n\\n\\nres = (div[0] // 2)*2\\nif k % 2 == 1:\\n    c = k//2 +1\\nelse:\\n    c = k//2 + 1\\nfor i in range(1, c):\\n    res += 2 * min(div[i], div[k - i]) if i != k - i else (div[i] // 2)*2\\nprint(res)\", \"n,k = list(map(int,input().split()))\\nnum = list(map(int,input().split()))\\ngay = []\\nfor i in num:\\n\\tgay.append(i%k)\\nnumber = [0] * 101\\nfor i in gay:\\n\\tnumber[i] += 1\\n#print(number)\\ni = 0\\nchuj = 1\\nwynik = 0\\nwhile i<k:\\n\\tif i == (k-i)%k:\\n\\t\\tif number[i] > 1:\\n\\t\\t\\tnumber[i] -= 2\\n\\t\\t\\twynik += 1\\n\\t\\telse:\\n\\t\\t\\tnumber[i] = 0\\n\\t\\t\\ti += 1\\n\\telse:\\n\\t\\tif number[i] > 0:\\n\\t\\t\\tif number[(k-i)%k]>0:\\n\\t\\t\\t\\tnumber[i] -= 1\\n\\t\\t\\t\\tnumber[(k-i)%k] -= 1\\n\\t\\t\\t\\twynik += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tnumber[i] = 0\\n\\t\\tif number[i] == 0:\\n\\t\\t\\ti += 1\\nprint(2*wynik)\"]",
        "difficulty": "introductory",
        "input": "1 2\n120\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1133/B"
    },
    {
        "id": 2430,
        "task_id": 4421,
        "test_case_id": 5,
        "question": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by $k$. In other words, two boxes $i$ and $j$ ($i \\ne j$) can be combined as a gift if $d_i + d_j$ is divisible by $k$.\n\nHow many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes \"partially\" or redistribute candies between them. \n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le n \\le 2 \\cdot 10^5, 1 \\le k \\le 100$) — the number the boxes and the number the girls.\n\nThe second line of the input contains $n$ integers $d_1, d_2, \\dots, d_n$ ($1 \\le d_i \\le 10^9$), where $d_i$ is the number of candies in the $i$-th box.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of the boxes Polycarp can give as gifts.\n\n\n-----Examples-----\nInput\n7 2\n1 2 2 3 2 4 10\n\nOutput\n6\n\nInput\n8 2\n1 2 2 3 2 4 6 10\n\nOutput\n8\n\nInput\n7 3\n1 2 2 3 2 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(2, 3)$;  $(5, 6)$;  $(1, 4)$. \n\nSo the answer is $6$.\n\nIn the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(6, 8)$;  $(2, 3)$;  $(1, 4)$;  $(5, 7)$. \n\nSo the answer is $8$.\n\nIn the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(1, 2)$;  $(6, 7)$. \n\nSo the answer is $4$.",
        "solutions": "[\"n, k = map(int, input().split())\\nD = list(map(int, input().split()))\\nz = {i: 0 for i in range(k)}\\nfor i in range(n):\\n    z[D[i] % k] += 1\\ncnt = z[0] // 2\\nfor q in range(1, k // 2 + k % 2):\\n    cnt += min(z[q], z[k - q])\\nif k % 2 == 0:\\n    cnt += z[k // 2] // 2\\nprint(cnt * 2)\", \"n, k = map(int, input().split())\\nd = list(map(int, input().split()))\\n\\ncount = [0] * k\\nfor x in d:\\n    count[x%k] += 1\\n\\nresult = count[0]//2\\nfor i in range(1, k):\\n    if i*2 >= k:\\n        break\\n    result += min(count[i], count[k-i])\\n\\nif k%2==0:\\n    result += count[k//2]//2\\nprint(result*2)\", \"n, k = list(map(int, input().split()))\\ncounts = [0] * k\\nfor i in map(int, input().split()):\\n    counts[i % k] += 1\\n\\nc = counts[0] // 2\\nfor i in range(1, k):\\n    if 2 * i >= k:\\n        break\\n    c += min(counts[i], counts[k - i])\\nif k % 2 == 0:\\n    c += counts[k // 2] // 2\\n\\nprint(2 * c)\\n\", \"def main():\\n    n, k = list(map(int, input().split()))\\n    cnt = [0] * k\\n    ans = 0\\n    arr = list(map(int, input().split()))\\n    for el in arr:\\n        t = el % k\\n        if (cnt[(k - t) % k] > 0):\\n            cnt[(k - t) % k] -= 1\\n            ans += 2\\n        else:\\n            cnt[t] += 1\\n    print(ans)\\n \\n \\nmain()\\n\", \"n, k = list(map(int, input().split()))\\n\\nans = [0] * k\\n\\na = list(map(int, input().split()))\\n\\nfor c in a:\\n\\tans[c % k] += 1\\nkol = ans[0] - ans[0] % 2\\nfor i in range(1, int(k / 2 + 0.5)):\\n\\tkol += min(ans[i], ans[k - i]) * 2\\n\\t#print(ans[i], ans[k - i], i)\\n\\nif k % 2 == 0:\\n\\tkol += ans[k // 2] - ans[k // 2] % 2\\n#print(ans)\\nprint(kol)\\n\", \"n, k = list(map(int,input().split()))\\ndi = list(map(int,input().split()))\\nai  = [0] * k\\nfor i in di:\\n    ai[i % k] += 1\\nans = ai[0] // 2\\nai[0] = 0\\nfor i in range(1,k):\\n    num = i\\n    num2 = k - i\\n    if num != num2:\\n        ans += min(ai[num], ai[num2])\\n    else:\\n        ans += ai[num] // 2\\n    ai[num] = 0\\n    ai[num2] = 0\\nprint(ans * 2)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\ndi = dict()\\nfor i in range(n):\\n    if d[i] % k in di:\\n        di[d[i] % k] += 1\\n    else:\\n        di[d[i] % k] = 1\\nans = 0\\nif 0 in di:\\n    ans = di[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i in di and k - i in di:\\n        if i == k - i:\\n            ans += di[i] // 2\\n        else:\\n            ans += min(di[i], di[k - i])\\nprint(ans * 2)\\n\", \"n,k = [int(x) for x in input().split()]\\n\\nL = [int(x) for x in input().split()]\\n\\nD = [0]*k\\n\\nfor i in L:\\n    D[i%k] += 1\\n    \\ns = 0    \\nfor i in range((k+2)//2):\\n    if i == 0:\\n        s += 2*(D[0]//2)\\n    elif (k%2 == 0) and (i == k//2):\\n        s += 2*(D[i]//2)\\n    else:\\n        s += 2*min(D[i],D[k-i])\\n    \\nprint(s)\", \"n,k=map(int,input().split())\\nd=[*map(int,input().split())]\\ncnt=[0]*k\\nfor i in d:\\n    cnt[i%k]+=1\\nans=cnt[0]//2\\nfor i in range(1,k):\\n    req=k-i\\n    if i<req:\\n        ans+=min(cnt[i],cnt[req])\\n    elif i==req:\\n        ans+=cnt[i]//2\\nprint(ans*2)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nd = [0] * k\\nfor i in range(n):\\n    d[a[i] % k] += 1\\n\\nnum = 0\\nfor i in range(k):\\n    if k - i < i:\\n        break\\n    if i == 0:\\n        num += d[i] // 2\\n    elif i == k - i:\\n        num += d[i] // 2\\n    else:\\n        num += min(d[i], d[k - i])\\n\\nprint(num * 2)\\n\", \"from collections import Counter as C\\nn, k = map(int, input().split())\\nl = [int(x) % k for x in input().split()]\\nc = C(l)\\nres = 0\\nfor i in range(k):\\n    j = -i % k\\n    vi, vj = c.get(i, 0), c.get(j, 0)\\n    if i == j:\\n        res += vi // 2\\n    else:\\n        res += min(vi, vj)\\n    c[i] = 0\\nprint(res * 2)\", \"n, K = map(int, input().split())\\narr = map(int, input().split())\\nfreq = [0 for _ in range(K)]\\nfor x in arr:\\n    freq[x%K] += 1\\nans = 2*(freq[0]//2)\\nfor i in range(1, K):\\n    if i < K-i:\\n        ans += 2*(min(freq[i], freq[K-i]))\\n    elif i == K-i:\\n        ans += 2*(freq[i]//2)\\nprint(ans)\", \"n,k = list(map(int,input().split()))\\nl   = list(map(int,input().split()))\\n\\nd = {}\\n\\nfor i in range(k):\\n    d[i] = 0\\n\\nfor i in range(len(l)):\\n    l[i] = l[i]%k\\n    d[l[i]] += 1 \\n\\ns = 0\\n\\ns += d[0]//2\\n\\nfor i in range(1,k//2):\\n    s += min(d[i],d[k-i])\\n\\nif k % 2 == 0:\\n    s += d[k//2] // 2\\nelse:\\n    if k != 1:\\n        s += min(d[k//2],d[k-k//2])\\n        \\nprint(s*2)\\n\", \"n,k=list(map(int,input().split()))\\nD=list(map(int,input().split()))\\n\\nD2=[d%k for d in D]\\n\\nfrom collections import Counter\\nc=Counter(D2)\\n\\nANS=c[0]//2*2\\nif k%2==0:\\n    ANS+=c[k//2]//2*2\\nfor i in range(1,-(-k//2)):\\n    ANS+=min(c[i],c[k-i])*2\\n\\nprint(ANS)\\n    \\n\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/3/7 23:13\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B. Preparation for International Women's Day.py\\n\\nfrom collections import Counter\\n\\n\\ndef main():\\n    n, k = map(int, input().split())\\n    d = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    for x in d:\\n        counter[x % k] += 1\\n\\n    ret = counter[0] // 2 * 2\\n    for i in range(1, k):\\n        if i != k - i:\\n            ret += min(counter[i], counter[k - i])\\n        else:\\n            ret += counter[i] // 2 * 2\\n    print(ret)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\ndivs = {}\\nhandled = [False, ] * k\\n\\nfor x in a:\\n    divs[x % k] = divs.get(x % k, 0) + 1\\n\\nresult = divs.get(0, 0) - divs.get(0, 0) % 2\\n\\nfor i in range(1, k):\\n    if not handled[i] and not handled[k - i]:\\n        if i != k - i:\\n            result += 2 * min(divs.get(i, 0), divs.get(k - i, 0))\\n        else:\\n            result += divs.get(i, 0) - divs.get(i, 0) % 2\\n        handled[i] = handled[k - i] = True\\n\\nprint(result)\\n\", \"#map(int,input().split())\\n#int(input())\\nn,k=map(int,input().split())\\na=list(map(int,input().split()))\\nd = dict()\\nfor i in range(n):\\n    m=a[i]%k\\n    if m not in d:\\n       d[m]=1\\n    else:\\n        d[m]+=1\\nans=0\\nif 0 in d:\\n   ans = d[0]//2\\nh=k//2\\nif k%2==0 and h in d:\\n    ans  += d[h]//2\\nfor i in range(1,(k+1)//2):\\n    if i in d and k-i in d:\\n       ans += min(d[i],d[k-i])\\nprint(ans*2)\", \"from math import floor\\nfrom collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = defaultdict(int)\\nfor i in input().split():\\n    i = int(i) % k\\n    a[i] += 1\\nr = 0\\nfor i in range(floor(k / 2) + 1):\\n    if i == 0 or i == k - i:\\n        r += a[i] // 2\\n    else:\\n        r += min(a[i], a[k - i])\\nprint(r * 2)\", \"n,k=tuple(map(int,input().strip().split(\\\" \\\")))\\nnumbers=tuple(map(int,input().strip().split(\\\" \\\")))\\nl=[]\\nfor i in range(k):\\n    l.append(0)\\nfor i in numbers:\\n    l[i%k]+=1\\ns=(l[0]//2)*2\\nimport math\\nfor g in range(1,math.ceil(k/2)):\\n    s=s+(min(l[g],l[k-g])*2)\\nif(k%2==0):\\n    s=s+((l[k//2]//2)*2)\\nprint(s)\", \"def main():\\n    n,k = list(map(int,input().split()))\\n    candy = list(map(int,input().split()))\\n    candies = []\\n    zeroes = 0\\n    for i in candy:\\n        mod = i%k\\n        if mod == 0:\\n            zeroes += 1\\n        else:\\n            candies.append(mod)\\n\\n    candies.sort()\\n\\n    boxes = zeroes//2\\n\\n    candy_dict = {}\\n\\n    for i in candies:\\n        if i not in list(candy_dict.keys()):\\n            candy_dict[i] = 1\\n        else:\\n            candy_dict[i] += 1\\n\\n    #print (candy_dict)\\n    for i in candy_dict:\\n        if candy_dict[i] > 0:\\n            if (k-i) in list(candy_dict.keys()):\\n                if candy_dict[k-i] > 0:\\n                    if i == (k-i):\\n                        box = candy_dict[i]//2\\n                        candy_dict[i] = candy_dict[i]%2\\n                    else:\\n                        box = min(candy_dict[i],candy_dict[k-i])\\n                        candy_dict[i] -= box\\n                        candy_dict[k-i] -= box\\n                    boxes += box\\n\\n    print(2*boxes)\\n    \\n\\nmain()\\n\", \"n,k=list(map(int,input().split()))\\na=[int(x)%k for x in input().split()]\\nf={}\\nan=0\\nfor i in a:\\n    if -i in f and f[-i]>0:\\n        an+=2\\n        f[-i]-=1\\n    elif k-i in f and f[k-i]>0:\\n        an+=2\\n        f[k-i]-=1\\n    else:\\n        if i not in f:f[i]=0\\n        f[i]+=1\\nprint(an)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\nost = [0] * k\\nfor i in range(n):\\n    ost[d[i] % k] += 1\\nans = ost[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i != k - i:\\n        ans += min(ost[i], ost[k - i])\\n    else:\\n        ans += ost[i] // 2\\nprint(ans * 2)\\n\", \"n, k = map(int, input().split())\\ncandies = list(map(int, input().split()))\\n\\ndiv = [0 for i in range(k)]\\n\\nfor i in candies:\\n    div[i % k] += 1\\n\\n\\nres = (div[0] // 2)*2\\nif k % 2 == 1:\\n    c = k//2 +1\\nelse:\\n    c = k//2 + 1\\nfor i in range(1, c):\\n    res += 2 * min(div[i], div[k - i]) if i != k - i else (div[i] // 2)*2\\nprint(res)\", \"n,k = list(map(int,input().split()))\\nnum = list(map(int,input().split()))\\ngay = []\\nfor i in num:\\n\\tgay.append(i%k)\\nnumber = [0] * 101\\nfor i in gay:\\n\\tnumber[i] += 1\\n#print(number)\\ni = 0\\nchuj = 1\\nwynik = 0\\nwhile i<k:\\n\\tif i == (k-i)%k:\\n\\t\\tif number[i] > 1:\\n\\t\\t\\tnumber[i] -= 2\\n\\t\\t\\twynik += 1\\n\\t\\telse:\\n\\t\\t\\tnumber[i] = 0\\n\\t\\t\\ti += 1\\n\\telse:\\n\\t\\tif number[i] > 0:\\n\\t\\t\\tif number[(k-i)%k]>0:\\n\\t\\t\\t\\tnumber[i] -= 1\\n\\t\\t\\t\\tnumber[(k-i)%k] -= 1\\n\\t\\t\\t\\twynik += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tnumber[i] = 0\\n\\t\\tif number[i] == 0:\\n\\t\\t\\ti += 1\\nprint(2*wynik)\"]",
        "difficulty": "introductory",
        "input": "2 9\n80 1\n",
        "output": "2\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1133/B"
    },
    {
        "id": 2431,
        "task_id": 4421,
        "test_case_id": 6,
        "question": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by $k$. In other words, two boxes $i$ and $j$ ($i \\ne j$) can be combined as a gift if $d_i + d_j$ is divisible by $k$.\n\nHow many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes \"partially\" or redistribute candies between them. \n\n\n-----Input-----\n\nThe first line of the input contains two integers $n$ and $k$ ($1 \\le n \\le 2 \\cdot 10^5, 1 \\le k \\le 100$) — the number the boxes and the number the girls.\n\nThe second line of the input contains $n$ integers $d_1, d_2, \\dots, d_n$ ($1 \\le d_i \\le 10^9$), where $d_i$ is the number of candies in the $i$-th box.\n\n\n-----Output-----\n\nPrint one integer — the maximum number of the boxes Polycarp can give as gifts.\n\n\n-----Examples-----\nInput\n7 2\n1 2 2 3 2 4 10\n\nOutput\n6\n\nInput\n8 2\n1 2 2 3 2 4 6 10\n\nOutput\n8\n\nInput\n7 3\n1 2 2 3 2 4 5\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(2, 3)$;  $(5, 6)$;  $(1, 4)$. \n\nSo the answer is $6$.\n\nIn the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(6, 8)$;  $(2, 3)$;  $(1, 4)$;  $(5, 7)$. \n\nSo the answer is $8$.\n\nIn the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(1, 2)$;  $(6, 7)$. \n\nSo the answer is $4$.",
        "solutions": "[\"n, k = map(int, input().split())\\nD = list(map(int, input().split()))\\nz = {i: 0 for i in range(k)}\\nfor i in range(n):\\n    z[D[i] % k] += 1\\ncnt = z[0] // 2\\nfor q in range(1, k // 2 + k % 2):\\n    cnt += min(z[q], z[k - q])\\nif k % 2 == 0:\\n    cnt += z[k // 2] // 2\\nprint(cnt * 2)\", \"n, k = map(int, input().split())\\nd = list(map(int, input().split()))\\n\\ncount = [0] * k\\nfor x in d:\\n    count[x%k] += 1\\n\\nresult = count[0]//2\\nfor i in range(1, k):\\n    if i*2 >= k:\\n        break\\n    result += min(count[i], count[k-i])\\n\\nif k%2==0:\\n    result += count[k//2]//2\\nprint(result*2)\", \"n, k = list(map(int, input().split()))\\ncounts = [0] * k\\nfor i in map(int, input().split()):\\n    counts[i % k] += 1\\n\\nc = counts[0] // 2\\nfor i in range(1, k):\\n    if 2 * i >= k:\\n        break\\n    c += min(counts[i], counts[k - i])\\nif k % 2 == 0:\\n    c += counts[k // 2] // 2\\n\\nprint(2 * c)\\n\", \"def main():\\n    n, k = list(map(int, input().split()))\\n    cnt = [0] * k\\n    ans = 0\\n    arr = list(map(int, input().split()))\\n    for el in arr:\\n        t = el % k\\n        if (cnt[(k - t) % k] > 0):\\n            cnt[(k - t) % k] -= 1\\n            ans += 2\\n        else:\\n            cnt[t] += 1\\n    print(ans)\\n \\n \\nmain()\\n\", \"n, k = list(map(int, input().split()))\\n\\nans = [0] * k\\n\\na = list(map(int, input().split()))\\n\\nfor c in a:\\n\\tans[c % k] += 1\\nkol = ans[0] - ans[0] % 2\\nfor i in range(1, int(k / 2 + 0.5)):\\n\\tkol += min(ans[i], ans[k - i]) * 2\\n\\t#print(ans[i], ans[k - i], i)\\n\\nif k % 2 == 0:\\n\\tkol += ans[k // 2] - ans[k // 2] % 2\\n#print(ans)\\nprint(kol)\\n\", \"n, k = list(map(int,input().split()))\\ndi = list(map(int,input().split()))\\nai  = [0] * k\\nfor i in di:\\n    ai[i % k] += 1\\nans = ai[0] // 2\\nai[0] = 0\\nfor i in range(1,k):\\n    num = i\\n    num2 = k - i\\n    if num != num2:\\n        ans += min(ai[num], ai[num2])\\n    else:\\n        ans += ai[num] // 2\\n    ai[num] = 0\\n    ai[num2] = 0\\nprint(ans * 2)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\ndi = dict()\\nfor i in range(n):\\n    if d[i] % k in di:\\n        di[d[i] % k] += 1\\n    else:\\n        di[d[i] % k] = 1\\nans = 0\\nif 0 in di:\\n    ans = di[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i in di and k - i in di:\\n        if i == k - i:\\n            ans += di[i] // 2\\n        else:\\n            ans += min(di[i], di[k - i])\\nprint(ans * 2)\\n\", \"n,k = [int(x) for x in input().split()]\\n\\nL = [int(x) for x in input().split()]\\n\\nD = [0]*k\\n\\nfor i in L:\\n    D[i%k] += 1\\n    \\ns = 0    \\nfor i in range((k+2)//2):\\n    if i == 0:\\n        s += 2*(D[0]//2)\\n    elif (k%2 == 0) and (i == k//2):\\n        s += 2*(D[i]//2)\\n    else:\\n        s += 2*min(D[i],D[k-i])\\n    \\nprint(s)\", \"n,k=map(int,input().split())\\nd=[*map(int,input().split())]\\ncnt=[0]*k\\nfor i in d:\\n    cnt[i%k]+=1\\nans=cnt[0]//2\\nfor i in range(1,k):\\n    req=k-i\\n    if i<req:\\n        ans+=min(cnt[i],cnt[req])\\n    elif i==req:\\n        ans+=cnt[i]//2\\nprint(ans*2)\", \"n, k = list(map(int, input().split()))\\na = list(map(int, input().split()))\\nd = [0] * k\\nfor i in range(n):\\n    d[a[i] % k] += 1\\n\\nnum = 0\\nfor i in range(k):\\n    if k - i < i:\\n        break\\n    if i == 0:\\n        num += d[i] // 2\\n    elif i == k - i:\\n        num += d[i] // 2\\n    else:\\n        num += min(d[i], d[k - i])\\n\\nprint(num * 2)\\n\", \"from collections import Counter as C\\nn, k = map(int, input().split())\\nl = [int(x) % k for x in input().split()]\\nc = C(l)\\nres = 0\\nfor i in range(k):\\n    j = -i % k\\n    vi, vj = c.get(i, 0), c.get(j, 0)\\n    if i == j:\\n        res += vi // 2\\n    else:\\n        res += min(vi, vj)\\n    c[i] = 0\\nprint(res * 2)\", \"n, K = map(int, input().split())\\narr = map(int, input().split())\\nfreq = [0 for _ in range(K)]\\nfor x in arr:\\n    freq[x%K] += 1\\nans = 2*(freq[0]//2)\\nfor i in range(1, K):\\n    if i < K-i:\\n        ans += 2*(min(freq[i], freq[K-i]))\\n    elif i == K-i:\\n        ans += 2*(freq[i]//2)\\nprint(ans)\", \"n,k = list(map(int,input().split()))\\nl   = list(map(int,input().split()))\\n\\nd = {}\\n\\nfor i in range(k):\\n    d[i] = 0\\n\\nfor i in range(len(l)):\\n    l[i] = l[i]%k\\n    d[l[i]] += 1 \\n\\ns = 0\\n\\ns += d[0]//2\\n\\nfor i in range(1,k//2):\\n    s += min(d[i],d[k-i])\\n\\nif k % 2 == 0:\\n    s += d[k//2] // 2\\nelse:\\n    if k != 1:\\n        s += min(d[k//2],d[k-k//2])\\n        \\nprint(s*2)\\n\", \"n,k=list(map(int,input().split()))\\nD=list(map(int,input().split()))\\n\\nD2=[d%k for d in D]\\n\\nfrom collections import Counter\\nc=Counter(D2)\\n\\nANS=c[0]//2*2\\nif k%2==0:\\n    ANS+=c[k//2]//2*2\\nfor i in range(1,-(-k//2)):\\n    ANS+=min(c[i],c[k-i])*2\\n\\nprint(ANS)\\n    \\n\", \"# -*- coding: utf-8 -*-\\n# @Time    : 2019/3/7 23:13\\n# @Author  : LunaFire\\n# @Email   : gilgemesh2012@gmail.com\\n# @File    : B. Preparation for International Women's Day.py\\n\\nfrom collections import Counter\\n\\n\\ndef main():\\n    n, k = map(int, input().split())\\n    d = list(map(int, input().split()))\\n\\n    counter = Counter()\\n    for x in d:\\n        counter[x % k] += 1\\n\\n    ret = counter[0] // 2 * 2\\n    for i in range(1, k):\\n        if i != k - i:\\n            ret += min(counter[i], counter[k - i])\\n        else:\\n            ret += counter[i] // 2 * 2\\n    print(ret)\\n\\n\\ndef __starting_point():\\n    main()\\n__starting_point()\", \"n, k = list(map(int, input().split()))\\n\\na = list(map(int, input().split()))\\n\\ndivs = {}\\nhandled = [False, ] * k\\n\\nfor x in a:\\n    divs[x % k] = divs.get(x % k, 0) + 1\\n\\nresult = divs.get(0, 0) - divs.get(0, 0) % 2\\n\\nfor i in range(1, k):\\n    if not handled[i] and not handled[k - i]:\\n        if i != k - i:\\n            result += 2 * min(divs.get(i, 0), divs.get(k - i, 0))\\n        else:\\n            result += divs.get(i, 0) - divs.get(i, 0) % 2\\n        handled[i] = handled[k - i] = True\\n\\nprint(result)\\n\", \"#map(int,input().split())\\n#int(input())\\nn,k=map(int,input().split())\\na=list(map(int,input().split()))\\nd = dict()\\nfor i in range(n):\\n    m=a[i]%k\\n    if m not in d:\\n       d[m]=1\\n    else:\\n        d[m]+=1\\nans=0\\nif 0 in d:\\n   ans = d[0]//2\\nh=k//2\\nif k%2==0 and h in d:\\n    ans  += d[h]//2\\nfor i in range(1,(k+1)//2):\\n    if i in d and k-i in d:\\n       ans += min(d[i],d[k-i])\\nprint(ans*2)\", \"from math import floor\\nfrom collections import defaultdict\\n\\nn, k = map(int, input().split())\\na = defaultdict(int)\\nfor i in input().split():\\n    i = int(i) % k\\n    a[i] += 1\\nr = 0\\nfor i in range(floor(k / 2) + 1):\\n    if i == 0 or i == k - i:\\n        r += a[i] // 2\\n    else:\\n        r += min(a[i], a[k - i])\\nprint(r * 2)\", \"n,k=tuple(map(int,input().strip().split(\\\" \\\")))\\nnumbers=tuple(map(int,input().strip().split(\\\" \\\")))\\nl=[]\\nfor i in range(k):\\n    l.append(0)\\nfor i in numbers:\\n    l[i%k]+=1\\ns=(l[0]//2)*2\\nimport math\\nfor g in range(1,math.ceil(k/2)):\\n    s=s+(min(l[g],l[k-g])*2)\\nif(k%2==0):\\n    s=s+((l[k//2]//2)*2)\\nprint(s)\", \"def main():\\n    n,k = list(map(int,input().split()))\\n    candy = list(map(int,input().split()))\\n    candies = []\\n    zeroes = 0\\n    for i in candy:\\n        mod = i%k\\n        if mod == 0:\\n            zeroes += 1\\n        else:\\n            candies.append(mod)\\n\\n    candies.sort()\\n\\n    boxes = zeroes//2\\n\\n    candy_dict = {}\\n\\n    for i in candies:\\n        if i not in list(candy_dict.keys()):\\n            candy_dict[i] = 1\\n        else:\\n            candy_dict[i] += 1\\n\\n    #print (candy_dict)\\n    for i in candy_dict:\\n        if candy_dict[i] > 0:\\n            if (k-i) in list(candy_dict.keys()):\\n                if candy_dict[k-i] > 0:\\n                    if i == (k-i):\\n                        box = candy_dict[i]//2\\n                        candy_dict[i] = candy_dict[i]%2\\n                    else:\\n                        box = min(candy_dict[i],candy_dict[k-i])\\n                        candy_dict[i] -= box\\n                        candy_dict[k-i] -= box\\n                    boxes += box\\n\\n    print(2*boxes)\\n    \\n\\nmain()\\n\", \"n,k=list(map(int,input().split()))\\na=[int(x)%k for x in input().split()]\\nf={}\\nan=0\\nfor i in a:\\n    if -i in f and f[-i]>0:\\n        an+=2\\n        f[-i]-=1\\n    elif k-i in f and f[k-i]>0:\\n        an+=2\\n        f[k-i]-=1\\n    else:\\n        if i not in f:f[i]=0\\n        f[i]+=1\\nprint(an)\\n\", \"n, k = list(map(int, input().split()))\\nd = list(map(int, input().split()))\\nost = [0] * k\\nfor i in range(n):\\n    ost[d[i] % k] += 1\\nans = ost[0] // 2\\nfor i in range(1, k // 2 + 1):\\n    if i != k - i:\\n        ans += min(ost[i], ost[k - i])\\n    else:\\n        ans += ost[i] // 2\\nprint(ans * 2)\\n\", \"n, k = map(int, input().split())\\ncandies = list(map(int, input().split()))\\n\\ndiv = [0 for i in range(k)]\\n\\nfor i in candies:\\n    div[i % k] += 1\\n\\n\\nres = (div[0] // 2)*2\\nif k % 2 == 1:\\n    c = k//2 +1\\nelse:\\n    c = k//2 + 1\\nfor i in range(1, c):\\n    res += 2 * min(div[i], div[k - i]) if i != k - i else (div[i] // 2)*2\\nprint(res)\", \"n,k = list(map(int,input().split()))\\nnum = list(map(int,input().split()))\\ngay = []\\nfor i in num:\\n\\tgay.append(i%k)\\nnumber = [0] * 101\\nfor i in gay:\\n\\tnumber[i] += 1\\n#print(number)\\ni = 0\\nchuj = 1\\nwynik = 0\\nwhile i<k:\\n\\tif i == (k-i)%k:\\n\\t\\tif number[i] > 1:\\n\\t\\t\\tnumber[i] -= 2\\n\\t\\t\\twynik += 1\\n\\t\\telse:\\n\\t\\t\\tnumber[i] = 0\\n\\t\\t\\ti += 1\\n\\telse:\\n\\t\\tif number[i] > 0:\\n\\t\\t\\tif number[(k-i)%k]>0:\\n\\t\\t\\t\\tnumber[i] -= 1\\n\\t\\t\\t\\tnumber[(k-i)%k] -= 1\\n\\t\\t\\t\\twynik += 1\\n\\t\\t\\telse:\\n\\t\\t\\t\\tnumber[i] = 0\\n\\t\\tif number[i] == 0:\\n\\t\\t\\ti += 1\\nprint(2*wynik)\"]",
        "difficulty": "introductory",
        "input": "2 9\n81 1\n",
        "output": "0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://codeforces.com/problemset/problem/1133/B"
    },
    {
        "id": 2432,
        "task_id": 4747,
        "test_case_id": 1,
        "question": "Recently your town has been infested by swindlers who convince unknowing tourists to play a simple dice game with them for money. The game works as follows: given is an $n$-sided die, whose sides have $1, 2, \\ldots , n$ pips, and a positive integer $k$. You then roll the die, and then have to make a choice. Option $1$ is to stop rolling. Option $2$ is to reroll the die, with the limitation that the die can only be rolled $k$ times in total. Your score is the number of pips showing on your final roll.\n\nObviously the swindlers are better at this game than the tourists are. You, proud supporter of the Battle Against Probabilistic Catastrophes, decide to fight this problem not by banning the swindlers but by arming the tourists with information.\n\nYou create pamphlets on which tourists can find the maximum expected score for many values of $n$ and $k$. You are sure that the swindlers will soon stop their swindling if the tourists are better prepared than they are!\n\nThe layout of the flyers is done, and you have distribution channels set up. All that is left to do is to calculate the numbers to put on the pamphlet.\n\nGiven the number of sides of the die and the number of times you are allowed to roll, calculate the expected (that is, average) score when the game is played optimally.\n\n-----Input-----\n - A single line with two integers $1\\leq n\\leq 100$, the number of sides of the die, and $1\\leq k\\leq 100$, the number of times the die may be rolled.\n\n-----Output-----\nOutput the expected score when playing optimally. Your answer should have an absolute or relative error of at most $10^{-7}$.\n\n-----Examples-----\nSample Input 1:\n1 1\nSample Output 1:\n1\n\nSample Input 2:\n2 3\nSample Output 2:\n1.875\n\nSample Input 3:\n6 2\nSample Output 3:\n4.25",
        "solutions": "",
        "difficulty": "introductory",
        "input": "1 1\n",
        "output": "1\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/deceptivedice"
    },
    {
        "id": 2433,
        "task_id": 4773,
        "test_case_id": 1,
        "question": "One of our older Mars Rovers has nearly completed its tour of duty and is awaiting instructions for one last mission to explore the Martian surface. The survey team has picked a route and has entrusted you with the job of transmitting the final set of instructions to the rover. This route is simply a sequence of moves in the cardinal directions: North, South, East, and West. These instructions can be sent using a string of corresponding characters: N, S, E, and W. However, receiving the signal drains the rover’s power supply, which is already dangerously low. Fortunately, the rover’s creators built in the ability for you to optionally define a single “macro” that can be used if the route has a lot of repetition. More concretely, to send a message with a macro, two strings are sent. The first is over the characters {N,S,E,W,M} and the second is over {N,S,E,W}. The first string represents a sequence of moves and calls to a macro (M), while the second string determines what the macro expands out to. For example:WNMWMME\n\n EEN\n\nis an encoding ofWNEENWEENEENE\n\nNotice that the version with macros requires only $10$ characters, whereas the original requires $13$.\n\nGiven a route, determine the minimum number of characters needed to transmit it to the rover.\n\n-----Input-----\nInput consists of a single line containing a non-empty string made up of the letters N, S, E, and W representing the route to transmit to the rover. The maximum length of the string is $100$.\n\n-----Input-----\nDisplay the minimum number of characters needed to encode the route.\n\n-----Examples-----\nSample Input 1:\nWNEENWEENEENE\nSample Output 1:\n10\n\nSample Input 2:\nNSEW\nSample Output 2:\n4",
        "solutions": "",
        "difficulty": "introductory",
        "input": "WNEENWEENEENE\n",
        "output": "10\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/redrover"
    },
    {
        "id": 2434,
        "task_id": 4773,
        "test_case_id": 3,
        "question": "One of our older Mars Rovers has nearly completed its tour of duty and is awaiting instructions for one last mission to explore the Martian surface. The survey team has picked a route and has entrusted you with the job of transmitting the final set of instructions to the rover. This route is simply a sequence of moves in the cardinal directions: North, South, East, and West. These instructions can be sent using a string of corresponding characters: N, S, E, and W. However, receiving the signal drains the rover’s power supply, which is already dangerously low. Fortunately, the rover’s creators built in the ability for you to optionally define a single “macro” that can be used if the route has a lot of repetition. More concretely, to send a message with a macro, two strings are sent. The first is over the characters {N,S,E,W,M} and the second is over {N,S,E,W}. The first string represents a sequence of moves and calls to a macro (M), while the second string determines what the macro expands out to. For example:WNMWMME\n\n EEN\n\nis an encoding ofWNEENWEENEENE\n\nNotice that the version with macros requires only $10$ characters, whereas the original requires $13$.\n\nGiven a route, determine the minimum number of characters needed to transmit it to the rover.\n\n-----Input-----\nInput consists of a single line containing a non-empty string made up of the letters N, S, E, and W representing the route to transmit to the rover. The maximum length of the string is $100$.\n\n-----Input-----\nDisplay the minimum number of characters needed to encode the route.\n\n-----Examples-----\nSample Input 1:\nWNEENWEENEENE\nSample Output 1:\n10\n\nSample Input 2:\nNSEW\nSample Output 2:\n4",
        "solutions": "",
        "difficulty": "introductory",
        "input": "EEEEEEEEE\n",
        "output": "6\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/redrover"
    },
    {
        "id": 2435,
        "task_id": 4796,
        "test_case_id": 1,
        "question": "Mirko and Slavko bought a few liters of orange, apple and pineapple juice. They are now whipping up a non alcoholic cocktail following a recipe they found on the Internet. Sadly, they figured out too late that not only you should use recipes when making cocktails, you should also use them when planning how much juice to buy.\n\nWrite a program that will determine how much of each juice they will have leftover, after they make as much cocktail as possible, respecting the recipe.\n\n-----Input-----\nThe first line contains three integers, $A$, $B$, $C$, ($1 \\leq A, B, C \\leq 500$), the amount of orange, apple and pineapple juice they bought, in liters.\n\nThe second line contains three integers, $I$, $J$, $K$, ($1 \\leq I, J, K \\leq 50$), the ratio of orange, apple and pineapple juice in the cocktail.\n\n-----Output-----\nThe first and only line of output should contain three decimal numbers, the leftover amounts of each juice, in liters. Solutions with absolute or relative error $10^{-4}$ or smaller will be accepted.\n\n-----Examples-----\nSample Input 1:\n10 10 10\n3 3 3\nSample Output 1:\n0.000000 0.000000 0.000000\n\nSample Input 2:\n9 9 9\n3 2 1\nSample Output 2:\n0.000000 3.000000 6.000000",
        "solutions": "",
        "difficulty": "introductory",
        "input": "10 10 10\n3 3 3\n",
        "output": "0.000000 0.000000 0.000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/sok"
    },
    {
        "id": 2436,
        "task_id": 4796,
        "test_case_id": 2,
        "question": "Mirko and Slavko bought a few liters of orange, apple and pineapple juice. They are now whipping up a non alcoholic cocktail following a recipe they found on the Internet. Sadly, they figured out too late that not only you should use recipes when making cocktails, you should also use them when planning how much juice to buy.\n\nWrite a program that will determine how much of each juice they will have leftover, after they make as much cocktail as possible, respecting the recipe.\n\n-----Input-----\nThe first line contains three integers, $A$, $B$, $C$, ($1 \\leq A, B, C \\leq 500$), the amount of orange, apple and pineapple juice they bought, in liters.\n\nThe second line contains three integers, $I$, $J$, $K$, ($1 \\leq I, J, K \\leq 50$), the ratio of orange, apple and pineapple juice in the cocktail.\n\n-----Output-----\nThe first and only line of output should contain three decimal numbers, the leftover amounts of each juice, in liters. Solutions with absolute or relative error $10^{-4}$ or smaller will be accepted.\n\n-----Examples-----\nSample Input 1:\n10 10 10\n3 3 3\nSample Output 1:\n0.000000 0.000000 0.000000\n\nSample Input 2:\n9 9 9\n3 2 1\nSample Output 2:\n0.000000 3.000000 6.000000",
        "solutions": "",
        "difficulty": "introductory",
        "input": "9 9 9\n3 2 1\n",
        "output": "0.000000 3.000000 6.000000\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/sok"
    },
    {
        "id": 2437,
        "task_id": 4796,
        "test_case_id": 3,
        "question": "Mirko and Slavko bought a few liters of orange, apple and pineapple juice. They are now whipping up a non alcoholic cocktail following a recipe they found on the Internet. Sadly, they figured out too late that not only you should use recipes when making cocktails, you should also use them when planning how much juice to buy.\n\nWrite a program that will determine how much of each juice they will have leftover, after they make as much cocktail as possible, respecting the recipe.\n\n-----Input-----\nThe first line contains three integers, $A$, $B$, $C$, ($1 \\leq A, B, C \\leq 500$), the amount of orange, apple and pineapple juice they bought, in liters.\n\nThe second line contains three integers, $I$, $J$, $K$, ($1 \\leq I, J, K \\leq 50$), the ratio of orange, apple and pineapple juice in the cocktail.\n\n-----Output-----\nThe first and only line of output should contain three decimal numbers, the leftover amounts of each juice, in liters. Solutions with absolute or relative error $10^{-4}$ or smaller will be accepted.\n\n-----Examples-----\nSample Input 1:\n10 10 10\n3 3 3\nSample Output 1:\n0.000000 0.000000 0.000000\n\nSample Input 2:\n9 9 9\n3 2 1\nSample Output 2:\n0.000000 3.000000 6.000000",
        "solutions": "",
        "difficulty": "introductory",
        "input": "10 15 18\n3 4 1\n",
        "output": "0.000000 1.666667 14.666667\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/sok"
    },
    {
        "id": 2438,
        "task_id": 4816,
        "test_case_id": 1,
        "question": "You have a fence post located at the point $(x, y)$ in the plane, to which a goat is tethered by a rope. You also have a house, which you model as an axis-aligned rectangle with diagonally opposite corners at the points $(x_1, y_1)$ and $(x_2, y_2)$. You want to pick a length of rope that guarantees the goat cannot reach the house.\n\nDetermine the minimum distance from the fence post to the house, so that you can make sure to use a shorter rope.\n\n-----Input-----\nThe input consists of a single line containing six space-separated integers $x$, $y$, $x_1$, $y_1$, $x_2$, and $y_2$, each in the range $[-999, 999]$.\n\nIt is guaranteed that $x_1 < x_2$ and $y_1 < y_2$, and that $(x, y)$ is strictly outside the axis-aligned rectangle with corners at $(x_1, y_1)$ and $(x_2, y_2)$.\n\n-----Output-----\nPrint the minimum distance from the goat’s post to the house, with a relative or absolute error no more than $0.001$.\n\n-----Examples-----\nSample Input 1:\n7 3 0 0 5 4\nSample Output 1:\n2.0\n\nSample Input 2:\n6 0 0 2 7 6\nSample Output 2:\n2.0",
        "solutions": "",
        "difficulty": "introductory",
        "input": "7 3 0 0 5 4\n",
        "output": "2.0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/goatrope"
    },
    {
        "id": 2439,
        "task_id": 4816,
        "test_case_id": 2,
        "question": "You have a fence post located at the point $(x, y)$ in the plane, to which a goat is tethered by a rope. You also have a house, which you model as an axis-aligned rectangle with diagonally opposite corners at the points $(x_1, y_1)$ and $(x_2, y_2)$. You want to pick a length of rope that guarantees the goat cannot reach the house.\n\nDetermine the minimum distance from the fence post to the house, so that you can make sure to use a shorter rope.\n\n-----Input-----\nThe input consists of a single line containing six space-separated integers $x$, $y$, $x_1$, $y_1$, $x_2$, and $y_2$, each in the range $[-999, 999]$.\n\nIt is guaranteed that $x_1 < x_2$ and $y_1 < y_2$, and that $(x, y)$ is strictly outside the axis-aligned rectangle with corners at $(x_1, y_1)$ and $(x_2, y_2)$.\n\n-----Output-----\nPrint the minimum distance from the goat’s post to the house, with a relative or absolute error no more than $0.001$.\n\n-----Examples-----\nSample Input 1:\n7 3 0 0 5 4\nSample Output 1:\n2.0\n\nSample Input 2:\n6 0 0 2 7 6\nSample Output 2:\n2.0",
        "solutions": "",
        "difficulty": "introductory",
        "input": "6 0 0 2 7 6\n",
        "output": "2.0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/goatrope"
    },
    {
        "id": 2440,
        "task_id": 4816,
        "test_case_id": 3,
        "question": "You have a fence post located at the point $(x, y)$ in the plane, to which a goat is tethered by a rope. You also have a house, which you model as an axis-aligned rectangle with diagonally opposite corners at the points $(x_1, y_1)$ and $(x_2, y_2)$. You want to pick a length of rope that guarantees the goat cannot reach the house.\n\nDetermine the minimum distance from the fence post to the house, so that you can make sure to use a shorter rope.\n\n-----Input-----\nThe input consists of a single line containing six space-separated integers $x$, $y$, $x_1$, $y_1$, $x_2$, and $y_2$, each in the range $[-999, 999]$.\n\nIt is guaranteed that $x_1 < x_2$ and $y_1 < y_2$, and that $(x, y)$ is strictly outside the axis-aligned rectangle with corners at $(x_1, y_1)$ and $(x_2, y_2)$.\n\n-----Output-----\nPrint the minimum distance from the goat’s post to the house, with a relative or absolute error no more than $0.001$.\n\n-----Examples-----\nSample Input 1:\n7 3 0 0 5 4\nSample Output 1:\n2.0\n\nSample Input 2:\n6 0 0 2 7 6\nSample Output 2:\n2.0",
        "solutions": "",
        "difficulty": "introductory",
        "input": "3 -4 -3 -1 -1 2\n",
        "output": "5.0\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/goatrope"
    },
    {
        "id": 2441,
        "task_id": 4836,
        "test_case_id": 1,
        "question": "Young Mislav loves spending time in nature and, most of all, he loves spending time in forests. The fresh air and lovely sounds make the forest his favourite location. Mislav has decided to spend this afternoon in a forest and, because he’s so practical, he’s also decided to stuff himself with food. His belly can contain $C$ amount of food.\n\nHe will have the opportunity to eat various fruits of nature (mushrooms, chestnuts, berries, and so on) while walking through the forest. All fruits are mutually different given their type and he’d like to eat as much different fruits as possible, but with the condition that he doesn’t overeat. In other words, the total weight of the fruits he’s eaten must not be larger than $C$. Also, when Mislav decides to start eating, he tries to eat every next fruit if it’s possible to eat it and not overeat. In the case when he doesn’t have the capacity to eat it, he just moves on.\n\nAn array of weights of $N$ fruits represents the weight and order of fruits that Mislav came across in the forest. Determine the maximum amount of different fruits that Mislav can eat.\n\n-----Input-----\nThe first line of input contains two integers $N$ and $C$ ($1 \\leq N \\leq 1000$, $1 \\leq C \\leq 1000000$) from the task. The second line contains $N$ integers $w_ i$ ($1 \\leq w_ i \\leq 1000$) that represent the fruits’ weight.\n\n-----Output-----\nThe first and only line of output must contain the maximum possible amount of different fruits that Mislav can eat.\n\n-----Examples-----\nSample Input 1:\n5 5\n3 1 2 1 1\nSample Output 1:\n4\n\nSample Input 2:\n7 5\n1 5 4 3 2 1 1\nSample Output 2:\n3",
        "solutions": "",
        "difficulty": "introductory",
        "input": "5 5\n3 1 2 1 1\n",
        "output": "4\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/putovanje"
    },
    {
        "id": 2442,
        "task_id": 4836,
        "test_case_id": 2,
        "question": "Young Mislav loves spending time in nature and, most of all, he loves spending time in forests. The fresh air and lovely sounds make the forest his favourite location. Mislav has decided to spend this afternoon in a forest and, because he’s so practical, he’s also decided to stuff himself with food. His belly can contain $C$ amount of food.\n\nHe will have the opportunity to eat various fruits of nature (mushrooms, chestnuts, berries, and so on) while walking through the forest. All fruits are mutually different given their type and he’d like to eat as much different fruits as possible, but with the condition that he doesn’t overeat. In other words, the total weight of the fruits he’s eaten must not be larger than $C$. Also, when Mislav decides to start eating, he tries to eat every next fruit if it’s possible to eat it and not overeat. In the case when he doesn’t have the capacity to eat it, he just moves on.\n\nAn array of weights of $N$ fruits represents the weight and order of fruits that Mislav came across in the forest. Determine the maximum amount of different fruits that Mislav can eat.\n\n-----Input-----\nThe first line of input contains two integers $N$ and $C$ ($1 \\leq N \\leq 1000$, $1 \\leq C \\leq 1000000$) from the task. The second line contains $N$ integers $w_ i$ ($1 \\leq w_ i \\leq 1000$) that represent the fruits’ weight.\n\n-----Output-----\nThe first and only line of output must contain the maximum possible amount of different fruits that Mislav can eat.\n\n-----Examples-----\nSample Input 1:\n5 5\n3 1 2 1 1\nSample Output 1:\n4\n\nSample Input 2:\n7 5\n1 5 4 3 2 1 1\nSample Output 2:\n3",
        "solutions": "",
        "difficulty": "introductory",
        "input": "7 5\n1 5 4 3 2 1 1\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/putovanje"
    },
    {
        "id": 2443,
        "task_id": 4836,
        "test_case_id": 3,
        "question": "Young Mislav loves spending time in nature and, most of all, he loves spending time in forests. The fresh air and lovely sounds make the forest his favourite location. Mislav has decided to spend this afternoon in a forest and, because he’s so practical, he’s also decided to stuff himself with food. His belly can contain $C$ amount of food.\n\nHe will have the opportunity to eat various fruits of nature (mushrooms, chestnuts, berries, and so on) while walking through the forest. All fruits are mutually different given their type and he’d like to eat as much different fruits as possible, but with the condition that he doesn’t overeat. In other words, the total weight of the fruits he’s eaten must not be larger than $C$. Also, when Mislav decides to start eating, he tries to eat every next fruit if it’s possible to eat it and not overeat. In the case when he doesn’t have the capacity to eat it, he just moves on.\n\nAn array of weights of $N$ fruits represents the weight and order of fruits that Mislav came across in the forest. Determine the maximum amount of different fruits that Mislav can eat.\n\n-----Input-----\nThe first line of input contains two integers $N$ and $C$ ($1 \\leq N \\leq 1000$, $1 \\leq C \\leq 1000000$) from the task. The second line contains $N$ integers $w_ i$ ($1 \\leq w_ i \\leq 1000$) that represent the fruits’ weight.\n\n-----Output-----\nThe first and only line of output must contain the maximum possible amount of different fruits that Mislav can eat.\n\n-----Examples-----\nSample Input 1:\n5 5\n3 1 2 1 1\nSample Output 1:\n4\n\nSample Input 2:\n7 5\n1 5 4 3 2 1 1\nSample Output 2:\n3",
        "solutions": "",
        "difficulty": "introductory",
        "input": "5 10\n3 2 5 4 3\n",
        "output": "3\n",
        "halu_type": "Logic Deviation",
        "fn_name": null,
        "starter_code": "",
        "url": "https://open.kattis.com/problems/putovanje"
    }
]